Skip to content

Commit

Permalink
Incorrect clear properties in choicesByUrl fix #6766 (#7070)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Oct 5, 2023
1 parent 1241c00 commit f6af288
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
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

0 comments on commit f6af288

Please sign in to comment.