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

It is impossible to change a default value of the ChoicesRestful.path… #6827

Merged
merged 1 commit into from
Aug 30, 2023
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
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class Base {
if (this.isPropertyEmpty(res)) {
const locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
if(locStr) return locStr.text;
if (defaultValue != null) return defaultValue;
if (defaultValue !== null && defaultValue !== undefined) return defaultValue;
const propDefaultValue = this.getDefaultPropertyValue(name);
if(propDefaultValue !== undefined) return propDefaultValue;
}
Expand Down
3 changes: 2 additions & 1 deletion src/choicesRestful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ export class ChoicesRestful extends Base {
*/

public get path(): string {
return this.getPropertyValue("path", "");
const res = this.getPropertyValue("path");
return !!res ? res : "";
}
public set path(val: string) {
this.setPropertyValue("path", val);
Expand Down
7 changes: 7 additions & 0 deletions tests/question_baseselecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1189,4 +1189,11 @@ QUnit.test("Use carryForward with panel dynamic + update data on survey.data=dat
assert.equal(q2.visibleChoices[1].value, 2, "the second value is correct");
assert.equal(q2.visibleChoices[1].text, "Item 2", "the second text is correct");
});
QUnit.test("Allow to override default value fro choicesByUrl.path Bug#6766", function (assert) {
const prop = Serializer.findProperty("choicesByUrl", "path");
prop.defaultValue = "list";
const q1 = new QuestionDropdownModel("q1");
assert.equal(q1.choicesByUrl.path, "list", "get new default value for path");
prop.defaultValue = undefined;
});