From b6dd66e7a4f54f8a64ee8d379448709c3d541d92 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 24 Jul 2023 20:05:16 +0300 Subject: [PATCH] [DE PE SSE] Plugins: add button and panel in left menu for different plugins --- apps/common/main/lib/controller/Plugins.js | 45 ++++-- apps/common/main/lib/view/PluginPanel.js | 139 ++++++++++++++++++ apps/common/main/lib/view/Plugins.js | 12 +- apps/common/main/resources/less/plugins.less | 8 +- .../main/app/controller/LeftMenu.js | 42 +++++- 5 files changed, 224 insertions(+), 22 deletions(-) create mode 100644 apps/common/main/lib/view/PluginPanel.js diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index be4deefa46..c1240eae7e 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -39,7 +39,8 @@ define([ 'core', 'common/main/lib/collection/Plugins', 'common/main/lib/view/Plugins', - 'common/main/lib/view/PluginDlg' + 'common/main/lib/view/PluginDlg', + 'common/main/lib/view/PluginPanel' ], function () { 'use strict'; @@ -78,11 +79,11 @@ define([ }); }, - events: function() { + /*events: function() { return { 'click #id-plugin-close':_.bind(this.onToolClose,this) }; - }, + },*/ onLaunch: function() { var store = this.getApplication().getCollection('Common.Collections.Plugins'); @@ -101,6 +102,8 @@ define([ this.autostart = []; this.customPluginsDlg = []; + this.pluginPanels = []; + Common.Gateway.on('init', this.loadConfig.bind(this)); Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this)); Common.NotificationCenter.on('uitheme:changed', this.updatePluginsButtons.bind(this)); @@ -197,7 +200,7 @@ define([ onAfterRender: function(panelPlugins) { panelPlugins.viewPluginsList && panelPlugins.viewPluginsList.on('item:click', _.bind(this.onSelectPlugin, this)); - this.bindViewEvents(this.panelPlugins, this.events); + //this.bindViewEvents(this.panelPlugins, this.events); var me = this; Common.NotificationCenter.on({ 'layout:resizestart': function(e){ @@ -380,8 +383,18 @@ define([ if (urlAddition) url += urlAddition; if (variation.get_InsideMode()) { - if (!this.panelPlugins.openInsideMode(plugin.get_Name(lang), url, frameId, plugin.get_Guid())) + var name = plugin.get_Name('en').toLowerCase(), + panelId = 'left-panel-plugins-' + name; + if (!this.pluginPanels[name]) { + this.panelPlugins.fireEvent('plugin:new', [name, panelId]); // add button and div for panel in left menu + this.pluginPanels[name] = new Common.Views.PluginPanel({ + el: '#' + panelId + }); + } + if (!this.pluginPanels[name].openInsideMode(plugin.get_Name(lang), url, frameId, plugin.get_Guid())) this.api.asc_pluginButtonClick(-1, plugin.get_Guid()); + this.panelPlugins.fireEvent('plugin:show', [this.pluginPanels[name], name, 'show']); + this.pluginPanels[name].pluginClose.on('click', _.bind(this.onToolClose, this, this.pluginPanels[name])); } else { var me = this, isCustomWindow = variation.get_CustomWindow(), @@ -442,15 +455,25 @@ define([ me.pluginDlg.show(); } } - this.panelPlugins.openedPluginMode(plugin.get_Guid()); + !variation.get_InsideMode() && this.panelPlugins.openedPluginMode(plugin.get_Guid()); }, onPluginClose: function(plugin) { + console.log('onPluginClose'); + var isIframePlugin = false; if (this.pluginDlg) this.pluginDlg.close(); - else if (this.panelPlugins.iframePlugin) - this.panelPlugins.closeInsideMode(); - this.panelPlugins.closedPluginMode(plugin.get_Guid()); + else { + var name = plugin.get_Name('en').toLowerCase(), + panel = this.pluginPanels[name]; + if (panel && panel.iframePlugin) { + isIframePlugin = true; + panel.closeInsideMode(); + this.panelPlugins.fireEvent('plugin:show', [this.pluginPanels[name], name, 'close']); + this.pluginPanels[name] = undefined; + } + } + !isIframePlugin && this.panelPlugins.closedPluginMode(plugin.get_Guid()); this.runAutoStartPlugins(); }, @@ -464,8 +487,8 @@ define([ } }, - onToolClose: function() { - this.api.asc_pluginButtonClick(-1, this.panelPlugins ? this.panelPlugins._state.insidePlugin : undefined); + onToolClose: function(panel) { + this.api.asc_pluginButtonClick(-1, panel ? panel._state.insidePlugin : undefined); }, onPluginMouseUp: function(x, y) { diff --git a/apps/common/main/lib/view/PluginPanel.js b/apps/common/main/lib/view/PluginPanel.js new file mode 100644 index 0000000000..c62ead9538 --- /dev/null +++ b/apps/common/main/lib/view/PluginPanel.js @@ -0,0 +1,139 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2023 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ +/** + * User: Julia.Svinareva + * Date: 22.07.23 + * Time: 17:18 + */ + +if (Common === undefined) + var Common = {}; + +Common.Views = Common.Views || {}; + +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/BaseView', + 'common/main/lib/component/Layout' +], function (template) { + 'use strict'; + + Common.Views.PluginPanel = Common.UI.BaseView.extend(_.extend({ + template: _.template([ + '
', + '
', + '
', + '
', + '', + '
', + '
', + '
', + '