diff --git a/src/entries/index.ts b/src/entries/index.ts index f10e20209e..73830143bc 100644 --- a/src/entries/index.ts +++ b/src/entries/index.ts @@ -62,7 +62,8 @@ export { export { SurveyPropertyDefaultValueEditor, SurveyPropertyDefaultRowValueEditor, - SurveyPropertyDefaultPanelValueEditor + SurveyPropertyDefaultPanelValueEditor, + SurveyPropertySetEditor } from "../propertyEditors/propertyDefaultValueEditor"; export { SurveyPropertyTriggersEditor diff --git a/src/propertyEditors/propertyDefaultValueEditor.ts b/src/propertyEditors/propertyDefaultValueEditor.ts index 51e7bf5aaa..8a2ff6f234 100644 --- a/src/propertyEditors/propertyDefaultValueEditor.ts +++ b/src/propertyEditors/propertyDefaultValueEditor.ts @@ -76,9 +76,6 @@ export class SurveyPropertyDefaultValueEditor extends SurveyPropertyModalEditor SurveyPropertyDefaultValueEditor.defaultQuestionName ); } - private getJsonType(type: string): string { - return type != "expression" ? type : "text"; - } } export class SurveyPropertyDefaultRowValueEditorBase extends SurveyPropertyDefaultValueEditor { @@ -139,6 +136,34 @@ export class SurveyPropertyDefaultPanelValueEditor extends SurveyPropertyDefault } } +export class SurveyPropertySetEditor extends SurveyPropertyDefaultValueEditor { + constructor(property: Survey.JsonObjectProperty) { + super(property); + } + public get editorType(): string { + return "set"; + } + public get editorTypeTemplate(): string { + return "value"; + } + protected getSurveyInitialValue(): any { + var res = this.editingValue; + if (!res) return res; + if (!Array.isArray(res)) { + res = [res]; + } + return res; + } + protected buildQuestionJson(): any { + var question = new Survey.QuestionCheckbox("q1"); + question.hasSelectAll = true; + if (!!this.property) { + question.choices = this.property.getChoices(this.object); + } + return SurveyPropertyDefaultValueEditor.createJsonFromQuestion(question); + } +} + SurveyPropertyEditorFactory.registerEditor("value", function( property: Survey.JsonObjectProperty ): SurveyPropertyEditorBase { @@ -156,3 +181,9 @@ SurveyPropertyEditorFactory.registerEditor("panelvalue", function( ): SurveyPropertyEditorBase { return new SurveyPropertyDefaultPanelValueEditor(property); }); + +SurveyPropertyEditorFactory.registerEditor("set", function( + property: Survey.JsonObjectProperty +): SurveyPropertyEditorBase { + return new SurveyPropertySetEditor(property); +});