From 041d617b26b81e2d35a82b935e6de64172f728dc Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 May 2016 11:01:41 +0300 Subject: [PATCH] =?UTF-8?q?[SSE]=20=D0=92=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=D0=BD=D0=BE=D0=B5=20=D0=BC=D0=B5=D0=BD=D1=8E?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D1=8F=D1=87=D0=B5=D0=B5=D0=BA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/app/controller/DocumentHolder.js | 60 ++++++++++++++++--- .../main/app/view/AutoFilterDialog.js | 2 +- .../main/app/view/DocumentHolder.js | 33 +++++++++- 3 files changed, 85 insertions(+), 10 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index e36329f4e..d85eaf49c 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -152,6 +152,8 @@ define([ view.pmiInsertCells.menu.on('item:click', _.bind(me.onInsertCells, me)); view.pmiDeleteCells.menu.on('item:click', _.bind(me.onDeleteCells, me)); view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me)); + view.pmiFilterCells.menu.on('item:click', _.bind(me.onFilterCells, me)); + view.pmiReapply.menu.on('item:click', _.bind(me.onReapply, me)); view.pmiClear.menu.on('item:click', _.bind(me.onClear, me)); view.pmiSelectTable.menu.on('item:click', _.bind(me.onSelectTable, me)); view.pmiInsertTable.menu.on('item:click', _.bind(me.onInsertTable, me)); @@ -343,6 +345,41 @@ define([ } }, + onFilterCells: function(menu, item) { + if (this.api) { + var autoFilterObject = new Asc.AutoFiltersOptions(), + filterObj = new Asc.AutoFilterObj(); + if (item.value>0) { + filterObj.asc_setFilter(new Asc.ColorFilter()); + filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.ColorFilter); + + var colorFilter = filterObj.asc_getFilter(); + colorFilter.asc_setCellColor((item.value==1) ? null : false); + colorFilter.asc_setCColor((item.value==1) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor); + } else { + filterObj.asc_setFilter(new Asc.CustomFilters()); + filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.CustomFilters); + + var customFilter = filterObj.asc_getFilter(); + customFilter.asc_setCustomFilters([new Asc.CustomFilter()]); + customFilter.asc_setAnd(true); + var customFilters = customFilter.asc_getCustomFilters(); + customFilters[0].asc_setOperator(Asc.c_oAscCustomAutoFilter.equals); +// customFilters[0].asc_setVal(''); + } + + autoFilterObject.asc_setFilterObj(filterObj); + this.api.asc_applyAutoFilterByType(autoFilterObject); + + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + Common.component.Analytics.trackEvent('DocumentHolder', 'Filter Cells'); + } + }, + + onReapply: function() { + this.api.asc_applyAutoFilter(new Asc.AutoFiltersOptions()); + }, + onClear: function(menu, item) { if (this.api) { this.api.asc_emptyCells(item.value); @@ -1181,6 +1218,8 @@ define([ formatTableInfo = cellinfo.asc_getFormatTableInfo(), isintable = (formatTableInfo !== null); documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null; + documentHolder.ssMenu.cellColor = cellinfo.asc_getFill().asc_getColor(); + documentHolder.ssMenu.fontColor = cellinfo.asc_getFont().asc_getColor(); documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu); documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft); @@ -1190,7 +1229,10 @@ define([ documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable); documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable); documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable); - documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit && !isintable); + documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit); + documentHolder.pmiFilterCells.setVisible((iscellmenu||cansort) && !iscelledit); + documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit); + documentHolder.ssMenu.items[12].setVisible((iscellmenu||isallmenu||cansort) && !iscelledit); documentHolder.pmiInsFunction.setVisible(iscellmenu||insfunc); documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit); @@ -1218,7 +1260,7 @@ define([ documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes); /** coauthoring begin **/ - documentHolder.ssMenu.items[13].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); + documentHolder.ssMenu.items[16].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); /** coauthoring end **/ documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc); @@ -1236,17 +1278,19 @@ define([ documentHolder.pmiClear.menu.items[3].setVisible(!this.permissions.isEditDiagram); documentHolder.pmiClear.menu.items[4].setVisible(!this.permissions.isEditDiagram); - var filterInfo = cellinfo.asc_getAutoFilterInfo(); - filterInfo = (filterInfo) ? filterInfo.asc_getIsApplyAutoFilter() : false; - documentHolder.pmiInsertCells.menu.items[0].setDisabled(filterInfo); - documentHolder.pmiDeleteCells.menu.items[0].setDisabled(filterInfo); - documentHolder.pmiInsertCells.menu.items[1].setDisabled(filterInfo); - documentHolder.pmiDeleteCells.menu.items[1].setDisabled(filterInfo); + var filterInfo = cellinfo.asc_getAutoFilterInfo(), + isApplyAutoFilter = (filterInfo) ? filterInfo.asc_getIsApplyAutoFilter() : false; + filterInfo = (filterInfo) ? filterInfo.asc_getIsAutoFilter() : null; + documentHolder.pmiInsertCells.menu.items[0].setDisabled(isApplyAutoFilter); + documentHolder.pmiDeleteCells.menu.items[0].setDisabled(isApplyAutoFilter); + documentHolder.pmiInsertCells.menu.items[1].setDisabled(isApplyAutoFilter); + documentHolder.pmiDeleteCells.menu.items[1].setDisabled(isApplyAutoFilter); _.each(documentHolder.ssMenu.items, function(item) { item.setDisabled(isCellLocked); }); documentHolder.pmiCopy.setDisabled(false); + documentHolder.pmiSortCells.setDisabled(isCellLocked || (filterInfo==null)); if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event); } else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) { if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return; diff --git a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js index 24c041b90..1b658c097 100644 --- a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js +++ b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js @@ -677,8 +677,8 @@ define([ this.miTextFilter, this.miFilterCellColor, this.miFilterFontColor, - {caption : '--'}, this.miClear, + {caption : '--'}, this.miReapply ] }); diff --git a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js index 718e0d58a..34b390566 100644 --- a/apps/spreadsheeteditor/main/app/view/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/view/DocumentHolder.js @@ -239,6 +239,29 @@ define([ }) }); + me.pmiFilterCells = new Common.UI.MenuItem({ + caption : me.txtFilter, + menu : new Common.UI.Menu({ + menuAlign : 'tl-tr', + items: [ + { + caption : me.txtFilterValue, + value : 0 + },{ + caption : me.txtFilterCellColor, + value : 1 + },{ + caption : me.txtFilterFontColor, + value : 2 + } + ] + }) + }); + + me.pmiReapply = new Common.UI.MenuItem({ + caption : me.txtReapply + }); + me.pmiInsFunction = new Common.UI.MenuItem({ caption : me.txtFormula }); @@ -319,7 +342,10 @@ define([ me.pmiDeleteCells, me.pmiDeleteTable, me.pmiClear, + {caption: '--'}, me.pmiSortCells, + me.pmiFilterCells, + me.pmiReapply, {caption: '--'}, me.pmiAddComment, me.pmiCellMenuSeparator, @@ -629,7 +655,12 @@ define([ insertColumnRightText : 'Insert Column Right', deleteRowText : 'Delete Row', deleteColumnText : 'Delete Column', - deleteTableText : 'Delete Table' + deleteTableText : 'Delete Table', + txtFilter: 'Filter', + txtFilterValue: 'Filter by Selected cell\'s value', + txtFilterCellColor: 'Filter by cell\'s color', + txtFilterFontColor: 'Filter by font color', + txtReapply: 'Reapply' }, SSE.Views.DocumentHolder || {})); }); \ No newline at end of file