Skip to content

Commit

Permalink
[common] Add default icon for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaSvinareva committed Apr 16, 2024
1 parent 1a0fd18 commit 9ac1d47
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 15 deletions.
44 changes: 32 additions & 12 deletions apps/common/main/lib/controller/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ define([
storePlugins.each(function(item){
me.viewPlugins.updatePluginIcons(item);
var guid = item.get('guid');
if (me.viewPlugins.pluginPanels[guid]) {
if (me.viewPlugins.pluginPanels[guid] && item.get('parsedIcons')) {
var menu = me.viewPlugins.pluginPanels[guid].menu === 'right' ? iconsInRightMenu : iconsInLeftMenu;
menu.push({
guid: guid,
Expand All @@ -496,13 +496,15 @@ define([
}
});
for (var key in this.viewPlugins.customPluginPanels) {
var panel = this.viewPlugins.customPluginPanels[key],
menu = panel.menu === 'right' ? iconsInRightMenu : iconsInLeftMenu;
menu.push({
guid: panel.frameId,
baseUrl: panel.baseUrl,
parsedIcons: this.viewPlugins.parseIcons(panel.icons)
});
var panel = this.viewPlugins.customPluginPanels[key];
if (panel.icons) {
var menu = panel.menu === 'right' ? iconsInRightMenu : iconsInLeftMenu;
menu.push({
guid: panel.frameId,
baseUrl: panel.baseUrl,
parsedIcons: this.viewPlugins.parseIcons(panel.icons)
});
}
}
if (iconsInLeftMenu.length > 0) {
me.viewPlugins.fireEvent('pluginsleft:updateicons', [iconsInLeftMenu]);
Expand Down Expand Up @@ -599,14 +601,21 @@ define([
model = this.viewPlugins.storePlugins.findWhere({guid: pluginGuid}),
name = createUniqueName(plugin.get_Name('en'));
model.set({menu: menu});
var icon_url, icon_cls;
if (model.get('parsedIcons')) {
icon_url = model.get('baseUrl') + model.get('parsedIcons')['normal'];
} else {
icon_cls = 'icon toolbar__icon btn-plugin-panel-default';
}
var $button = $('<div id="slot-btn-plugins' + name + '"></div>'),
button = new Common.UI.Button({
parentEl: $button,
cls: 'btn-category plugin-buttons',
hint: langName,
enableToggle: true,
toggleGroup: menu === 'right' ? 'tabpanelbtnsGroup' : 'leftMenuGroup',
iconImg: model.get('baseUrl') + model.get('parsedIcons')['normal'],
iconCls: icon_cls,
iconImg: icon_url,
onlyIcon: true,
value: pluginGuid,
type: 'plugin'
Expand Down Expand Up @@ -861,11 +870,14 @@ define([
b.visible = (isEdit || b.isViewer !== false);
});

var icons = (typeof itemVar.icons === 'string' && itemVar.icons.indexOf('%') !== -1 || !itemVar.icons2) ? itemVar.icons : itemVar.icons2;
if (!icons) icons = '';

model.set({
description: description,
index: variationsArr.length,
url: itemVar.url,
icons: (typeof itemVar.icons === 'string' && itemVar.icons.indexOf('%') !== -1 || !itemVar.icons2) ? itemVar.icons : itemVar.icons2,
icons: icons,
buttons: itemVar.buttons,
visible: visible,
help: itemVar.help
Expand Down Expand Up @@ -1201,16 +1213,23 @@ define([
var baseUrl = variation.baseUrl || "";
var model = this.viewPlugins.storePlugins.findWhere({guid: guid});
var icons = variation.icons;
var icon_url, icon_cls;

if (model) {
if ("" === baseUrl)
baseUrl = model.get('baseUrl');
if (!icons)
if (!icons) {
var modes = model.get('variations');
icons = modes[model.get('currentVariation')].get('icons');
}
}

var parsedIcons = this.viewPlugins.parseIcons(icons),
if (!icons) {
icon_cls = 'icon toolbar__icon btn-plugin-panel-default';
} else {
var parsedIcons = this.viewPlugins.parseIcons(icons);
icon_url = baseUrl + parsedIcons['normal'];
}

var $button = $('<div id="slot-btn-plugins-' + frameId + '"></div>'),
button = new Common.UI.Button({
Expand All @@ -1219,6 +1238,7 @@ define([
hint: description,
enableToggle: true,
toggleGroup: menu === 'right' ? 'tabpanelbtnsGroup' : 'leftMenuGroup',
iconCls: icon_cls,
iconImg: icon_url,
onlyIcon: true,
value: frameId,
Expand Down
13 changes: 10 additions & 3 deletions apps/common/main/lib/view/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,13 @@ define([

var modes = model.get('variations'),
icons = modes[model.get('currentVariation')].get('icons');
if (icons === '') return;
model.set('parsedIcons', this.parseIcons(icons));
this.updatePluginButton(model);
},

updatePluginButton: function(model) {
if (!model.get('visible'))
if (!model.get('visible') || !model.get('parsedIcons'))
return null;

var btn = model.get('button'),
Expand Down Expand Up @@ -452,9 +453,14 @@ define([
var modes = model.get('variations'),
guid = model.get('guid'),
icons = modes[model.get('currentVariation')].get('icons'),
parsedIcons = this.parseIcons(icons),
icon_cls, icon_url;
if (icons === '') {
icon_cls = 'toolbar__icon btn-plugin-default'
} else {
var parsedIcons = this.parseIcons(icons);
icon_url = model.get('baseUrl') + parsedIcons['normal'];
model.set('parsedIcons', parsedIcons);
model.set('parsedIcons', parsedIcons);
}
var _menu_items = [];
_.each(model.get('variations'), function(variation, index) {
if (variation.get('visible'))
Expand All @@ -468,6 +474,7 @@ define([
var _set = Common.enumLock;
var btn = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: icon_cls,
iconImg: icon_url,
caption: model.get('name'),
menu: _menu_items.length > 1,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9ac1d47

Please sign in to comment.