From 2493571d170e17a95c3c100da35db64e708d5331 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 23 Sep 2020 21:15:45 +0300 Subject: [PATCH] [SSE] Add pivot table button to the Insert tab. --- .../main/app/controller/Main.js | 2 +- .../main/app/controller/PivotTable.js | 13 +++---- .../main/app/controller/Toolbar.js | 1 + .../main/app/template/Toolbar.template | 1 + .../main/app/view/PivotTable.js | 37 ++++++++++--------- apps/spreadsheeteditor/main/locale/en.json | 1 + 6 files changed, 30 insertions(+), 25 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 4719a941f6..e1756ab83a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1149,7 +1149,7 @@ define([ } if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && me.appOptions.canFeaturePivot) - application.getController('PivotTable').setMode(me.appOptions).setConfig({config: me.editorConfig}, me.api); + application.getController('PivotTable').setMode(me.appOptions); var viewport = this.getApplication().getController('Viewport').getView('Viewport'); viewport.applyEditorMode(); diff --git a/apps/spreadsheeteditor/main/app/controller/PivotTable.js b/apps/spreadsheeteditor/main/app/controller/PivotTable.js index f826afaea4..3b1cba8762 100644 --- a/apps/spreadsheeteditor/main/app/controller/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/controller/PivotTable.js @@ -89,12 +89,10 @@ define([ Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); }, - setConfig: function (data, api) { - this.view = this.createView('PivotTable'); - this.setApi(api); - if (data) { - this.sdkViewName = data['sdkviewname'] || this.sdkViewName; - } + setConfig: function (config) { + this.view = this.createView('PivotTable', { + toolbar: config.toolbar.toolbar + }); }, setApi: function (api) { @@ -106,6 +104,7 @@ define([ this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this)); } + return this; }, setMode: function(mode) { @@ -400,7 +399,7 @@ define([ Common.Utils.lockControls(SSE.enumLock.noPivot, !pivotInfo, {array: this.view.lockedControls}); Common.Utils.lockControls(SSE.enumLock.pivotLock, pivotInfo && (info.asc_getLockedPivotTable()===true), {array: this.view.lockedControls}); - Common.Utils.lockControls(SSE.enumLock.editPivot, !!pivotInfo, {array: [this.view.btnAddPivot]}); + Common.Utils.lockControls(SSE.enumLock.editPivot, !!pivotInfo, {array: this.view.btnsAddPivot}); if (pivotInfo) this.ChangeSettings(pivotInfo); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index d0b765740c..19ef0d6374 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -3314,6 +3314,7 @@ define([ if ( config.canFeaturePivot ) { tab = {action: 'pivot', caption: me.textPivot}; var pivottab = me.getApplication().getController('PivotTable'); + pivottab.setApi(me.api).setConfig({toolbar: me}); $panel = pivottab.createToolbarPanel(); if ($panel) { me.toolbar.addTab(tab, $panel, 5); diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index cb7050e5f0..1055f6815d 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -120,6 +120,7 @@
+
diff --git a/apps/spreadsheeteditor/main/app/view/PivotTable.js b/apps/spreadsheeteditor/main/app/view/PivotTable.js index b274d5da8f..0598af43ea 100644 --- a/apps/spreadsheeteditor/main/app/view/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/view/PivotTable.js @@ -53,7 +53,7 @@ define([ var template = '
' + '
' + - '' + + '' + '
' + '
' + '
' + @@ -94,8 +94,10 @@ define([ function setEvents() { var me = this; - this.btnAddPivot.on('click', function (e) { - me.fireEvent('pivottable:create'); + this.btnsAddPivot.forEach(function(button) { + button.on('click', function (b, e) { + me.fireEvent('pivottable:create'); + }); }); this.btnPivotLayout.menu.on('item:click', function (menu, item, e) { @@ -149,11 +151,14 @@ define([ initialize: function (options) { Common.UI.BaseView.prototype.initialize.call(this, options); - this.appConfig = options.mode; + this.toolbar = options.toolbar; this.lockedControls = []; var _set = SSE.enumLock; + this.btnsAddPivot = Common.Utils.injectButtons(this.toolbar.$el.find('.btn-slot.slot-add-pivot'), '', 'toolbar__icon btn-pivot-sum', this.txtPivotTable, + [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell]); + this.chRowHeader = new Common.UI.CheckBox({ labelText: this.textRowHeader, lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock] @@ -178,14 +183,6 @@ define([ }); this.lockedControls.push(this.chColBanded); - this.btnAddPivot = new Common.UI.Button({ - cls: 'btn-toolbar x-huge icon-top', - iconCls: 'toolbar__icon btn-pivot-sum', - caption: this.txtCreate, - disabled : false, - lock : [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell] - }); - this.btnPivotLayout = new Common.UI.Button({ cls : 'btn-toolbar x-huge icon-top', iconCls : 'toolbar__icon btn-pivot-layout', @@ -276,7 +273,9 @@ define([ (new Promise(function (accept, reject) { accept(); })).then(function(){ - me.btnAddPivot.updateHint(me.tipCreatePivot); + me.btnsAddPivot.forEach( function(btn) { + btn.updateHint(me.tipCreatePivot); + }); me.btnRefreshPivot.updateHint(me.tipRefresh); me.btnSelectPivot.updateHint(me.tipSelect); me.btnPivotLayout.updateHint(me.capLayout); @@ -325,12 +324,15 @@ define([ getPanel: function () { this.$el = $(_.template(template)( {} )); + var _set = SSE.enumLock; + this.btnsAddPivot = this.btnsAddPivot.concat(Common.Utils.injectButtons(this.$el.find('.btn-slot.slot-add-pivot'), '', 'toolbar__icon btn-pivot-sum', this.txtCreate, + [_set.lostConnect, _set.coAuth, _set.editPivot, _set.selRangeEdit, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.editCell])); + this.chRowHeader.render(this.$el.find('#slot-chk-header-row')); this.chColHeader.render(this.$el.find('#slot-chk-header-column')); this.chRowBanded.render(this.$el.find('#slot-chk-banded-row')); this.chColBanded.render(this.$el.find('#slot-chk-banded-column')); - this.btnAddPivot.render(this.$el.find('#slot-btn-add-pivot')); this.btnRefreshPivot.render(this.$el.find('#slot-btn-refresh-pivot')); this.btnSelectPivot.render(this.$el.find('#slot-btn-select-pivot')); this.btnPivotLayout.render(this.$el.find('#slot-btn-pivot-report-layout')); @@ -352,11 +354,11 @@ define([ }, getButtons: function(type) { - return this.lockedControls.concat(this.btnAddPivot); + return this.btnsAddPivot.concat(this.lockedControls); }, SetDisabled: function (state) { - this.lockedControls.concat(this.btnAddPivot).forEach(function(button) { + this.btnsAddPivot.concat(this.lockedControls).forEach(function(button) { if ( button ) { button.setDisabled(state); } @@ -392,7 +394,8 @@ define([ tipGrandTotals: 'Show or hide grand totals', tipSubtotals: 'Show or hide subtotals', txtSelect: 'Select', - tipSelect: 'Select entire pivot table' + tipSelect: 'Select entire pivot table', + txtPivotTable: 'Pivot Table' } }()), SSE.Views.PivotTable || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index b87701625e..cb50918148 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2183,6 +2183,7 @@ "SSE.Views.PivotTable.txtCreate": "Insert Table", "SSE.Views.PivotTable.txtRefresh": "Refresh", "SSE.Views.PivotTable.txtSelect": "Select", + "SSE.Views.PivotTable.txtPivotTable": "Pivot Table", "SSE.Views.PrintSettings.btnDownload": "Save & Download", "SSE.Views.PrintSettings.btnPrint": "Save & Print", "SSE.Views.PrintSettings.strBottom": "Bottom",