[DE] Hide toolbar tabs according to config
This commit is contained in:
parent
b738928629
commit
ad2fa65fca
97
apps/common/main/lib/component/LayoutManager.js
Normal file
97
apps/common/main/lib/component/LayoutManager.js
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* (c) Copyright Ascensio System SIA 2010-2021
|
||||||
|
*
|
||||||
|
* 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-12 Ernesta Birznieka-Upisha
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* LayoutManager.js
|
||||||
|
*
|
||||||
|
* Created by Julia Radzhabova on 06.10.2021
|
||||||
|
* Copyright (c) 2021 Ascensio System SIA. All rights reserved.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (Common === undefined)
|
||||||
|
var Common = {};
|
||||||
|
|
||||||
|
if (Common.UI === undefined) {
|
||||||
|
Common.UI = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
Common.UI.LayoutManager = new(function() {
|
||||||
|
var _config;
|
||||||
|
var _init = function(config) {
|
||||||
|
_config = config;
|
||||||
|
};
|
||||||
|
|
||||||
|
var _applyCustomization = function(config, el, prefix) {
|
||||||
|
!config && (config = _config);
|
||||||
|
if (!config) return;
|
||||||
|
|
||||||
|
for (var name in config) {
|
||||||
|
if(config.hasOwnProperty(name)) {
|
||||||
|
if(typeof config[name] === 'object')
|
||||||
|
_applyCustomization(config[name], el, name + '-');
|
||||||
|
else if (config[name] === false) {
|
||||||
|
var selector = '[data-layout-name=' + (prefix || '') + name + ']',
|
||||||
|
cmp = el ? el.find(selector) : $(selector);
|
||||||
|
cmp && cmp.hide && cmp.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var _isElementVisible = function(value, config, prefix) {
|
||||||
|
!config && (config = _config);
|
||||||
|
if (!config) return true;
|
||||||
|
|
||||||
|
var res = true;
|
||||||
|
for (var name in config) {
|
||||||
|
if(config.hasOwnProperty(name)) {
|
||||||
|
if(typeof config[name] === 'object')
|
||||||
|
res = _isElementVisible(value, config[name], (prefix || '') + name + '-');
|
||||||
|
else {
|
||||||
|
if (value === (prefix || '') + name) { // checked value is in config
|
||||||
|
res = config[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res===false) return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: _init,
|
||||||
|
applyCustomization: _applyCustomization,
|
||||||
|
isElementVisible: _isElementVisible
|
||||||
|
}
|
||||||
|
})();
|
|
@ -63,7 +63,7 @@ define([
|
||||||
var appOptions = me.getApplication().getController('Main').appOptions;
|
var appOptions = me.getApplication().getController('Main').appOptions;
|
||||||
|
|
||||||
if ( !appOptions.isEditMailMerge && !appOptions.isEditDiagram ) {
|
if ( !appOptions.isEditMailMerge && !appOptions.isEditDiagram ) {
|
||||||
var tab = {action: 'plugins', caption: me.panelPlugins.groupCaption};
|
var tab = {action: 'plugins', caption: me.panelPlugins.groupCaption, layoutname: 'toolbar-plugins'};
|
||||||
me.$toolbarPanelPlugins = me.panelPlugins.getPanel();
|
me.$toolbarPanelPlugins = me.panelPlugins.getPanel();
|
||||||
|
|
||||||
toolbar.addTab(tab, me.$toolbarPanelPlugins, 10); // TODO: clear plugins list in left panel
|
toolbar.addTab(tab, me.$toolbarPanelPlugins, 10); // TODO: clear plugins list in left panel
|
||||||
|
@ -219,7 +219,7 @@ define([
|
||||||
});
|
});
|
||||||
this.api.asc_pluginsRegister('', arr);
|
this.api.asc_pluginsRegister('', arr);
|
||||||
if (storePlugins.hasVisible())
|
if (storePlugins.hasVisible())
|
||||||
Common.NotificationCenter.trigger('tab:visible', 'plugins', true);
|
Common.NotificationCenter.trigger('tab:visible', 'plugins', Common.UI.LayoutManager.isElementVisible('toolbar-plugins'));
|
||||||
Common.Gateway.pluginsReady();
|
Common.Gateway.pluginsReady();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ define([
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('tab:visible', 'protect', true);
|
Common.NotificationCenter.trigger('tab:visible', 'protect', Common.UI.LayoutManager.isElementVisible('toolbar-protect'));
|
||||||
}
|
}
|
||||||
|
|
||||||
setEvents.call(me);
|
setEvents.call(me);
|
||||||
|
|
|
@ -646,7 +646,7 @@ define([
|
||||||
if (!me.btnHistory && separator_last)
|
if (!me.btnHistory && separator_last)
|
||||||
me.$el.find(separator_last).hide();
|
me.$el.find(separator_last).hide();
|
||||||
|
|
||||||
Common.NotificationCenter.trigger('tab:visible', 'review', config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments);
|
Common.NotificationCenter.trigger('tab:visible', 'review', (config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments) && Common.UI.LayoutManager.isElementVisible('toolbar-collaboration'));
|
||||||
|
|
||||||
setEvents.call(me);
|
setEvents.call(me);
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,8 @@ define([
|
||||||
'common/main/lib/util/LocalStorage',
|
'common/main/lib/util/LocalStorage',
|
||||||
'documenteditor/main/app/collection/ShapeGroups',
|
'documenteditor/main/app/collection/ShapeGroups',
|
||||||
'documenteditor/main/app/collection/EquationGroups',
|
'documenteditor/main/app/collection/EquationGroups',
|
||||||
'common/main/lib/component/HintManager'
|
'common/main/lib/component/HintManager',
|
||||||
|
'common/main/lib/component/LayoutManager'
|
||||||
], function () {
|
], function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -1459,6 +1460,7 @@ define([
|
||||||
this.appOptions.canRename && appHeader.setCanRename(true);
|
this.appOptions.canRename && appHeader.setCanRename(true);
|
||||||
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
|
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
|
||||||
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
|
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
|
||||||
|
this.appOptions.canBrandingExt && this.appOptions.customization && Common.UI.LayoutManager.init(this.appOptions.customization.layout);
|
||||||
|
|
||||||
if (this.appOptions.canComments)
|
if (this.appOptions.canComments)
|
||||||
Common.NotificationCenter.on('comments:cleardummy', _.bind(this.onClearDummyComment, this));
|
Common.NotificationCenter.on('comments:cleardummy', _.bind(this.onClearDummyComment, this));
|
||||||
|
@ -2047,6 +2049,7 @@ define([
|
||||||
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
|
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
|
||||||
if (this.appOptions.canBrandingExt) {
|
if (this.appOptions.canBrandingExt) {
|
||||||
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
|
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
|
||||||
|
Common.UI.LayoutManager.applyCustomization();
|
||||||
promise = this.getApplication().getController('Common.Controllers.Plugins').applyUICustomization();
|
promise = this.getApplication().getController('Common.Controllers.Plugins').applyUICustomization();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3184,7 +3184,7 @@ define([
|
||||||
|
|
||||||
me.toolbar.render(_.extend({isCompactView: compactview}, config));
|
me.toolbar.render(_.extend({isCompactView: compactview}, config));
|
||||||
|
|
||||||
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'collaboration'};
|
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'toolbar-collaboration'};
|
||||||
var $panel = me.application.getController('Common.Controllers.ReviewChanges').createToolbarPanel();
|
var $panel = me.application.getController('Common.Controllers.ReviewChanges').createToolbarPanel();
|
||||||
if ( $panel ) {
|
if ( $panel ) {
|
||||||
me.toolbar.addTab(tab, $panel, 5);
|
me.toolbar.addTab(tab, $panel, 5);
|
||||||
|
@ -3210,7 +3210,7 @@ define([
|
||||||
|
|
||||||
if ( config.isDesktopApp ) {
|
if ( config.isDesktopApp ) {
|
||||||
if ( config.canProtect ) {
|
if ( config.canProtect ) {
|
||||||
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
|
tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect'};
|
||||||
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
|
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
|
||||||
|
|
||||||
if ($panel) me.toolbar.addTab(tab, $panel, 6);
|
if ($panel) me.toolbar.addTab(tab, $panel, 6);
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="group small" id="slot-field-styles"></div>
|
<div class="group small" id="slot-field-styles"></div>
|
||||||
</section>
|
</section>
|
||||||
<section class="panel" data-tab="ins">
|
<section class="panel" data-tab="ins" data-layout-name="toolbar-insert">
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<span class="btn-slot text x-huge" id="slot-btn-blankpage"></span>
|
<span class="btn-slot text x-huge" id="slot-btn-blankpage"></span>
|
||||||
<span class="btn-slot text x-huge btn-pagebreak"></span>
|
<span class="btn-slot text x-huge btn-pagebreak"></span>
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
<span class="btn-slot text x-huge" id="slot-btn-controls"></span>
|
<span class="btn-slot text x-huge" id="slot-btn-controls"></span>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="panel" data-tab="layout">
|
<section class="panel" data-tab="layout" data-layout-name="toolbar-layout">
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<span class="btn-slot text x-huge" id="slot-btn-pagemargins"></span>
|
<span class="btn-slot text x-huge" id="slot-btn-pagemargins"></span>
|
||||||
<span class="btn-slot text x-huge" id="slot-btn-pageorient"></span>
|
<span class="btn-slot text x-huge" id="slot-btn-pageorient"></span>
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
<span class="btn-slot text x-huge" id="slot-btn-watermark"></span>
|
<span class="btn-slot text x-huge" id="slot-btn-watermark"></span>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="panel" data-tab="links">
|
<section class="panel" data-tab="links" data-layout-name="toolbar-references">
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<span class="btn-slot text x-huge btn-contents"></span>
|
<span class="btn-slot text x-huge btn-contents"></span>
|
||||||
<span class="btn-slot text x-huge" id="slot-btn-contents-update"></span>
|
<span class="btn-slot text x-huge" id="slot-btn-contents-update"></span>
|
||||||
|
|
|
@ -109,11 +109,11 @@ define([
|
||||||
Common.UI.Mixtbar.prototype.initialize.call(this, {
|
Common.UI.Mixtbar.prototype.initialize.call(this, {
|
||||||
template: _.template(template),
|
template: _.template(template),
|
||||||
tabs: [
|
tabs: [
|
||||||
{caption: me.textTabFile, action: 'file', extcls: 'canedit', layoutname: 'file', haspanel:false},
|
|
||||||
{caption: me.textTabHome, action: 'home', extcls: 'canedit', layoutname: 'home'},
|
{caption: me.textTabHome, action: 'home', extcls: 'canedit', layoutname: 'home'},
|
||||||
{caption: me.textTabInsert, action: 'ins', extcls: 'canedit', layoutname: 'insert'},
|
{caption: me.textTabFile, action: 'file', extcls: 'canedit', layoutname: 'toolbar-file', haspanel:false},
|
||||||
{caption: me.textTabLayout, action: 'layout', extcls: 'canedit', layoutname: 'layout'},
|
{caption: me.textTabInsert, action: 'ins', extcls: 'canedit', layoutname: 'toolbar-insert'},
|
||||||
{caption: me.textTabLinks, action: 'links', extcls: 'canedit', layoutname: 'references'}
|
{caption: me.textTabLayout, action: 'layout', extcls: 'canedit', layoutname: 'toolbar-layout'},
|
||||||
|
{caption: me.textTabLinks, action: 'links', extcls: 'canedit', layoutname: 'toolbar-references'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -2434,11 +2434,11 @@ define([
|
||||||
}
|
}
|
||||||
me.toolbar.render(_.extend({compactview: compactview}, config));
|
me.toolbar.render(_.extend({compactview: compactview}, config));
|
||||||
|
|
||||||
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
|
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'toolbar-collaboration'};
|
||||||
var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel();
|
var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel();
|
||||||
if ( $panel ) {
|
if ( $panel ) {
|
||||||
me.toolbar.addTab(tab, $panel, 4);
|
me.toolbar.addTab(tab, $panel, 4);
|
||||||
me.toolbar.setVisible('review', config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments);
|
me.toolbar.setVisible('review', (config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments) && Common.UI.LayoutManager.isElementVisible('toolbar-collaboration'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.isEdit ) {
|
if ( config.isEdit ) {
|
||||||
|
@ -2465,7 +2465,7 @@ define([
|
||||||
|
|
||||||
if ( config.isDesktopApp ) {
|
if ( config.isDesktopApp ) {
|
||||||
if ( config.canProtect ) { // don't add protect panel to toolbar
|
if ( config.canProtect ) { // don't add protect panel to toolbar
|
||||||
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
|
tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect'};
|
||||||
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
|
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
|
||||||
if ($panel)
|
if ($panel)
|
||||||
me.toolbar.addTab(tab, $panel, 4);
|
me.toolbar.addTab(tab, $panel, 4);
|
||||||
|
|
|
@ -3706,11 +3706,11 @@ define([
|
||||||
me.toolbar.render(_.extend({isCompactView: compactview}, config));
|
me.toolbar.render(_.extend({isCompactView: compactview}, config));
|
||||||
|
|
||||||
if ( !config.isEditDiagram && !config.isEditMailMerge ) {
|
if ( !config.isEditDiagram && !config.isEditMailMerge ) {
|
||||||
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
|
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration, layoutname: 'toolbar-collaboration'};
|
||||||
var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel();
|
var $panel = me.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel();
|
||||||
if ($panel) {
|
if ($panel) {
|
||||||
me.toolbar.addTab(tab, $panel, 6);
|
me.toolbar.addTab(tab, $panel, 6);
|
||||||
me.toolbar.setVisible('review', config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments);
|
me.toolbar.setVisible('review', (config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments) && Common.UI.LayoutManager.isElementVisible('toolbar-collaboration'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3746,13 +3746,13 @@ define([
|
||||||
Array.prototype.push.apply(me.toolbar.lockControls, formulatab.getButtons());
|
Array.prototype.push.apply(me.toolbar.lockControls, formulatab.getButtons());
|
||||||
|
|
||||||
if ( config.canFeaturePivot ) {
|
if ( config.canFeaturePivot ) {
|
||||||
tab = {action: 'pivot', caption: me.textPivot};
|
tab = {action: 'pivot', caption: me.textPivot, layoutname: 'toolbar-pivot'};
|
||||||
var pivottab = me.getApplication().getController('PivotTable');
|
var pivottab = me.getApplication().getController('PivotTable');
|
||||||
pivottab.setApi(me.api).setConfig({toolbar: me});
|
pivottab.setApi(me.api).setConfig({toolbar: me});
|
||||||
$panel = pivottab.createToolbarPanel();
|
$panel = pivottab.createToolbarPanel();
|
||||||
if ($panel) {
|
if ($panel) {
|
||||||
me.toolbar.addTab(tab, $panel, 5);
|
me.toolbar.addTab(tab, $panel, 5);
|
||||||
me.toolbar.setVisible('pivot', true);
|
me.toolbar.setVisible('pivot', Common.UI.LayoutManager.isElementVisible('toolbar-pivot'));
|
||||||
Array.prototype.push.apply(me.toolbar.lockControls, pivottab.getView('PivotTable').getButtons());
|
Array.prototype.push.apply(me.toolbar.lockControls, pivottab.getView('PivotTable').getButtons());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3769,7 +3769,7 @@ define([
|
||||||
me.toolbar.btnCopy.$el.removeClass('split');
|
me.toolbar.btnCopy.$el.removeClass('split');
|
||||||
}
|
}
|
||||||
|
|
||||||
var tab = {action: 'protect', caption: me.toolbar.textTabProtect};
|
var tab = {action: 'protect', caption: me.toolbar.textTabProtect, layoutname: 'toolbar-protect'};
|
||||||
var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
|
var $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
|
||||||
if ($panel) {
|
if ($panel) {
|
||||||
config.canProtect && $panel.append($('<div class="separator long"></div>'));
|
config.canProtect && $panel.append($('<div class="separator long"></div>'));
|
||||||
|
|
Loading…
Reference in a new issue