From 47048623e2a2c2d4f9db988a43ef59c19e4f96d5 Mon Sep 17 00:00:00 2001 From: Basher <89542751+Basher03@users.noreply.github.com> Date: Sat, 30 Jul 2022 14:04:45 +0300 Subject: [PATCH] Added groups fot pivot table templates --- .../main/resources/less/combo-dataview.less | 26 ++++++++- .../main/app/controller/PivotTable.js | 54 ++++++++++++++++--- .../main/app/view/PivotTable.js | 10 +++- apps/spreadsheeteditor/main/locale/en.json | 7 +++ apps/spreadsheeteditor/main/locale/ru.json | 7 +++ 5 files changed, 95 insertions(+), 9 deletions(-) diff --git a/apps/common/main/resources/less/combo-dataview.less b/apps/common/main/resources/less/combo-dataview.less index fecb3727e..896e17371 100644 --- a/apps/common/main/resources/less/combo-dataview.less +++ b/apps/common/main/resources/less/combo-dataview.less @@ -350,9 +350,31 @@ position: static; } - .view .dataview, .dropdown-menu { - padding: 1px; + .dataview { + .item { + &:hover { + .box-shadow(0 0 0 2px @border-preview-hover-ie) !important; + .box-shadow(0 0 0 @scaled-two-px-value @border-preview-hover) !important; + } + + &.selected { + .box-shadow(0 0 0 2px @border-preview-select-ie) !important; + .box-shadow(0 0 0 @scaled-two-px-value @border-preview-select) !important; + } + } } + + .dropdown-menu { + padding: 5px 1px 5px 1px; + + .dataview { + .group-description { + padding: 3px 0 3px 10px; + .font-weight-bold(); + } + } + } + } .combo-slicer-style { diff --git a/apps/spreadsheeteditor/main/app/controller/PivotTable.js b/apps/spreadsheeteditor/main/app/controller/PivotTable.js index 110e62c93..148ea6647 100644 --- a/apps/spreadsheeteditor/main/app/controller/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/controller/PivotTable.js @@ -355,8 +355,8 @@ define([ var self = this, styles = this.view.pivotStyles; this._isTemplatesChanged = true; - var count = styles.menuPicker.store.length; + if (count>0 && count==Templates.length) { var data = styles.menuPicker.dataViewItems; data && _.each(Templates, function(template, index){ @@ -367,20 +367,62 @@ define([ styles.fieldPicker.store.reset(styles.fieldPicker.store.models); } else { styles.menuPicker.store.reset([]); - var arr = []; - _.each(Templates, function(template){ - arr.push({ + var templates = []; + var groups = [ + {id: 'menu-table-group-custom', caption: self.view.__proto__.txtGroupPivot_Custom, templates: []}, + {id: 'menu-table-group-light', caption: self.view.__proto__.txtGroupPivot_Light, templates: []}, + {id: 'menu-table-group-medium', caption: self.view.__proto__.txtGroupPivot_Medium, templates: []}, + {id: 'menu-table-group-dark', caption: self.view.__proto__.txtGroupPivot_Dark, templates: []}, + {id: 'menu-table-group-no-name', caption: ' ', templates: []}, + ]; + _.each(Templates, function(template, index){ + var tip = template.asc_getDisplayName(); + var groupItem = ''; + + if (template.asc_getType()==0) { + var arr = tip.split(' '), + last = arr.pop(); + + if(tip == 'None'){ + groupItem = 'menu-table-group-light'; + } + else { + if(arr.length > 0){ + groupItem = 'menu-table-group-' + arr[arr.length - 1].toLowerCase(); + } + if(groups.some(function(item) {return item.id === groupItem;}) == false) { + groupItem = 'menu-table-group-no-name'; + } + } + arr = 'txtTable_' + arr.join(''); + tip = self.view.__proto__[arr] ? self.view.__proto__[arr] + ' ' + last : tip; + } + else { + groupItem = 'menu-table-group-custom' + } + groups.filter(function(item){ return item.id == groupItem; })[0].templates.push({ id : Common.UI.getId(), name : template.asc_getName(), caption : template.asc_getDisplayName(), type : template.asc_getType(), imageUrl : template.asc_getImage(), + group : groupItem, allowSelected : true, selected : false, - tip : template.asc_getDisplayName() + tip : tip }); }); - styles.menuPicker.store.add(arr); + groups = groups.filter(function(item, index){ + return item.templates.length > 0 + }); + + groups.forEach(function(item){ + templates = templates.concat(item.templates); + delete item.templates; + }); + + styles.groups.reset(groups); + styles.menuPicker.store.reset(templates); } }, diff --git a/apps/spreadsheeteditor/main/app/view/PivotTable.js b/apps/spreadsheeteditor/main/app/view/PivotTable.js index 9513fd36b..c6266d9c3 100644 --- a/apps/spreadsheeteditor/main/app/view/PivotTable.js +++ b/apps/spreadsheeteditor/main/app/view/PivotTable.js @@ -276,6 +276,7 @@ define([ itemWidth : 61, itemHeight : 49, menuMaxHeight : 300, + groups : new Common.UI.DataViewGroupStore(), lock : [_set.lostConnect, _set.coAuth, _set.noPivot, _set.selRangeEdit, _set.pivotLock, _set['FormatCells'], _set['PivotTables']], beforeOpenHandler: function(e) { var cmp = this, @@ -428,7 +429,14 @@ define([ tipSubtotals: 'Show or hide subtotals', txtSelect: 'Select', tipSelect: 'Select entire pivot table', - txtPivotTable: 'Pivot Table' + txtPivotTable: 'Pivot Table', + txtTable_PivotStyleMedium: 'Pivot Table Style Medium', + txtTable_PivotStyleDark: 'Pivot Table Style Dark', + txtTable_PivotStyleLight: 'Pivot Table Style Light', + txtGroupPivot_Custom: 'Custom', + txtGroupPivot_Light: 'Light', + txtGroupPivot_Medium: 'Medium', + txtGroupPivot_Dark: 'Dark' } }()), SSE.Views.PivotTable || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 8812ebaeb..cee25e4e8 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2762,6 +2762,13 @@ "SSE.Views.PivotTable.tipSubtotals": "Show or hide subtotals", "SSE.Views.PivotTable.txtCreate": "Insert Table", "SSE.Views.PivotTable.txtPivotTable": "Pivot Table", + "SSE.Views.PivotTable.txtTable_PivotStyleMedium": "Pivot Table Style Medium", + "SSE.Views.PivotTable.txtTable_PivotStyleDark": "Pivot Table Style Dark", + "SSE.Views.PivotTable.txtTable_PivotStyleLight": "Pivot Table Style Light", + "SSE.Views.PivotTable.txtGroupPivot_Custom": "Custom", + "SSE.Views.PivotTable.txtGroupPivot_Light": "Light", + "SSE.Views.PivotTable.txtGroupPivot_Medium": "Medium", + "SSE.Views.PivotTable.txtGroupPivot_Dark": "Dark", "SSE.Views.PivotTable.txtRefresh": "Refresh", "SSE.Views.PivotTable.txtSelect": "Select", "SSE.Views.PrintSettings.btnDownload": "Save & Download", diff --git a/apps/spreadsheeteditor/main/locale/ru.json b/apps/spreadsheeteditor/main/locale/ru.json index cec989006..d4f55c9c9 100644 --- a/apps/spreadsheeteditor/main/locale/ru.json +++ b/apps/spreadsheeteditor/main/locale/ru.json @@ -2760,6 +2760,13 @@ "SSE.Views.PivotTable.tipSubtotals": "Показать или скрыть промежуточные итоги", "SSE.Views.PivotTable.txtCreate": "Вставить таблицу", "SSE.Views.PivotTable.txtPivotTable": "Сводная таблица", + "SSE.Views.PivotTable.txtTable_PivotStyleMedium": "Стиль сводной таблицы: средний", + "SSE.Views.PivotTable.txtTable_PivotStyleDark": "Стиль сводной таблицы: темный", + "SSE.Views.PivotTable.txtTable_PivotStyleLight": "Стиль сводной таблицы: светлый", + "SSE.Views.PivotTable.txtGroupPivot_Custom": "Пользовательский", + "SSE.Views.PivotTable.txtGroupPivot_Light": "Светлый", + "SSE.Views.PivotTable.txtGroupPivot_Medium": "Средний", + "SSE.Views.PivotTable.txtGroupPivot_Dark": "Темный", "SSE.Views.PivotTable.txtRefresh": "Обновить", "SSE.Views.PivotTable.txtSelect": "Выделить", "SSE.Views.PrintSettings.btnDownload": "Сохранить и скачать",