Skip to content
Merged
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
26 changes: 17 additions & 9 deletions packages/survey-creator-core/src/components/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,17 +479,25 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
return newAction;
}

private jsonsAreCompatible(objJson, json) {
let jsonIsCorresponded = true;
Object.keys(json).forEach(p => {
const question = QuestionFactory.Instance.createQuestion(objJson.type, "question") || this.element;
const propertyValue = objJson[p] === undefined ? question.getDefaultPropertyValue(p) : objJson[p];
if (p != "type" && !Helpers.isTwoValueEquals(json[p], propertyValue)) jsonIsCorresponded = false;
});
return jsonIsCorresponded;
private jsonsAreCompatible(objJson: any, json: any): boolean {
let question = this.element;
if (!!objJson && !!objJson.type && question.getType() !== objJson.type) {
question = QuestionFactory.Instance.createQuestion(objJson.type, "question") || this.element;
}
const keys = Object.keys(json);
for (let i = 0; i < keys.length; i++) {
const p = keys[i];
if (!objJson && p === "type") continue;
let propertyValue = !!objJson ? objJson[p] : question.getPropertyValue(p);
if (!!objJson && propertyValue === undefined) {
propertyValue = p === "type" ? question.getType() : question.getDefaultPropertyValue(p);
}
if (!Helpers.isTwoValueEquals(json[p], propertyValue)) return false;
}
return true;
}
private jsonIsCorresponded(json: any) {
return this.jsonsAreCompatible(this.element.toJSON(), json);
return this.jsonsAreCompatible(undefined, json);
}

private toolboxItemIsCorresponded(toolboxItem: QuestionToolboxItem, someItemSelectedAlready: boolean) {
Expand Down