Skip to content

Commit

Permalink
Optionally store survey sjsVersion in JSON fix #6377 (#6378)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Jan 10, 2025
1 parent e4e470e commit 5f5a1b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2551,8 +2551,18 @@ export class SurveyCreatorModel extends Base
delete json.pages;
}
}
if(this.storeSjsVersion) {
json["sjsVersion"] = SurveySettings.version;
}
return json;
}
private storeSjsVersionValue: boolean;
public get storeSjsVersion(): boolean {
return this.storeSjsVersionValue === true;
}
public set storeSjsVersion(val: boolean) {
this.storeSjsVersionValue = val;
}
/**
* A survey JSON schema.
*
Expand Down
13 changes: 12 additions & 1 deletion packages/survey-creator-core/tests/string-editor.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,18 @@ test("StringEditor multiline paste for matrix questions", (): any => {
connectorItemRow.onTextChanging.fire(null, { value: "a\nb\r\nc" });
expect(question.rows.map(c => c.text)).toEqual(["a", "b", "c", "Row 2"]);
});

test("Support for creator.storeSjsVersion", (): any => {
const creator = new CreatorTester();
expect(creator.JSON["sjsVersion"]).toBeFalsy();
expect(creator.text.indexOf("sjsVersion") > 0).toBeFalsy();
creator.storeSjsVersion = true;
creator.JSON = { elements: [{ type: "text", name: "q1" }] };
expect(creator.JSON["sjsVersion"]).toBeTruthy();
expect(creator.text.indexOf("sjsVersion") > 0).toBeTruthy();
creator.storeSjsVersion = false;
expect(creator.JSON["sjsVersion"]).toBeFalsy();
expect(creator.text.indexOf("sjsVersion") > 0).toBeFalsy();
});
test("StringEditor Navigator - supported types", (): any => {
expect(StringItemsNavigatorBase.setQuestion(<any>{ element: new QuestionTextModel("q") })).toBeFalsy();
expect(StringItemsNavigatorBase.setQuestion(<any>{ element: new QuestionMultipleTextModel("q") })).toBeTruthy();
Expand Down

0 comments on commit 5f5a1b0

Please sign in to comment.