diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index cbd2db149..181b10e8b 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -120,7 +120,9 @@ define([ } }, 'DataTab': { - 'data:sort': this.onSortType + 'data:sort': this.onSortType, + 'data:setfilter': this.onAutoFilter, + 'data:clearfilter': this.onClearFilter } }); Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this)); @@ -315,8 +317,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.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); - toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); toolbar.btnTableTemplate.menu.on('show:after', _.bind(this.onTableTplMenuOpen, this)); toolbar.btnPercentStyle.on('click', _.bind(this.onNumberFormat, this)); toolbar.btnCurrencyStyle.on('click', _.bind(this.onNumberFormat, this)); @@ -2188,12 +2188,14 @@ define([ val = (filterInfo) ? filterInfo.asc_getIsAutoFilter() : null; if (this._state.filter !== val) { - toolbar.btnSetAutofilter.toggle(val===true, true); + toolbar.btnsSetAutofilter.forEach(function(button) { + button.toggle(val===true, true); + }); this._state.filter = val; } need_disable = this._state.controlsdisabled.filters || (val===null); toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, - { array: [toolbar.btnTableTemplate,toolbar.btnSetAutofilter].concat(toolbar.btnsSortDown).concat(toolbar.btnsSortUp) }); + { array: [toolbar.btnTableTemplate].concat(toolbar.btnsSetAutofilter).concat(toolbar.btnsSortDown).concat(toolbar.btnsSortUp) }); val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null; if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) { @@ -2208,7 +2210,7 @@ define([ } need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); - toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array:[toolbar.btnClearAutofilter]}); + toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array: toolbar.btnsClearAutofilter}); var old_name = this._state.tablename; this._state.tablename = (formatTableInfo) ? formatTableInfo.asc_getTableName() : undefined; @@ -2223,11 +2225,10 @@ 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].concat(toolbar.btnsSortDown).concat(toolbar.btnsSortUp)}); + toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge, toolbar.btnInsertHyperlink].concat(toolbar.btnsSetAutofilter).concat(toolbar.btnsClearAutofilter).concat(toolbar.btnsSortDown).concat(toolbar.btnsSortUp)}); need_disable = !this.appConfig.canModifyFilter; - toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnSetAutofilter, - toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ].concat(toolbar.btnsSortDown).concat(toolbar.btnsSortUp)}); + toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ].concat(toolbar.btnsSetAutofilter).concat(toolbar.btnsSortDown).concat(toolbar.btnsSortUp)}); } @@ -2423,10 +2424,10 @@ define([ need_disable = this._state.controlsdisabled.filters || (val===null); me.toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, - { array: [me.toolbar.btnSetAutofilter].concat(me.toolbar.btnsSortDown).concat(me.toolbar.btnsSortUp) }); + { array: [me.toolbar.btnSetAutofilter, me.toolbar.btnSortDown, me.toolbar.btnSortUp] }); need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); - me.toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array:[me.toolbar.btnClearAutofilter]}); + me.toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array: [me.toolbar.btnClearAutofilter]}); } }, @@ -3100,6 +3101,8 @@ define([ Array.prototype.push.apply(me.toolbar.lockControls, datatab.getButtons()); me.toolbar.btnsSortDown = datatab.getButtons('sort-down'); me.toolbar.btnsSortUp = datatab.getButtons('sort-up'); + me.toolbar.btnsSetAutofilter = datatab.getButtons('set-filter'); + me.toolbar.btnsClearAutofilter = datatab.getButtons('clear-filter'); 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 bf1fd43a9..082e2ad96 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -80,8 +80,8 @@
- - + +
@@ -159,6 +159,8 @@
+ +
diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index a6f2506ab..d9800f065 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -76,6 +76,16 @@ define([ me.fireEvent('data:sort', [Asc.c_oAscSortOptions.Descending]); }); }); + me.btnsSetAutofilter.forEach(function(button) { + button.on('click', function (b, e) { + me.fireEvent('data:setfilter', [Asc.c_oAscSortOptions.Descending]); + }); + }); + me.btnsClearAutofilter.forEach(function(button) { + button.on('click', function (b, e) { + me.fireEvent('data:clearfilter', [Asc.c_oAscSortOptions.Descending]); + }); + }); } return { @@ -88,6 +98,8 @@ define([ this.lockedControls = []; this.btnsSortDown = []; this.btnsSortUp = []; + this.btnsSetAutofilter = []; + this.btnsClearAutofilter = []; var me = this, $host = me.toolbar.$el, @@ -99,7 +111,7 @@ define([ cmp.rendered ? $slot.append(cmp.$el) : cmp.render($slot); }; - var _injectComponents = function ($slots, iconCls, split, menu, caption, lock, btnsArr) { + var _injectComponents = function ($slots, iconCls, split, menu, caption, toggle, lock, btnsArr) { $slots.each(function(index, el) { var _cls = 'btn-toolbar'; /x-huge/.test(el.className) && (_cls += ' x-huge icon-top'); @@ -174,14 +186,22 @@ define([ _injectComponent('#slot-btn-hide-details', this.btnHide); this.lockedControls.push(this.btnHide); - _injectComponents($host.find('.slot-sortdesc'), 'btn-sort-down', false, false, '', + _injectComponents($host.find('.slot-sortdesc'), 'btn-sort-down', false, false, '', false, [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter], this.btnsSortDown); - _injectComponents($host.find('.slot-sortasc'), 'btn-sort-up', false, false, '', + _injectComponents($host.find('.slot-sortasc'), 'btn-sort-up', false, false, '', false, [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter], this.btnsSortUp); + _injectComponents($host.find('.slot-btn-setfilter'), 'btn-autofilter', false, false, '', true, + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter], + this.btnsSetAutofilter); + + _injectComponents($host.find('.slot-btn-clear-filter'), 'btn-clear-filter', false, false, '', false, + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot], + this.btnsClearAutofilter); + Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, @@ -213,6 +233,12 @@ define([ me.btnsSortUp.forEach( function(btn) { btn.updateHint(me.toolbar.txtSortZA); }); + me.btnsSetAutofilter.forEach( function(btn) { + btn.updateHint(me.toolbar.txtFilter + ' (Ctrl+Shift+L)'); + }); + me.btnsClearAutofilter.forEach( function(btn) { + btn.updateHint(me.toolbar.txtClearFilter); + }); setEvents.call(me); }); @@ -228,6 +254,10 @@ define([ return this.btnsSortDown; else if (type == 'sort-up') return this.btnsSortUp; + else if (type == 'set-filter') + return this.btnsSetAutofilter; + else if (type == 'clear-filter') + return this.btnsClearAutofilter; else if (type===undefined) return this.lockedControls; return []; diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 4a6b04655..78abe74c5 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -716,21 +716,6 @@ define([ menu : new Common.UI.Menu({cls: 'menu-shapes'}) }); - me.btnSetAutofilter = new Common.UI.Button({ - id : 'id-toolbar-btn-setautofilter', - cls : 'btn-toolbar', - iconCls : 'btn-autofilter', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter], - enableToggle: true - }); - - me.btnClearAutofilter = new Common.UI.Button({ - id : 'id-toolbar-btn-clearfilter', - cls : 'btn-toolbar', - iconCls : 'btn-clear-filter', - lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleDelFilter, _set.editPivot] - }); - me.btnTableTemplate = new Common.UI.Button({ id : 'id-toolbar-btn-ttempl', cls : 'btn-toolbar',