Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default values for carry-forward items. No values fix #8558 #8559

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,7 @@ Serializer.addClass(
return !obj.choicesFromQuestion;
},
},

{
name: "choicesByUrl:restfull",
className: "choicesByUrl",
Expand All @@ -2092,6 +2093,8 @@ Serializer.addClass(
return !obj.choicesFromQuestion;
},
},
{ name: "defaultValue:value", visibleIf: (obj: any): boolean => !obj.choicesFromQuestion, dependsOn: "choicesFromQuestion" },
{ name: "correctAnswer:value", visibleIf: (obj: any): boolean => !obj.choicesFromQuestion, dependsOn: "choicesFromQuestion" },
{ name: "separateSpecialChoices:boolean", visible: false },
{ name: "showOtherItem:boolean", alternativeName: "hasOther" },
{ name: "showNoneItem:boolean", alternativeName: "hasNone" },
Expand Down Expand Up @@ -2151,8 +2154,7 @@ Serializer.addClass(
default: "default",
choices: ["default", true, false],
visible: false,
},
// { name: "itemComponent", visible: false }
}
],
null,
"question"
Expand Down
7 changes: 7 additions & 0 deletions tests/question_baseselecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,8 @@ QUnit.test("Carry Forward and keepIncorrectValues, bug#6490", function (assert)
});
QUnit.test("Check isUsingCarryForward on deleting question", function (assert) {
const survey = new SurveyModel();
const defaultValueProp = Serializer.findProperty("dropdown", "defaultValue");
const correctAnswerProp = Serializer.findProperty("dropdown", "correctAnswer");
survey.setDesignMode(true);
survey.fromJSON({ elements: [
{ type: "dropdown", name: "q1", choices: ["B", "A", "D", "C"] },
Expand All @@ -1320,9 +1322,14 @@ QUnit.test("Check isUsingCarryForward on deleting question", function (assert) {
const q2 = <QuestionSelectBase>survey.getQuestionByName("q2");
assert.equal(q2.choicesFromQuestion, "q1", "set correctly");
assert.equal(q2.isUsingCarryForward, true, "Carryforward flag is set");
assert.equal(defaultValueProp.isVisible("", q2), false, "defaultValueProp.isVisible #1");
assert.equal(correctAnswerProp.isVisible("", q2), false, "correctAnswerProp.isVisible #1");

q1.delete();
assert.notOk(q2.choicesFromQuestion, "it is empty");
assert.equal(q2.isUsingCarryForward, false, "Carryforward flag is unset");
assert.equal(defaultValueProp.isVisible("", q2), true, "defaultValueProp.isVisible #2");
assert.equal(correctAnswerProp.isVisible("", q2), true, "correctAnswerProp.isVisible #2");
});
QUnit.test("Do not notify survey on changing newItem.value", function (
assert
Expand Down