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

We don't need do anything on after loading json for SurveyForTextWorker #6048

Merged
merged 3 commits into from
Nov 11, 2024
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
18 changes: 16 additions & 2 deletions packages/survey-creator-core/src/textWorker.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { SurveyModel, JsonError, Base, ISurveyElement } from "survey-core";
import { SurveyModel, JsonError, Base, ISurveyElement, ISurveyData, ISurvey } from "survey-core";
import { SurveyHelper } from "./survey-helper";
import { SurveyJSON5 } from "./json5";
import { settings } from "./creator-settings";

class SurveyForTextWorker extends SurveyModel {
private isRunEndLoadingFromJson: boolean;
constructor(jsonObj: any) {
super();
this.setDesignMode(true);
this.fromJSON(jsonObj);
}
//Run endLoading before fixing issues with unique names
public runEndLoadingFromJson(): void {
if(this.isRunEndLoadingFromJson) return;
this.isRunEndLoadingFromJson = true;
super.endLoadingFromJson();
}
//Do nothing on end loading
endLoadingFromJson(): void {}
getSurveyData(): ISurveyData { return null; }
}

class SurveyTextWorkerJsonErrorFixerBase {
Expand Down Expand Up @@ -113,7 +123,11 @@ class SurveyTextWorkerJsonDuplicateNameErrorFixer extends SurveyTextWorkerJsonEr
return this.getNewIndex(text, "\"name\":", at, end);
}
protected updatedJsonObjOnFix(json: any): void {
json["name"] = SurveyHelper.getNewElementName(<ISurveyElement><any>this.element);
const el: any = this.element;
if(el.survey?.runEndLoadingFromJson) {
el.survey.runEndLoadingFromJson();
}
json["name"] = SurveyHelper.getNewElementName(el);
}
}
class SurveyTextWorkerJsonRequiredPropertyErrorFixer extends SurveyTextWorkerJsonErrorFixer {
Expand Down