diff --git a/src/question_baseselect.ts b/src/question_baseselect.ts index 2aa24fe56b..0899142ebf 100644 --- a/src/question_baseselect.ts +++ b/src/question_baseselect.ts @@ -56,7 +56,7 @@ export class QuestionSelectBase extends Question { } }); this.registerPropertyChangedHandlers( - ["choicesFromQuestion", "choicesFromQuestionMode", "choicesFromValueName", "choicesFromTextName", "showNoneItem"], + ["choicesFromQuestion", "choicesFromQuestionMode", "choiceValuesFromQuestion", "choiceTextsFromQuestion", "showNoneItem"], () => { this.onVisibleChoicesChanged(); } @@ -720,17 +720,17 @@ export class QuestionSelectBase extends Question { public set choicesFromQuestionMode(val: string) { this.setPropertyValue("choicesFromQuestionMode", val); } - public get choicesFromValueName(): string { - return this.getPropertyValue("choicesFromValueName"); + public get choiceValuesFromQuestion(): string { + return this.getPropertyValue("choiceValuesFromQuestion"); } - public set choicesFromValueName(val: string) { - this.setPropertyValue("choicesFromValueName", val); + public set choiceValuesFromQuestion(val: string) { + this.setPropertyValue("choiceValuesFromQuestion", val); } - public get choicesFromTextName(): string { - return this.getPropertyValue("choicesFromTextName"); + public get choiceTextsFromQuestion(): string { + return this.getPropertyValue("choiceTextsFromQuestion"); } - public set choicesFromTextName(val: string) { - this.setPropertyValue("choicesFromTextName", val); + public set choiceTextsFromQuestion(val: string) { + this.setPropertyValue("choiceTextsFromQuestion", val); } /** * Specifies whether to hide the question if no choice items are visible. @@ -1058,14 +1058,14 @@ export class QuestionSelectBase extends Question { if(!Helpers.isValueObject(obj)) continue; const key = this.getValueKeyName(obj); if(!!key && !this.isValueEmpty(obj[key])) { - const text = !!this.choicesFromTextName ? obj[this.choicesFromTextName] : undefined; + const text = !!this.choiceTextsFromQuestion ? obj[this.choiceTextsFromQuestion] : undefined; res.push(this.createItemValue(obj[key], text)); } } return res; } private getValueKeyName(obj: any): string { - if(this.choicesFromValueName) return this.choicesFromValueName; + if(this.choiceValuesFromQuestion) return this.choiceValuesFromQuestion; const keys = Object.keys(obj); return keys.length > 0 ? keys[0] : undefined; } @@ -1803,14 +1803,14 @@ Serializer.addClass( }, }, { - name: "choicesFromValueName", + name: "choiceValuesFromQuestion", dependsOn: "choicesFromQuestion", visibleIf: (obj: any) => { return obj.carryForwardQuestionType === "array"; }, }, { - name: "choicesFromTextName", + name: "choiceTextsFromQuestion", dependsOn: "choicesFromQuestion", visibleIf: (obj: any) => { return obj.carryForwardQuestionType === "array"; diff --git a/tests/question_baseselecttests.ts b/tests/question_baseselecttests.ts index 32053b4861..f54946b902 100644 --- a/tests/question_baseselecttests.ts +++ b/tests/question_baseselecttests.ts @@ -1092,15 +1092,15 @@ QUnit.test("Use carryForward with matrix dynamic", function (assert) { assert.equal(q2.visibleChoices[2].value, "C", "the third value is correct"); }); -QUnit.test("Use carryForward with matrix dynamic + choicesFromValueName", function (assert) { +QUnit.test("Use carryForward with matrix dynamic + choiceValuesFromQuestion", function (assert) { const survey = new SurveyModel({ elements: [ { type: "matrixdynamic", name: "q1", columns: [{ name: "col1", cellType: "text" }, { name: "col2", cellType: "text" }] }, - { type: "checkbox", name: "q2", choicesFromQuestion: "q1", choicesFromValueName: "col2" } + { type: "checkbox", name: "q2", choicesFromQuestion: "q1", choiceValuesFromQuestion: "col2" } ] }); const q1 = survey.getQuestionByName("q1"); const q2 = survey.getQuestionByName("q2"); assert.equal(q2.choicesFromQuestion, "q1", "choicesFromQuestion is set"); - assert.equal(q2.choicesFromValueName, "col2", "choicesFromValueName is set"); + assert.equal(q2.choiceValuesFromQuestion, "col2", "choiceValuesFromQuestion is set"); assert.equal(q2.isUsingCarryForward, true, "Carryforward flag is set"); assert.equal(q2.visibleChoices.length, 0, "There is no choices"); assert.equal(q2.visibleChoices.length, 0, "There is no choices, row is empty"); @@ -1121,18 +1121,18 @@ QUnit.test("Use carryForward with matrix dynamic + choicesFromValueName", functi assert.equal(q2.visibleChoices.length, 3, "There are three choice"); assert.equal(q2.visibleChoices[2].value, "CC", "the third value is correct"); }); -QUnit.test("Use carryForward with panel dynamic + choicesFromValueName&choicesFromTextName", function (assert) { +QUnit.test("Use carryForward with panel dynamic + choiceValuesFromQuestion&choiceTextsFromQuestion", function (assert) { const survey = new SurveyModel({ elements: [ { type: "paneldynamic", name: "q1", panelCount: 2, templateElements: [{ name: "q1-q1", type: "text" }, { name: "q1-q2", type: "text" }, { name: "q1-q3", type: "text" }] }, - { type: "checkbox", name: "q2", choicesFromQuestion: "q1", choicesFromValueName: "q1-q2", choicesFromTextName: "q1-q3" } + { type: "checkbox", name: "q2", choicesFromQuestion: "q1", choiceValuesFromQuestion: "q1-q2", choiceTextsFromQuestion: "q1-q3" } ] }); const q1 = survey.getQuestionByName("q1"); const q2 = survey.getQuestionByName("q2"); assert.equal(q2.choicesFromQuestion, "q1", "choicesFromQuestion is set"); - assert.equal(q2.choicesFromValueName, "q1-q2", "choicesFromValueName is set"); - assert.equal(q2.choicesFromTextName, "q1-q3", "choicesFromTextName is set"); + assert.equal(q2.choiceValuesFromQuestion, "q1-q2", "choiceValuesFromQuestion is set"); + assert.equal(q2.choiceTextsFromQuestion, "q1-q3", "choiceTextsFromQuestion is set"); assert.equal(q2.isUsingCarryForward, true, "Carryforward flag is set"); assert.equal(q2.visibleChoices.length, 0, "There is no choices"); q1.panels[0].getQuestionByName("q1-q1").value = "A";