Skip to content

Commit

Permalink
Finish updating the CreatorBase API (#5101)
Browse files Browse the repository at this point in the history
* Finish updating the `CreatorBase` API

* Delete `onConditionGetTitle` description
  • Loading branch information
RomanTsukanov authored Jan 22, 2024
1 parent 3c41b9a commit 9b6f7e4
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 132 deletions.
4 changes: 2 additions & 2 deletions docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
"Title": "Survey Creator API",
"Items": [
{
"Name": "surveycreator",
"Title": "SurveyCreator"
"Name": "surveycreatormodel",
"Title": "SurveyCreatorModel"
},
{
"Name": "ICreatorOptions",
Expand Down
3 changes: 2 additions & 1 deletion docs/uri.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
"classRename": {
"surveyeditor": "survey-creator",
"surveycreator": "survey-creator"
"surveycreator": "survey-creator",
"surveycreatormodel": "survey-creator"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ export class ThemeBuilder extends Base {
}
private patchFileEditors(survey: SurveyModel) {
const questionsToPatch = survey.getAllQuestions(false, false, true).filter(q => q.getType() == "fileedit");
questionsToPatch.forEach(q => { (<QuestionFileEditorModel>q).onChooseFilesCallback = (input, onFilesChosen) => this.surveyProvider.chooseFiles(input, onFilesChosen); });
questionsToPatch.forEach(q => { (<QuestionFileEditorModel>q).onChooseFilesCallback = (input, callback) => this.surveyProvider.chooseFiles(input, callback); });
}

private getCoverJson(headerSettings: any): any {
Expand Down
321 changes: 200 additions & 121 deletions packages/survey-creator-core/src/creator-base.ts

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/survey-creator-core/src/creator-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ export interface ISurveyCreatorOptions {
uploadFiles(
files: File[],
question: Question,
uploadingCallback: (status: string, data: any) => any
callback: (status: string, data: any) => any
): void;
getHasMachineTranslation(): boolean;
doMachineTranslation(fromLocale: string, toLocale: string, strings: Array<string>, callback: (translated: Array<string>) => void): void;
chooseFiles(
input: HTMLInputElement,
onFilesChosen: (files: File[]) => void,
callback: (files: File[]) => void,
context?: { element: SurveyElement, item?: ItemValue }
): void;
}
Expand Down Expand Up @@ -458,11 +458,11 @@ export class EmptySurveyCreatorOptions implements ISurveyCreatorOptions {
uploadFiles(
files: File[],
question: Question,
uploadingCallback: (status: string, data: any) => any
callback: (status: string, data: any) => any
): void { }
getHasMachineTranslation(): boolean { return this.machineTranslationValue; }
doMachineTranslation(fromLocale: string, toLocale: string, strings: Array<string>, callback: (translated: Array<string>) => void): void { }
chooseFiles(input: HTMLInputElement, onFilesChosen: (files: File[]) => void, context?: { element: SurveyElement, item?: ItemValue }): void { }
chooseFiles(input: HTMLInputElement, callback: (files: File[]) => void, context?: { element: SurveyElement, item?: ItemValue }): void { }
}

StylesManager.applyTheme("defaultV2");
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class QuestionFileEditorModel extends QuestionFileModel {
return true;
}
}
public onChooseFilesCallback: (input: HTMLInputElement, onFilesChosen: (files: File[]) => void) => void;
public onChooseFilesCallback: (input: HTMLInputElement, callback: (files: File[]) => void) => void;
chooseFiles(event: Event) {
if(this.isInputReadOnly || !this.onChooseFilesCallback) {
return true;
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-creator-core/src/property-grid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1431,8 +1431,8 @@ export class PropertyGridLinkEditor extends PropertyGridEditor {
} else {
question.acceptedTypes = getAcceptedTypesByContentMode("image");
}
question.onChooseFilesCallback = ((input, onFilesChosen) => {
options.chooseFiles(input, onFilesChosen);
question.onChooseFilesCallback = ((input, callback) => {
options.chooseFiles(input, callback);
});
}

Expand Down

0 comments on commit 9b6f7e4

Please sign in to comment.