From fc8ba6cf1582f1caa3cfee5db9bd8a16cd5be57c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 8 Aug 2019 10:48:27 +0300 Subject: [PATCH] [SSE] Add options for grouping cells --- .../main/app/controller/DataTab.js | 52 +++++++++++++------ .../main/app/view/DataTab.js | 26 +++++++++- apps/spreadsheeteditor/main/locale/en.json | 4 ++ apps/spreadsheeteditor/main/locale/ru.json | 4 ++ 4 files changed, 67 insertions(+), 19 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index d1875df19..ba3d9c8de 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -63,7 +63,8 @@ define([ 'data:ungroup': this.onUngroup, 'data:tocolumns': this.onTextToColumn, 'data:show': this.onShowClick, - 'data:hide': this.onHideClick + 'data:hide': this.onHideClick, + 'data:groupsettings': this.onGroupSettings } }); @@ -140,23 +141,40 @@ define([ Common.NotificationCenter.trigger('edit:complete', me.toolbar); }, - onGroup: function(btn) { - var me = this, - val = me.api.asc_checkAddGroup(); - if (val===null) { - (new SSE.Views.GroupDialog({ - title: me.view.capBtnGroup, - props: 'rows', - handler: function (dlg, result) { - if (result=='ok') { - me.api.asc_group(dlg.getSettings()); + onGroup: function(type, checked) { + if (type=='rows') { + (this.api.asc_checkAddGroup()!==undefined) && this.api.asc_group(true) + } else if (type=='columns') { + (this.api.asc_checkAddGroup()!==undefined) && this.api.asc_group(false) + } else if (type=='below') { + this.api.asc_setGroupSummary(checked, false); + } else if (type=='right') { + this.api.asc_setGroupSummary(checked, true); + } else { + var me = this, + val = me.api.asc_checkAddGroup(); + if (val===null) { + (new SSE.Views.GroupDialog({ + title: me.view.capBtnGroup, + props: 'rows', + handler: function (dlg, result) { + if (result=='ok') { + me.api.asc_group(dlg.getSettings()); + } + Common.NotificationCenter.trigger('edit:complete', me.toolbar); } - Common.NotificationCenter.trigger('edit:complete', me.toolbar); - } - })).show(); - } else if (val!==undefined) //undefined - error, true - rows, false - columns - me.api.asc_group(val); - Common.NotificationCenter.trigger('edit:complete', me.toolbar); + })).show(); + } else if (val!==undefined) //undefined - error, true - rows, false - columns + me.api.asc_group(val); + } + Common.NotificationCenter.trigger('edit:complete', this.toolbar); + }, + + onGroupSettings: function(menu) { + var value = this.api.asc_getGroupSummaryBelow(); + menu.items[3].setChecked(!!value, true); + value = this.api.asc_getGroupSummaryRight(); + menu.items[4].setChecked(!!value, true); }, onTextToColumn: function() { diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index a44b30e1a..1c4fce192 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -54,9 +54,15 @@ define([ me.btnUngroup.on('click', function (b, e) { me.fireEvent('data:ungroup'); }); + me.btnGroup.menu.on('item:click', function (menu, item, e) { + me.fireEvent('data:group', [item.value, item.checked]); + }); me.btnGroup.on('click', function (b, e) { me.fireEvent('data:group'); }); + me.btnGroup.menu.on('show:before', function (menu, e) { + me.fireEvent('data:groupsettings', [menu]); + }); me.btnTextToColumns.on('click', function (b, e) { me.fireEvent('data:tocolumns'); }); @@ -105,7 +111,8 @@ define([ cls: 'btn-toolbar x-huge icon-top', iconCls: 'btn-cell-group', caption: this.capBtnGroup, - split: false, + split: true, + menu: true, disabled: true, lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.sheetLock, _set.lostConnect, _set.coAuth] }); @@ -193,6 +200,17 @@ define([ me.btnUngroup.setMenu(_menu); me.btnGroup.updateHint(me.tipGroup); + _menu = new Common.UI.Menu({ + items: [ + {caption: me.textGroupRows, value: 'rows'}, + {caption: me.textGroupColumns, value: 'columns'}, + {caption: '--'}, + {caption: me.textBelow, value: 'below', checkable: true}, + {caption: me.textRightOf, value: 'right', checkable: true} + ] + }); + me.btnGroup.setMenu(_menu); + me.btnTextToColumns.updateHint(me.tipToColumns); me.btnsSortDown.forEach( function(btn) { @@ -243,13 +261,17 @@ define([ capBtnUngroup: 'Ungroup', textRows: 'Ungroup rows', textColumns: 'Ungroup columns', + textGroupRows: 'Group rows', + textGroupColumns: 'Group columns', textClear: 'Clear outline', tipGroup: 'Group range of cells', tipUngroup: 'Ungroup range of cells', capBtnTextToCol: 'Text to Columns', tipToColumns: 'Separate cell text into columns', capBtnTextShow: 'Show details', - capBtnTextHide: 'Hide details' + capBtnTextHide: 'Hide details', + textBelow: 'Summary rows below detail', + textRightOf: 'Summary columns to right of detail' } }()), SSE.Views.DataTab || {})); }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 5e2d82577..5d8cd300d 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1349,6 +1349,10 @@ "SSE.Views.DataTab.tipGroup": "Group range of cells", "SSE.Views.DataTab.tipToColumns": "Separate cell text into columns", "SSE.Views.DataTab.tipUngroup": "Ungroup range of cells", + "SSE.Views.DataTab.textGroupRows": "Group rows", + "SSE.Views.DataTab.textGroupColumns": "Group columns", + "SSE.Views.DataTab.textBelow": "Summary rows below detail", + "SSE.Views.DataTab.textRightOf": "Summary columns to right of detail", "SSE.Views.DigitalFilterDialog.cancelButtonText": "Cancel", "SSE.Views.DigitalFilterDialog.capAnd": "And", "SSE.Views.DigitalFilterDialog.capCondition1": "equals", diff --git a/apps/spreadsheeteditor/main/locale/ru.json b/apps/spreadsheeteditor/main/locale/ru.json index cc801cf48..fd7620846 100644 --- a/apps/spreadsheeteditor/main/locale/ru.json +++ b/apps/spreadsheeteditor/main/locale/ru.json @@ -1348,6 +1348,10 @@ "SSE.Views.DataTab.tipGroup": "Сгруппировать диапазон ячеек", "SSE.Views.DataTab.tipToColumns": "Разделить текст ячейки по столбцам", "SSE.Views.DataTab.tipUngroup": "Разгруппировать диапазон ячеек", + "SSE.Views.DataTab.textGroupRows": "Сгруппировать строки", + "SSE.Views.DataTab.textGroupColumns": "Сгруппировать столбцы", + "SSE.Views.DataTab.textBelow": "Итоги в строках под данными", + "SSE.Views.DataTab.textRightOf": "Итоги в столбцах справа от данных", "SSE.Views.DigitalFilterDialog.cancelButtonText": "Отмена", "SSE.Views.DigitalFilterDialog.capAnd": "И", "SSE.Views.DigitalFilterDialog.capCondition1": "равно",