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

Incorrect clear properties in choicesByUrl fix #6766 #7070

Merged
merged 1 commit into from
Oct 5, 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
12 changes: 6 additions & 6 deletions src/choicesRestful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,12 @@ export class ChoicesRestful extends Base {
if (prop.type == "itemvalue[]") return "itemvalue";
return prop.type;
}
public clear() {
this.url = "";
this.path = "";
this.valueName = "";
this.titleName = "";
this.imageLinkName = "";
public clear(): void {
this.url = undefined;
this.path = undefined;
this.valueName = undefined;
this.titleName = undefined;
this.imageLinkName = undefined;
var properties = this.getCustomPropertiesNames();
for (var i = 0; i < properties.length; i++) {
if ((<any>this)[properties[i]]) (<any>this)[properties[i]] = "";
Expand Down
19 changes: 19 additions & 0 deletions tests/surveyserializationtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,25 @@ QUnit.test("Deserialize choicesByUrl", function (assert) {
"data is copied correctly"
);
});
QUnit.test("Change choicesByUrl.path default value", function (assert) {
const prop = Serializer.findProperty("choicesByUrl", "path");
assert.ok(prop, "Property is here");
prop.defaultValue = "list";
let question = new QuestionDropdownModel("q1");
assert.equal(question.choicesByUrl.path, "list", "Get value from property default value");
const survey = new SurveyModel({
elements: [
{
type: "dropdown",
name: "question1",
choicesByUrl: {
valueName: "name"
}
}] });
question = <QuestionDropdownModel>survey.getQuestionByName("question1");
assert.equal(question.choicesByUrl.path, "list", "Get value from property default value, #2");
prop.defaultValue = undefined;
});
QUnit.test("MatrixDropdown serialize and deserialize", function (assert) {
var matrix = new QuestionMatrixDropdownModelBase("q1");
matrix.columns.push(new MatrixDropdownColumn("col1"));
Expand Down
Loading