From fc47f0f16794caf3b1d1dc8cd372d7216067b5df Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 16 Mar 2022 14:17:25 +0300 Subject: [PATCH] [SSE] Refactoring ole editor: add toolbar buttons --- .../common/main/lib/controller/HintManager.js | 2 +- .../main/app/controller/Main.js | 4 +- .../main/app/controller/Toolbar.js | 37 ++- .../main/app/template/ToolbarAnother.template | 14 + .../main/app/view/Statusbar.js | 8 +- .../main/app/view/Toolbar.js | 285 +++++++++--------- 6 files changed, 205 insertions(+), 145 deletions(-) diff --git a/apps/common/main/lib/controller/HintManager.js b/apps/common/main/lib/controller/HintManager.js index abbb3b897..9f135fda1 100644 --- a/apps/common/main/lib/controller/HintManager.js +++ b/apps/common/main/lib/controller/HintManager.js @@ -647,7 +647,7 @@ Common.UI.HintManager = new(function() { }; var _setMode = function (mode) { - _isEditDiagram = mode.isEditDiagram; + _isEditDiagram = mode.isEditDiagram || mode.isEditMailMerge || mode.isEditOle; }; return { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9e6f9796e..51f811314 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -468,7 +468,7 @@ define([ this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); Common.Controllers.Desktop.init(this.appOptions); - if (this.appOptions.isEditDiagram) { + if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle) { Common.UI.HintManager.setMode(this.appOptions); } }, @@ -1437,7 +1437,7 @@ define([ application.getController('WBProtection').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); if (statusbarController) { - statusbarController.getView('Statusbar').changeViewMode(!me.appOptions.isEditOle); + statusbarController.getView('Statusbar').changeViewMode(me.appOptions); me.appOptions.isEditOle && statusbarController.onChangeViewMode(null, true, true); // set compact status bar for ole editing mode } diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 5f5d2adde..e060c6f5f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -312,6 +312,14 @@ define([ toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending)); toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); + toolbar.btnInsertFormula.on('click', _.bind(this.onInsertFormulaMenu, this)); + toolbar.btnInsertFormula.menu.on('item:click', _.bind(this.onInsertFormulaMenu, this)); + toolbar.btnDecDecimal.on('click', _.bind(this.onDecrement, this)); + toolbar.btnIncDecimal.on('click', _.bind(this.onIncrement, this)); + toolbar.cmbNumberFormat.on('selected', _.bind(this.onNumberFormatSelect, this)); + toolbar.cmbNumberFormat.on('show:before', _.bind(this.onNumberFormatOpenBefore, this, true)); + if (toolbar.cmbNumberFormat.cmpEl) + toolbar.cmbNumberFormat.cmpEl.on('click', '#id-toolbar-mnu-item-more-formats a', _.bind(this.onNumberFormatSelect, this)); } else { toolbar.btnPrint.on('click', _.bind(this.onPrint, this)); toolbar.btnPrint.on('disabled', _.bind(this.onBtnChangeState, this, 'print:disabled')); @@ -3105,12 +3113,28 @@ define([ }); } + var _set = Common.enumLock; + var type = seltype; + switch ( seltype ) { + case Asc.c_oAscSelectionType.RangeSlicer: + case Asc.c_oAscSelectionType.RangeImage: type = _set.selImage; break; + case Asc.c_oAscSelectionType.RangeShape: type = _set.selShape; break; + case Asc.c_oAscSelectionType.RangeShapeText: type = _set.selShapeText; break; + case Asc.c_oAscSelectionType.RangeChart: type = _set.selChart; break; + case Asc.c_oAscSelectionType.RangeChartText: type = _set.selChartText; break; + } + + me.toolbar.lockToolbar(type, type != seltype, { + clear: [_set.selImage, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.coAuth] + }); + me.toolbar.lockToolbar(Common.enumLock.coAuthText, is_objLocked); return is_image; }; var selectionType = info.asc_getSelectionType(), + xfs = info.asc_getXfs(), coauth_disable = false, editOptionsDisabled = _disableEditOptions(selectionType, coauth_disable), val, need_disable = false; @@ -3135,6 +3159,17 @@ define([ need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); me.toolbar.lockToolbar(Common.enumLock.ruleDelFilter, need_disable, {array: [me.toolbar.btnClearAutofilter]}); } + + var val = xfs.asc_getNumFormatInfo(); + if ( val ) { + this._state.numformat = xfs.asc_getNumFormat(); + this._state.numformatinfo = val; + val = val.asc_getType(); + if (this._state.numformattype !== val) { + me.toolbar.cmbNumberFormat.setValue(val, me.toolbar.txtCustom); + this._state.numformattype = val; + } + } }, onApiStyleChange: function() { @@ -3793,7 +3828,7 @@ define([ var me = this; me.appConfig = config; - var compactview = !config.isEdit || config.isEditOle; + var compactview = !config.isEdit; if ( config.isEdit && !config.isEditDiagram && !config.isEditMailMerge && !config.isEditOle ) { if ( Common.localStorage.itemExists("sse-compact-toolbar") ) { compactview = Common.localStorage.getBool("sse-compact-toolbar"); diff --git a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template index 79bc438f3..878aa4f2f 100644 --- a/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template +++ b/apps/spreadsheeteditor/main/app/template/ToolbarAnother.template @@ -85,6 +85,12 @@
+
+
+ +
+
+
@@ -99,6 +105,14 @@
+
+
+ + + +
+
+
diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 6fd07ea32..8b318ccdb 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -516,7 +516,8 @@ define([ this.mode = _.extend({}, this.mode, mode); // this.$el.find('.el-edit')[mode.isEdit?'show':'hide'](); //this.btnAddWorksheet.setVisible(this.mode.isEdit); - $('#status-addtabs-box')[(this.mode.isEdit && !this.mode.isEditOle ) ? 'show' : 'hide'](); + $('#status-addtabs-box')[(this.mode.isEdit) ? 'show' : 'hide'](); + this.btnAddWorksheet.setVisible(!this.mode.isEditOle); this.btnAddWorksheet.setDisabled(this.mode.isDisconnected || this.api && (this.api.asc_isWorkbookLocked() || this.api.isCellEdited) || this.rangeSelectionMode!=Asc.c_oAscSelectionDialogType.None); this.updateTabbarBorders(); }, @@ -890,11 +891,12 @@ define([ } }, - changeViewMode: function (edit) { + changeViewMode: function (mode) { + var edit = mode.isEdit && !mode.isEditOle; if (edit) { this.tabBarBox.css('left', '175px'); } else { - this.tabBarBox.css('left', ''); + this.tabBarBox.css('left', mode.isEditOle ? '152px' : ''); } this.tabbar.options.draggable = edit; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index ccac769ae..0572660fd 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -197,7 +197,7 @@ define([ cls : 'btn-toolbar', iconCls : 'toolbar__icon btn-copy', dataHint: '1', - dataHintDirection: config.isEditDiagram ? 'bottom' : 'top', + dataHintDirection: (config.isEditDiagram || config.isEditMailMerge || config.isEditOle) ? 'bottom' : 'top', dataHintTitle: 'C' }); @@ -207,7 +207,7 @@ define([ iconCls : 'toolbar__icon btn-paste', lock : [/*_set.editCell,*/ _set.coAuth, _set.lostConnect], dataHint : '1', - dataHintDirection: config.isEditDiagram ? 'bottom' : 'top', + dataHintDirection: (config.isEditDiagram || config.isEditMailMerge || config.isEditOle) ? 'bottom' : 'top', dataHintTitle: 'V' }); @@ -235,153 +235,162 @@ define([ dataHintTitle: 'Y' }); - if ( config.isEditDiagram ) { + if (config.isEditDiagram || config.isEditMailMerge || config.isEditOle ) { me.$layout = $(_.template(simple)(config)); + if ( config.isEditDiagram || config.isEditOle ) { + me.btnInsertFormula = new Common.UI.Button({ + id : 'id-toolbar-btn-insertformula', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-formula', + split : true, + lock : [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], + menu : new Common.UI.Menu({ + style : 'min-width: 110px', + items : [ + {caption: 'SUM', value: 'SUM'}, + {caption: 'AVERAGE', value: 'AVERAGE'}, + {caption: 'MIN', value: 'MIN'}, + {caption: 'MAX', value: 'MAX'}, + {caption: 'COUNT', value: 'COUNT'}, + {caption: '--'}, + { + caption: me.txtAdditional, + value: 'more', + hint: me.txtFormula + Common.Utils.String.platformKey('Shift+F3') + } + ] + }), + dataHint: '1', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); - me.btnInsertFormula = new Common.UI.Button({ - id : 'id-toolbar-btn-insertformula', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-formula', - split : true, - lock : [_set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], - menu : new Common.UI.Menu({ - style : 'min-width: 110px', - items : [ - {caption: 'SUM', value: 'SUM'}, - {caption: 'AVERAGE', value: 'AVERAGE'}, - {caption: 'MIN', value: 'MIN'}, - {caption: 'MAX', value: 'MAX'}, - {caption: 'COUNT', value: 'COUNT'}, - {caption: '--'}, - { - caption: me.txtAdditional, - value: 'more', - hint: me.txtFormula + Common.Utils.String.platformKey('Shift+F3') - } - ] - }), - dataHint: '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' - }); + me.btnDecDecimal = new Common.UI.Button({ + id : 'id-toolbar-btn-decdecimal', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-decdecimal', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnDecDecimal = new Common.UI.Button({ - id : 'id-toolbar-btn-decdecimal', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-decdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], - dataHint : '1', - dataHintDirection: 'bottom' - }); + me.btnIncDecimal = new Common.UI.Button({ + id : 'id-toolbar-btn-incdecimal', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-incdecimal', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnIncDecimal = new Common.UI.Button({ - id : 'id-toolbar-btn-incdecimal', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-incdecimal', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth], - dataHint : '1', - dataHintDirection: 'bottom' - }); + var formatTemplate = + _.template([ + '<% _.each(items, function(item) { %>', + '
  • ', + '
    <%= scope.getDisplayValue(item) %>
    ', + '
    <%= item.exampleval ? item.exampleval : "" %>
    ', + '
  • ', + '<% }); %>', + '
  • ', + '
  • ' + me.textMoreFormats + '
  • ' + ].join('')); - var formatTemplate = - _.template([ - '<% _.each(items, function(item) { %>', - '
  • ', - '
    <%= scope.getDisplayValue(item) %>
    ', - '
    <%= item.exampleval ? item.exampleval : "" %>
    ', - '
  • ', - '<% }); %>', - '
  • ', - '
  • ' + me.textMoreFormats + '
  • ' - ].join('')); + me.cmbNumberFormat = new Common.UI.ComboBox({ + cls : 'input-group-nr', + menuStyle : 'min-width: 180px;', + hint : me.tipNumFormat, + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], + itemsTemplate: formatTemplate, + editable : false, + data : me.numFormatData, + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); + } + if ( config.isEditDiagram ) { + me.btnEditChart = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart', + cls : 'btn-toolbar btn-text-default auto', + caption : me.tipEditChart, + lock : [_set.lostConnect], + style : 'min-width: 120px;', + dataHint : '1', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); - me.cmbNumberFormat = new Common.UI.ComboBox({ - cls : 'input-group-nr', - menuStyle : 'min-width: 180px;', - hint : me.tipNumFormat, - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selRangeEdit, _set.lostConnect, _set.coAuth], - itemsTemplate: formatTemplate, - editable : false, - data : me.numFormatData, - dataHint : '1', - dataHintDirection: config.isEditDiagram ? 'bottom' : 'top', - dataHintOffset: config.isEditDiagram ? 'big' : undefined - }); + me.btnEditChartData = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart-data', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-select-range', + caption : me.tipEditChartData, + lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'medium' + }); - me.btnEditChart = new Common.UI.Button({ - id : 'id-toolbar-rtn-edit-chart', - cls : 'btn-toolbar btn-text-default auto', - caption : me.tipEditChart, - lock : [_set.lostConnect], - style : 'min-width: 120px;', - dataHint : '1', - dataHintDirection: 'bottom', - dataHintOffset: 'big' - }); + me.btnEditChartType = new Common.UI.Button({ + id : 'id-toolbar-rtn-edit-chart-type', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-menu-chart', + caption : me.tipEditChartType, + lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], + style : 'min-width: 120px;', + dataHint : '1', + dataHintDirection: 'left', + dataHintOffset: 'medium' + }); + } + if ( config.isEditMailMerge || config.isEditOle ) { + me.btnSearch = new Common.UI.Button({ + id : 'id-toolbar-btn-search', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-menu-search', + lock : [_set.lostConnect], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnEditChartData = new Common.UI.Button({ - id : 'id-toolbar-rtn-edit-chart-data', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-select-range', - caption : me.tipEditChartData, - lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], - dataHint : '1', - dataHintDirection: 'left', - dataHintOffset: 'medium' - }); + me.btnSortDown = new Common.UI.Button({ + id : 'id-toolbar-btn-sort-down', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-sort-down', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnEditChartType = new Common.UI.Button({ - id : 'id-toolbar-rtn-edit-chart-type', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-menu-chart', - caption : me.tipEditChartType, - lock : [_set.editCell, _set.selRange, _set.selRangeEdit, _set.lostConnect], - style : 'min-width: 120px;', - dataHint : '1', - dataHintDirection: 'left', - dataHintOffset: 'medium' - }); - } else - if ( config.isEditMailMerge || config.isEditOle ) { - me.$layout = $(_.template(simple)(config)); + me.btnSortUp = new Common.UI.Button({ + id : 'id-toolbar-btn-sort-up', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-sort-up', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnSearch = new Common.UI.Button({ - id : 'id-toolbar-btn-search', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-menu-search', - lock : [_set.lostConnect] - }); + me.btnSetAutofilter = new Common.UI.Button({ + id : 'id-toolbar-btn-setautofilter', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-autofilter', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + enableToggle: true, + dataHint : '1', + dataHintDirection: 'bottom' + }); - me.btnSortDown = new Common.UI.Button({ - id : 'id-toolbar-btn-sort-down', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-sort-down', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot] - }); - - me.btnSortUp = new Common.UI.Button({ - id : 'id-toolbar-btn-sort-up', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-sort-up', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot] - }); - - me.btnSetAutofilter = new Common.UI.Button({ - id : 'id-toolbar-btn-setautofilter', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-autofilter', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], - enableToggle: true - }); - - me.btnClearAutofilter = new Common.UI.Button({ - id : 'id-toolbar-btn-clearfilter', - cls : 'btn-toolbar', - iconCls : 'toolbar__icon btn-clear-filter', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot] - }); - } else - if ( config.isEdit ) { + me.btnClearAutofilter = new Common.UI.Button({ + id : 'id-toolbar-btn-clearfilter', + cls : 'btn-toolbar', + iconCls : 'toolbar__icon btn-clear-filter', + lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot], + dataHint : '1', + dataHintDirection: 'bottom' + }); + } + } else if ( config.isEdit ) { Common.UI.Mixtbar.prototype.initialize.call(this, { template: _.template(template), tabs: [