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

Work for https://github.com/surveyjs/private-tasks/issues/453 - urveyjs.io - Wrong icon version - Passed icon name to addTab method #6585

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class TabDesignerPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("designer", this);
creator.addTab({ name: "designer", plugin: this, iconName: "icon-config" });
this.tabControlModel = new TabControlModel(this.creator.sidebar);
this.propertyGrid = new PropertyGridModel(undefined, creator, creator.getPropertyGridDefinition());
this.showOneCategoryInPropertyGrid = creator.showOneCategoryInPropertyGrid;
Expand Down Expand Up @@ -287,7 +287,7 @@ export class TabDesignerPlugin implements ICreatorPlugin {
});
this.propertyGrid.survey.onPageVisibleChanged.add((sender: SurveyModel, options: PageVisibleChangedEvent) => {
const action = this.tabControlModel.topToolbar.getActionById(options.page.name);
if(!!action) {
if (!!action) {
action.visible = options.page.isVisible;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class TabJsonEditorAcePlugin
implements ICreatorPlugin {
constructor(creator: SurveyCreatorModel) {
super(creator);
creator.addPluginTab("json", this, undefined, "svc-tab-json-editor-ace");
creator.addTab({ name: "json", plugin: this, iconName: "icon-codeeditor-24x24", componentName: "svc-tab-json-editor-ace" });
}
protected createModel(
creator: SurveyCreatorModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TabJsonEditorTextareaPlugin
implements ICreatorPlugin {
constructor(creator: SurveyCreatorModel) {
super(creator);
creator.addPluginTab("json", this, undefined, "svc-tab-json-editor-textarea");
creator.addTab({ name: "json", plugin: this, iconName: "icon-codeeditor-24x24", componentName: "svc-tab-json-editor-textarea" });
}
protected createModel(
creator: SurveyCreatorModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class TabLogicPlugin implements ICreatorPlugin {
private fastEntryAction: Action;
public model: SurveyLogicUI;
constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("logic", this);
creator.addTab({ name: "logic", plugin: this, iconName: "icon-logic-24x24" });
this.createActions().forEach(action => creator.toolbar.actions.push(action));
}
public activate(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TabTestPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("preview", this);
creator.addTab({ name: "preview", plugin: this, iconName: "icon-preview" });
this.setPreviewTheme(this.creator.previewTheme);
this.createActions().forEach(action => creator.toolbar.actions.push(action));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class ThemeTabPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("theme", this);
creator.addTab({ name: "theme", plugin: this, iconName: "icon-theme" });
this.simulatorCssClasses = surveyCss[defaultThemeName];
this.tabControlModel = new TabControlModel(this.creator.sidebar);
this.createActions().forEach(action => creator.toolbar.actions.push(action));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TabTranslationPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("translation", this);
creator.addTab({ name: "translation", plugin: this, iconName: "icon-language" });
this.showOneCategoryInPropertyGrid = creator.showOneCategoryInPropertyGrid;
this.tabControlModel = new TabControlModel(this.creator.sidebar);
this.sidebarTab = this.creator.sidebar.addPage("translation");
Expand Down
19 changes: 17 additions & 2 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
addIconsToThemeSet,
SvgThemeSets
} from "survey-core";
import { ICreatorPlugin, ISurveyCreatorOptions, settings, ICollectionItemAllowOperations } from "./creator-settings";
import { ICreatorPlugin, ISurveyCreatorOptions, settings, ICollectionItemAllowOperations, ITabOptions } from "./creator-settings";
import { editorLocalization, setupLocale } from "./editorLocalization";
import { SurveyJSON5 } from "./json5";
import { DragDropChoices } from "survey-core";
Expand Down Expand Up @@ -477,7 +477,22 @@ export class SurveyCreatorModel extends Base
componentName?: string,
index?: number
) {
this.tabbedMenu.addTab(name, plugin, title, componentName, index);
this.tabbedMenu.addTab(name, plugin, title, undefined, componentName, index);
this.addPlugin(name, plugin);
}
public addTab(tabOptions: ITabOptions) {
let {
name,
plugin,
title,
iconName,
componentName,
index
} = tabOptions;
if (!name || !plugin) {
throw new Error("Plugin or name is not set");
}
this.tabbedMenu.addTab(name, plugin, title, iconName, componentName, index);
this.addPlugin(name, plugin);
}
public addPlugin(name: string, plugin: ICreatorPlugin): void {
Expand Down
13 changes: 11 additions & 2 deletions packages/survey-creator-core/src/creator-settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Base, IAction, ItemValue,
import {
Base, IAction, ItemValue,
JsonObjectProperty, MatrixDropdownColumn, Question,
SurveyModel, ILocalizableString, PopupBaseViewModel, SurveyElement
} from "survey-core";
Expand Down Expand Up @@ -202,7 +203,15 @@ export interface ICreatorPlugin {
dispose?: () => void;
onDesignerSurveyPropertyChanged?: (obj: Base, propName: string) => void;
model: Base;
showOneCategoryInPropertyGrid?: boolean;
}

export interface ITabOptions {
name: string;
plugin: ICreatorPlugin;
title?: string;
iconName?: string;
componentName?: string;
index?: number;
}

export interface ISurveyCreatorOptions {
Expand Down
14 changes: 2 additions & 12 deletions packages/survey-creator-core/src/tabbed-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ export interface ITabbedMenuItem extends IAction {
renderTab?: () => any;
}

const tabsIcons = {
designer: "icon-config",
theme: "icon-theme",
json: "icon-codeeditor-24x24",
translation: "icon-language",
preview: "icon-preview",
logic: "icon-logic-24x24",
customembeded: "icon-embedsurvey-24x24",
default: "icon-undefined-24x24"
};

export class TabbedMenuItem extends Action implements ITabbedMenuItem {
constructor(item: ITabbedMenuItem) {
super(item);
Expand Down Expand Up @@ -59,6 +48,7 @@ export class TabbedMenuContainer extends AdaptiveActionContainer<TabbedMenuItem>
public addTab(name: string,
plugin: ICreatorPlugin,
title?: string,
iconName?: string,
componentName?: string,
index?: number) {
const tabName = name === "test" ? "preview" : name;
Expand All @@ -69,7 +59,7 @@ export class TabbedMenuContainer extends AdaptiveActionContainer<TabbedMenuItem>
title: title,
componentContent: componentName ? componentName : "svc-tab-" + name,
data: plugin,
iconName: tabsIcons[tabName] || tabsIcons["default"],
iconName: iconName || "icon-undefined-24x24",
action: () => { this.creator.switchTab(name); },
active: this.creator.viewType === name,
disableHide: this.creator.viewType === name
Expand Down