Skip to content

Commit

Permalink
Condition Property Editor doesn't work when question.valueName equals…
Browse files Browse the repository at this point in the history
… to {prefix} + question.valueName #953
  • Loading branch information
andrewtelnov committed Sep 13, 2020
1 parent 00fd81f commit 37116d3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/propertyEditors/propertyConditionEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,13 @@ export class ConditionEditorItem {
}
private getQuestionValueByName(questionName: string): string {
var question = this.owner.getQuestionByName(questionName);
if (question && question.name != question.getValueName())
if (
question &&
question.name != question.getValueName() &&
questionName != question.getValueName()
) {
return questionName.replace(question.name, question.getValueName());
}
return questionName;
}
private getValueText(): string {
Expand Down Expand Up @@ -387,7 +392,8 @@ export class ConditionEditorItem {
}
}

export class SurveyPropertyConditionEditor extends SurveyPropertyTextEditor
export class SurveyPropertyConditionEditor
extends SurveyPropertyTextEditor
implements IConditionEditorItemOwner {
public showHelpText: boolean = true;
public koTextValue: any;
Expand Down
28 changes: 28 additions & 0 deletions tests/propertyEditors/propertyConditionEditorTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1855,3 +1855,31 @@ QUnit.test(
);
}
);
QUnit.test(
"SurveyPropertyConditionEditor, valueName with ':', Bug #953",
function (assert) {
var survey = new Survey.Survey({
elements: [
{ name: "q1", type: "text", valueName: "profile:q1" },
{
name: "q2",
type: "text",
},
],
});
var question = survey.getQuestionByName("q2");
var property = Survey.Serializer.findProperty("question", "visibleIf");
var editor = new SurveyPropertyConditionEditor(property);
editor.object = question;
editor.beforeShow();
editor.isEditorShowing = true;
var editorItem = editor.koEditorItems()[0];
editorItem.questionName = "profile:q1";
editorItem.value = "1";
assert.equal(
editorItem.toString(),
"{profile:q1} = 1",
"Condition sets correctly"
);
}
);

0 comments on commit 37116d3

Please sign in to comment.