Skip to content

Commit 1fe149b

Browse files
committed
Add iconName into IPropertyTabInfo inteface
1 parent e82f33e commit 1fe149b

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

packages/survey-creator-core/src/question-editor/definition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface IPropertyTabInfo {
1111
title?: string;
1212
visible?: boolean;
1313
parent?: string;
14+
iconName?: string;
1415
}
1516

1617
export interface ISurveyQuestionEditorDefinition {

packages/survey-creator-core/src/question-editor/properties.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class SurveyQuestionProperties {
231231
return true;
232232
}
233233
private setTabProperties(defProperty: any): void {
234-
let tab = this.getTabOrCreate(defProperty.name);
234+
let tab = this.getTabOrCreate(defProperty.name, defProperty.iconName);
235235
if (defProperty.index > 0) {
236236
tab.index = defProperty.index;
237237
}
@@ -290,13 +290,13 @@ export class SurveyQuestionProperties {
290290
}
291291
return null;
292292
}
293-
private getTabOrCreate(tabName: string): SurveyQuestionEditorTabDefinition {
293+
private getTabOrCreate(tabName: string, iconName?: string): SurveyQuestionEditorTabDefinition {
294294
for (var i = 0; i < this.tabs.length; i++) {
295295
if (this.tabs[i].name == tabName) return this.tabs[i];
296296
}
297297
var res = new SurveyQuestionEditorTabDefinition();
298298
res.name = tabName;
299-
res.iconName = pgTabIcons[tabName] || pgTabIcons["undefined"];
299+
res.iconName = iconName || pgTabIcons[tabName] || pgTabIcons["undefined"];
300300
if (tabName == settings.propertyGrid.generalTabName) {
301301
res.index = -1;
302302
}

packages/survey-creator-core/tests/presets.tests.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,43 @@ test("set property grid defintion: just one tab for page", () => {
223223
expect(pages[0].name).toBe("general");
224224
expect(pages[0].elements).toHaveLength(3);
225225
});
226+
test("set property grid defintion & icons", () => {
227+
const creator = new CreatorTester();
228+
creator.JSON = { elements: [{ type: "text", name: "q1" }] };
229+
creator.selectQuestionByName("q1");
230+
const preset = new CreatorPreset({
231+
propertyGrid: {
232+
definition: {
233+
autoGenerateProperties: false,
234+
classes: {
235+
question: {
236+
properties: [
237+
"name",
238+
"title",
239+
"indent",
240+
{ name: "visibleIf", tab: "logic" },
241+
{ name: "enableIf", tab: "logic" },
242+
],
243+
tabs: [
244+
{ name: "general", iconName: "general!" },
245+
{ name: "logic", index: 15, iconName: "logic!" }
246+
]
247+
},
248+
}
249+
}
250+
}
251+
});
252+
preset.apply(creator);
253+
const survey = creator.propertyGrid;
254+
const pages = survey.pages;
255+
expect(pages).toHaveLength(2);
256+
expect(pages[0].name).toBe("general");
257+
expect(pages[0]["iconName"]).toEqual("general!");
258+
expect(pages[1].name).toBe("logic");
259+
expect(pages[1]["iconName"]).toEqual("logic!");
260+
expect(pages[0].elements).toHaveLength(3);
261+
expect(pages[1].elements).toHaveLength(2);
262+
});
226263
test("apply localization for tabs", () => {
227264
expect(editorLocalization.presetStrings).toBeFalsy();
228265
expect(editorLocalization.getString("tabs.logic")).toEqual("Logic");

0 commit comments

Comments
 (0)