From a4965064eb6253a9c530cfafeeba3cdc3dedd4f6 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 17 Sep 2020 16:29:48 +0300 Subject: [PATCH] [SSE] Fix styles updating --- .../main/app/controller/PivotTable.js | 17 ++++++++++++++--- .../main/app/controller/Toolbar.js | 12 +++++++++++- apps/spreadsheeteditor/main/app/view/Toolbar.js | 7 +++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/PivotTable.js b/apps/spreadsheeteditor/main/app/controller/PivotTable.js index 305633f8f..f826afaea 100644 --- a/apps/spreadsheeteditor/main/app/controller/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/controller/PivotTable.js @@ -65,7 +65,8 @@ define([ 'pivottable:layout': _.bind(this.onPivotLayout, this), 'pivottable:blankrows': _.bind(this.onPivotBlankRows, this), 'pivottable:subtotals': _.bind(this.onPivotSubtotals, this), - 'pivottable:grandtotals': _.bind(this.onPivotGrandTotals, this) + 'pivottable:grandtotals': _.bind(this.onPivotGrandTotals, this), + 'pivot:open': _.bind(this.onPivotOpen, this) }, 'TableSettings': { 'pivottable:create': _.bind(this.onCreateClick, this) @@ -332,9 +333,9 @@ define([ if (this._isTemplatesChanged) { if (rec) - view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.getSelectedRec(),true, true); + view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.getSelectedRec(),true); else - view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.store.at(0), true, true); + view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.store.at(0), true); } this._state.TemplateName=value; } @@ -363,6 +364,7 @@ define([ data[index].model.set('imageUrl', img, {silent: true}); $(data[index].el).find('img').attr('src', img); }); + styles.fieldPicker.store.reset(styles.fieldPicker.store.models); } else { styles.menuPicker.store.reset([]); var arr = []; @@ -382,6 +384,15 @@ define([ } }, + onPivotOpen: function() { + var styles = this.view.pivotStyles; + if (styles && styles.needFillComboView && styles.menuPicker.store.length > 0 && styles.rendered){ + var styleRec; + if (this._state.TemplateName) styleRec = styles.menuPicker.store.findWhere({name: this._state.TemplateName}); + styles.fillComboView((styleRec) ? styleRec : styles.menuPicker.store.at(0), true); + } + }, + onSelectionChanged: function(info) { if (this.rangeSelectionMode || !this.appConfig.isEdit || !this.view) return; diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 4616f9aa6..fb7cd548b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -80,7 +80,8 @@ define([ 'add:chart' : this.onSelectChart, 'insert:textart': this.onInsertTextart, 'change:scalespn': this.onClickChangeScaleInMenu.bind(me), - 'click:customscale': this.onScaleClick.bind(me) + 'click:customscale': this.onScaleClick.bind(me), + 'home:open' : this.onHomeOpen }, 'FileMenu': { 'menu:hide': me.onFileMenu.bind(me, 'hide'), @@ -1773,6 +1774,15 @@ define([ window.styles_loaded = true; }, + onHomeOpen: function() { + var listStyles = this.toolbar.listStyles; + if (listStyles && listStyles.needFillComboView && listStyles.menuPicker.store.length > 0 && listStyles.rendered){ + var styleRec; + if (this._state.prstyle) styleRec = listStyles.menuPicker.store.findWhere({name: this._state.prstyle}); + listStyles.fillComboView((styleRec) ? styleRec : listStyles.menuPicker.store.at(0), true); + } + }, + onApiCoAuthoringDisconnect: function(enableDownload) { this.toolbar.setMode({isDisconnected:true, enableDownload: !!enableDownload}); this.editMode = false; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 1103b9769..116e20b68 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1553,6 +1553,13 @@ define([ me.fireEvent('file:open'); me.setTab(tab); } + if ( me.isTabActive('home')) + me.fireEvent('home:open'); + + if ( me.isTabActive('pivot')) { + var pivottab = SSE.getController('PivotTable'); + pivottab && pivottab.getView('PivotTable').fireEvent('pivot:open'); + } }, rendererComponents: function(html) {