[all] fix toolbar's rendering dependensies

This commit is contained in:
Maxim Kadushkin 2019-09-25 12:50:58 +03:00
parent 0e5aed194b
commit 2c4a281998
3 changed files with 102 additions and 104 deletions

View file

@ -2827,43 +2827,43 @@ define([
setTimeout(function () { setTimeout(function () {
me.toolbar.render(_.extend({isCompactView: compactview}, config)); me.toolbar.render(_.extend({isCompactView: compactview}, config));
}, 0);
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
var $panel = this.getApplication().getController('Common.Controllers.ReviewChanges').createToolbarPanel(); var $panel = me.application.getController('Common.Controllers.ReviewChanges').createToolbarPanel();
if ( $panel ) if ( $panel )
me.toolbar.addTab(tab, $panel, 4); me.toolbar.addTab(tab, $panel, 4);
if ( config.isEdit ) { if ( config.isEdit ) {
me.toolbar.setMode(config); me.toolbar.setMode(config);
me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled')); me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled'));
if (!(config.customization && config.customization.compactHeader)) { if (!(config.customization && config.customization.compactHeader)) {
// hide 'print' and 'save' buttons group and next separator // hide 'print' and 'save' buttons group and next separator
me.toolbar.btnPrint.$el.parents('.group').hide().next().hide(); me.toolbar.btnPrint.$el.parents('.group').hide().next().hide();
// hide 'undo' and 'redo' buttons and retrieve parent container // hide 'undo' and 'redo' buttons and retrieve parent container
var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent(); var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent();
// move 'paste' button to the container instead of 'undo' and 'redo' // move 'paste' button to the container instead of 'undo' and 'redo'
me.toolbar.btnPaste.$el.detach().appendTo($box); me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnCopy.$el.removeClass('split'); me.toolbar.btnCopy.$el.removeClass('split');
}
if ( config.isDesktopApp ) {
if ( config.canProtect ) {
tab = {action: 'protect', caption: me.toolbar.textTabProtect};
$panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
if ($panel) me.toolbar.addTab(tab, $panel, 5);
} }
}
var links = me.getApplication().getController('Links'); if ( config.isDesktopApp ) {
links.setApi(me.api).setConfig({toolbar: me}); if ( config.canProtect ) {
Array.prototype.push.apply(me.toolbar.toolbarControls, links.getView('Links').getButtons()); tab = {action: 'protect', caption: me.toolbar.textTabProtect};
} $panel = me.getApplication().getController('Common.Controllers.Protection').createToolbarPanel();
if ($panel) me.toolbar.addTab(tab, $panel, 5);
}
}
var links = me.getApplication().getController('Links');
links.setApi(me.api).setConfig({toolbar: me});
Array.prototype.push.apply(me.toolbar.toolbarControls, links.getView('Links').getButtons());
}
}, 0);
}, },
onAppReady: function (config) { onAppReady: function (config) {

View file

@ -2082,39 +2082,39 @@ define([
* */ * */
setTimeout(function () { setTimeout(function () {
me.toolbar.render(_.extend({compactview: compactview}, config)); me.toolbar.render(_.extend({compactview: compactview}, config));
}, 0);
if ( config.isEdit ) { if ( config.isEdit ) {
me.toolbar.setMode(config); me.toolbar.setMode(config);
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
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, 3); me.toolbar.addTab(tab, $panel, 3);
me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled')); me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled'));
if (!(config.customization && config.customization.compactHeader)) { if (!(config.customization && config.customization.compactHeader)) {
// hide 'print' and 'save' buttons group and next separator // hide 'print' and 'save' buttons group and next separator
me.toolbar.btnPrint.$el.parents('.group').hide().next().hide(); me.toolbar.btnPrint.$el.parents('.group').hide().next().hide();
// hide 'undo' and 'redo' buttons and get container // hide 'undo' and 'redo' buttons and get container
var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent(); var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent();
// move 'paste' button to the container instead of 'undo' and 'redo' // move 'paste' button to the container instead of 'undo' and 'redo'
me.toolbar.btnPaste.$el.detach().appendTo($box); me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnCopy.$el.removeClass('split'); me.toolbar.btnCopy.$el.removeClass('split');
} }
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};
$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);
}
} }
} }
} }, 0);
}, },
onAppReady: function (config) { onAppReady: function (config) {

View file

@ -3128,71 +3128,69 @@ define([
} }
setTimeout(function () { setTimeout(function () {
Common.Utils.asyncCall(function () { me.toolbar.render(_.extend({isCompactView: compactview}, config));
me.toolbar.render(_.extend({isCompactView: compactview}, config)); if ( config.isEdit ) {
if ( config.isEdit ) { me.toolbar.setMode(config);
me.toolbar.setMode(config);
me.toolbar.btnSave && me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled')); me.toolbar.btnSave && me.toolbar.btnSave.on('disabled', _.bind(me.onBtnChangeState, me, 'save:disabled'));
me.toolbar.btnUndo && me.toolbar.btnUndo.on('disabled', _.bind(me.onBtnChangeState, me, 'undo:disabled')); me.toolbar.btnUndo && me.toolbar.btnUndo.on('disabled', _.bind(me.onBtnChangeState, me, 'undo:disabled'));
me.toolbar.btnRedo && me.toolbar.btnRedo.on('disabled', _.bind(me.onBtnChangeState, me, 'redo:disabled')); me.toolbar.btnRedo && me.toolbar.btnRedo.on('disabled', _.bind(me.onBtnChangeState, me, 'redo:disabled'));
me.toolbar.btnPrint && me.toolbar.btnPrint.on('disabled', _.bind(me.onBtnChangeState, me, 'print:disabled')); me.toolbar.btnPrint && me.toolbar.btnPrint.on('disabled', _.bind(me.onBtnChangeState, me, 'print:disabled'));
me.toolbar.setApi(me.api); me.toolbar.setApi(me.api);
if ( !config.isEditDiagram && !config.isEditMailMerge ) { if ( !config.isEditDiagram && !config.isEditMailMerge ) {
var datatab = me.getApplication().getController('DataTab'); var datatab = me.getApplication().getController('DataTab');
datatab.setApi(me.api).setConfig({toolbar: me}); datatab.setApi(me.api).setConfig({toolbar: me});
datatab = datatab.getView('DataTab'); datatab = datatab.getView('DataTab');
Array.prototype.push.apply(me.toolbar.lockControls, datatab.getButtons()); Array.prototype.push.apply(me.toolbar.lockControls, datatab.getButtons());
me.toolbar.btnsSortDown = datatab.getButtons('sort-down'); me.toolbar.btnsSortDown = datatab.getButtons('sort-down');
me.toolbar.btnsSortUp = datatab.getButtons('sort-up'); me.toolbar.btnsSortUp = datatab.getButtons('sort-up');
me.toolbar.btnsSetAutofilter = datatab.getButtons('set-filter'); me.toolbar.btnsSetAutofilter = datatab.getButtons('set-filter');
me.toolbar.btnsClearAutofilter = datatab.getButtons('clear-filter'); me.toolbar.btnsClearAutofilter = datatab.getButtons('clear-filter');
var formulatab = me.getApplication().getController('FormulaDialog'); var formulatab = me.getApplication().getController('FormulaDialog');
formulatab.setConfig({toolbar: me}); formulatab.setConfig({toolbar: me});
formulatab = formulatab.getView('FormulaTab'); formulatab = formulatab.getView('FormulaTab');
me.toolbar.btnsFormula = formulatab.getButtons('formula'); me.toolbar.btnsFormula = formulatab.getButtons('formula');
Array.prototype.push.apply(me.toolbar.lockControls, formulatab.getButtons()); Array.prototype.push.apply(me.toolbar.lockControls, formulatab.getButtons());
if ( !config.isOffline ) { if ( !config.isOffline ) {
tab = {action: 'pivot', caption: me.textPivot}; tab = {action: 'pivot', caption: me.textPivot};
$panel = me.getApplication().getController('PivotTable').createToolbarPanel(); $panel = me.getApplication().getController('PivotTable').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', true);
}
} }
}
var tab = {action: 'review', caption: me.toolbar.textTabCollaboration}; var tab = {action: 'review', caption: me.toolbar.textTabCollaboration};
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);
if (!(config.customization && config.customization.compactHeader)) { if (!(config.customization && config.customization.compactHeader)) {
// hide 'print' and 'save' buttons group and next separator // hide 'print' and 'save' buttons group and next separator
me.toolbar.btnPrint.$el.parents('.group').hide().next().hide(); me.toolbar.btnPrint.$el.parents('.group').hide().next().hide();
// hide 'undo' and 'redo' buttons and get container // hide 'undo' and 'redo' buttons and get container
var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent(); var $box = me.toolbar.btnUndo.$el.hide().next().hide().parent();
// move 'paste' button to the container instead of 'undo' and 'redo' // move 'paste' button to the container instead of 'undo' and 'redo'
me.toolbar.btnPaste.$el.detach().appendTo($box); me.toolbar.btnPaste.$el.detach().appendTo($box);
me.toolbar.btnCopy.$el.removeClass('split'); me.toolbar.btnCopy.$el.removeClass('split');
} }
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};
$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, 7); me.toolbar.addTab(tab, $panel, 7);
}
} }
} }
} }
}); }
}, 0); }, 0);
}, },