From 68d2d406e03c706f92de3650ab61568e05841adb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 31 May 2019 17:48:14 +0300 Subject: [PATCH] [SSE] Data tab: add sort down button --- .../main/app/controller/Toolbar.js | 19 +++++--- .../main/app/template/Toolbar.template | 10 ++++- .../main/app/view/DataTab.js | 43 ++++++++++++++++++- .../main/app/view/Toolbar.js | 7 --- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index dd95cfaff..928499b3a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -118,6 +118,9 @@ define([ 'go:editor': function() { Common.Gateway.requestEditRights(); } + }, + 'DataTab': { + 'data:sort': this.onSortType } }); Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this)); @@ -312,7 +315,6 @@ define([ toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this)); toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this)); toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this)); - toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending)); 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)); @@ -2192,7 +2194,7 @@ define([ } need_disable = this._state.controlsdisabled.filters || (val===null); toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, - { array: [toolbar.btnSortDown, toolbar.btnSortUp, toolbar.btnTableTemplate,toolbar.btnSetAutofilter] }); + { array: [toolbar.btnSortUp, toolbar.btnTableTemplate,toolbar.btnSetAutofilter].concat(toolbar.btnsSortDown) }); val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null; if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) { @@ -2222,11 +2224,11 @@ define([ toolbar.lockToolbar(SSE.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate, toolbar.btnInsertHyperlink]}); this._state.inpivot = !!info.asc_getPivotTableInfo(); - toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnSetAutofilter, toolbar.btnClearAutofilter, toolbar.btnSortDown, toolbar.btnSortUp]}); + toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnSetAutofilter, toolbar.btnClearAutofilter, toolbar.btnSortUp].concat(toolbar.btnsSortDown)}); need_disable = !this.appConfig.canModifyFilter; - toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnSortDown, toolbar.btnSortUp, toolbar.btnSetAutofilter, - toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ]}); + toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnSortUp, toolbar.btnSetAutofilter, + toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ].concat(toolbar.btnsSortDown)}); } @@ -2422,7 +2424,7 @@ define([ need_disable = this._state.controlsdisabled.filters || (val===null); me.toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, - { array: [me.toolbar.btnSortDown, me.toolbar.btnSortUp, me.toolbar.btnSetAutofilter] }); + { array: [me.toolbar.btnSortUp, me.toolbar.btnSetAutofilter].concat(me.toolbar.btnsSortDown) }); need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); me.toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array:[me.toolbar.btnClearAutofilter]}); @@ -3094,7 +3096,10 @@ define([ if ( !config.isEditDiagram && !config.isEditMailMerge ) { var datatab = me.getApplication().getController('DataTab'); datatab.setApi(me.api).setConfig({toolbar: me}); - Array.prototype.push.apply(me.toolbar.lockControls, datatab.getView('DataTab').getButtons()); + + datatab = datatab.getView('DataTab'); + Array.prototype.push.apply(me.toolbar.lockControls, datatab.getButtons()); + me.toolbar.btnsSortDown = datatab.getButtons('sort-down'); if ( !config.isOffline ) { tab = {action: 'pivot', caption: me.textPivot}; diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index b74d5f2ef..e1321a1fe 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -76,7 +76,7 @@
- +
@@ -153,6 +153,14 @@
+
+
+ +
+
+
+
+
diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index 5a4db0dfa..457d55ef1 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -66,6 +66,11 @@ define([ me.btnHide.on('click', function (b, e) { me.fireEvent('data:hide'); }); + me.btnsSortDown.forEach(function(button) { + button.on('click', function (b, e) { + me.fireEvent('data:sort', [Asc.c_oAscSortOptions.Ascending]); + }); + }); } return { @@ -76,6 +81,7 @@ define([ this.toolbar = options.toolbar; this.lockedControls = []; + this.btnsSortDown = []; var me = this, $host = me.toolbar.$el, @@ -87,6 +93,27 @@ define([ cmp.rendered ? $slot.append(cmp.$el) : cmp.render($slot); }; + var _injectComponents = function ($slots, iconCls, split, menu, caption, lock, btnsArr) { + $slots.each(function(index, el) { + var _cls = 'btn-toolbar'; + /x-huge/.test(el.className) && (_cls += ' x-huge icon-top'); + + var button = new Common.UI.Button({ + id: "id-toolbar-" + iconCls + index, + cls: _cls, + iconCls: iconCls, + caption: caption, + split: split, + menu: menu, + lock: lock, + disabled: true + }).render( $slots.eq(index) ); + + btnsArr.push(button); + me.lockedControls.push(button); + }); + }; + this.btnGroup = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconCls: 'btn-img-group', @@ -141,6 +168,10 @@ define([ _injectComponent('#slot-btn-hide-details', this.btnHide); this.lockedControls.push(this.btnHide); + _injectComponents($host.find('.slot-sortdesc'), 'btn-sort-down', false, false, '', + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot], + this.btnsSortDown); + Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, @@ -166,6 +197,10 @@ define([ me.btnGroup.updateHint(me.tipGroup); me.btnTextToColumns.updateHint(me.tipToColumns); + me.btnsSortDown.forEach( function(btn) { + btn.updateHint(me.toolbar.txtSortAZ); + }); + setEvents.call(me); }); }, @@ -175,8 +210,12 @@ define([ this.fireEvent('show', this); }, - getButtons: function() { - return this.lockedControls; + getButtons: function(type) { + if (type == 'sort-down') + return this.btnsSortDown; + else if (type===undefined) + return this.lockedControls; + return []; }, SetDisabled: function (state) { diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 8ff39b3eb..4373af627 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -716,13 +716,6 @@ define([ menu : new Common.UI.Menu({cls: 'menu-shapes'}) }); - me.btnSortDown = new Common.UI.Button({ - id : 'id-toolbar-btn-sort-down', - cls : 'btn-toolbar', - iconCls : 'btn-sort-down', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter] - }); - me.btnSortUp = new Common.UI.Button({ id : 'id-toolbar-btn-sort-up', cls : 'btn-toolbar',