From ef8a9c8d0dee1c861f36d33177a9b3fe47663eab Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 1 Oct 2019 14:20:52 +0300 Subject: [PATCH 01/28] Add custom sort button --- .../main/app/controller/DataTab.js | 21 +++++++++++++++++-- .../main/app/controller/Toolbar.js | 7 ++++--- .../main/app/template/Toolbar.template | 11 ++++++---- .../main/app/view/DataTab.js | 20 +++++++++++++++++- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index fbf16ba4a4..79ff2745c3 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -86,7 +86,8 @@ define([ 'data:tocolumns': this.onTextToColumn, 'data:show': this.onShowClick, 'data:hide': this.onHideClick, - 'data:groupsettings': this.onGroupSettings + 'data:groupsettings': this.onGroupSettings, + 'data:sortcustom': this.onCustomSort }, 'Statusbar': { 'sheet:changed': this.onApiSheetChanged @@ -212,6 +213,21 @@ define([ this.api.asc_changeGroupDetails(false); }, + onCustomSort: function() { + var me = this; + // (new SSE.Views.SortDialog({ + // title: me.textSort, + // closable: true, + // api: me.api, + // handler: function (result) { + // if (result == 'ok') { + // if (me && me.api) { + // } + // } + // } + // })).show(); + }, + onWorksheetLocked: function(index,locked) { if (index == this.api.asc_getActiveWorksheetIndex()) { Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: [this.view.btnGroup, this.view.btnUngroup]}); @@ -225,7 +241,8 @@ define([ this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); }, - textWizard: 'Text to Columns Wizard' + textWizard: 'Text to Columns Wizard', + textSort: 'Sort' }, SSE.Controllers.DataTab || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 031bdf0e9c..cd88d23451 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -2285,7 +2285,7 @@ define([ } need_disable = this._state.controlsdisabled.filters || (val===null); toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, - { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnTableTemplate, toolbar.btnInsertTable) }); + { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnCustomSort, toolbar.btnTableTemplate, toolbar.btnInsertTable) }); val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null; if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) { @@ -2315,10 +2315,10 @@ define([ toolbar.lockToolbar(SSE.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate, toolbar.btnInsertHyperlink, toolbar.btnInsertTable]}); this._state.inpivot = !!info.asc_getPivotTableInfo(); - toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsClearAutofilter, toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnInsertTable)}); + toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsClearAutofilter, toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnCustomSort, toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnInsertTable)}); need_disable = !this.appConfig.canModifyFilter; - toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2], + toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnsSortDown, toolbar.btnsSortUp, toolbar.btnCustomSort, toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2], toolbar.btnInsertTable)}); } @@ -3148,6 +3148,7 @@ define([ me.toolbar.btnsSortUp = datatab.getButtons('sort-up'); me.toolbar.btnsSetAutofilter = datatab.getButtons('set-filter'); me.toolbar.btnsClearAutofilter = datatab.getButtons('clear-filter'); + me.toolbar.btnCustomSort = datatab.getButtons('sort-custom'); var formulatab = me.getApplication().getController('FormulaDialog'); formulatab.setConfig({toolbar: me}); diff --git a/apps/spreadsheeteditor/main/app/template/Toolbar.template b/apps/spreadsheeteditor/main/app/template/Toolbar.template index 9d812e6b3d..cd2ec0e65f 100644 --- a/apps/spreadsheeteditor/main/app/template/Toolbar.template +++ b/apps/spreadsheeteditor/main/app/template/Toolbar.template @@ -185,14 +185,17 @@
- - + +
- - + +
+
+ +
diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index 1c4fce1924..3469726b51 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -92,6 +92,9 @@ define([ me.fireEvent('data:clearfilter', [Asc.c_oAscSortOptions.Descending]); }); }); + me.btnCustomSort.on('click', function (b, e) { + me.fireEvent('data:sortcustom'); + }); } return { @@ -162,6 +165,16 @@ define([ Common.Utils.injectComponent($host.find('#slot-btn-hide-details'), this.btnHide); this.lockedControls.push(this.btnHide); + this.btnCustomSort = new Common.UI.Button({ + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'btn-to-columns', + caption: this.capBtnTextCustomSort, + disabled: true, + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter] + }); + Common.Utils.injectComponent($host.find('#slot-btn-custom-sort'), this.btnCustomSort); + this.lockedControls.push(this.btnCustomSort); + this.btnsSortDown = Common.Utils.injectButtons($host.find('.slot-sortdesc'), '', 'btn-sort-down', '', [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter]); @@ -225,6 +238,7 @@ define([ me.btnsClearAutofilter.forEach( function(btn) { btn.updateHint(me.toolbar.txtClearFilter); }); + me.btnCustomSort.updateHint(me.tipCustomSort); setEvents.call(me); }); @@ -240,6 +254,8 @@ define([ return this.btnsSortDown; else if (type == 'sort-up') return this.btnsSortUp; + else if (type == 'sort-custom') + return this.btnCustomSort; else if (type == 'set-filter') return this.btnsSetAutofilter; else if (type == 'clear-filter') @@ -271,7 +287,9 @@ define([ capBtnTextShow: 'Show details', capBtnTextHide: 'Hide details', textBelow: 'Summary rows below detail', - textRightOf: 'Summary columns to right of detail' + textRightOf: 'Summary columns to right of detail', + capBtnTextCustomSort: 'Custom Sort', + tipCustomSort: 'Custom sort' } }()), SSE.Views.DataTab || {})); }); From dca399480b8519be9045a28aab6c2e498ae048c8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 5 Oct 2019 14:20:38 +0300 Subject: [PATCH 02/28] [SSE] Add dialog for custom sort --- .../main/app/controller/DataTab.js | 61 +++- .../main/app/template/SortDialog.template | 28 ++ .../main/app/view/SortDialog.js | 268 ++++++++++++++++++ .../main/app/view/SortOptionsDialog.js | 157 ++++++++++ 4 files changed, 501 insertions(+), 13 deletions(-) create mode 100644 apps/spreadsheeteditor/main/app/template/SortDialog.template create mode 100644 apps/spreadsheeteditor/main/app/view/SortDialog.js create mode 100644 apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 79ff2745c3..9cd4ba91f0 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -42,7 +42,8 @@ define([ 'core', 'spreadsheeteditor/main/app/view/DataTab', - 'spreadsheeteditor/main/app/view/GroupDialog' + 'spreadsheeteditor/main/app/view/GroupDialog', + 'spreadsheeteditor/main/app/view/SortDialog' ], function () { 'use strict'; @@ -215,17 +216,48 @@ define([ onCustomSort: function() { var me = this; - // (new SSE.Views.SortDialog({ - // title: me.textSort, - // closable: true, - // api: me.api, - // handler: function (result) { - // if (result == 'ok') { - // if (me && me.api) { - // } - // } - // } - // })).show(); + if (this.api) { + var res = this.api.asc_sortCellsRangeExpand(); + if (res) { + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtExpandSort, + + buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, + {caption: this.txtSortSelected, primary: true, value: 'sort'}, + 'cancel'], + callback: function(btn){ + if (btn == 'expand' || btn == 'sort') { + setTimeout(function(){ + me.showCustomSort(btn == 'expand'); + },1); + } + } + }; + Common.UI.alert(config); + } else + me.showCustomSort(res !== null); + } + }, + + showCustomSort: function(expand) { + var me = this, + props = me.api.asc_getSortProps(expand); + // props = new Asc.CSortProperties(); + if (props) { + (new SSE.Views.SortDialog({ + props: props, + api: me.api, + handler: function (result) { + if (result == 'ok') { + if (me && me.api) { + + } + } + } + })).show(); + } }, onWorksheetLocked: function(index,locked) { @@ -242,7 +274,10 @@ define([ }, textWizard: 'Text to Columns Wizard', - textSort: 'Sort' + txtExpandSort: 'The data next to the selection will not be sorted. Do you want to expand the selection to include the adjacent data or continue with sorting the currently selected cells only?', + txtExpand: 'Expand and sort', + txtSorting: 'Sorting', + txtSortSelected: 'Sort selected' }, SSE.Controllers.DataTab || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/template/SortDialog.template b/apps/spreadsheeteditor/main/app/template/SortDialog.template new file mode 100644 index 0000000000..4735250162 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/template/SortDialog.template @@ -0,0 +1,28 @@ +
+
+ + + + + + + + + + +
+ + + +
+
+ +
+ + + +
+
+
+
+
\ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js new file mode 100644 index 0000000000..872a6371d2 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -0,0 +1,268 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * + * SortDialog.js + * + * Created by Julia.Radzhabova on 05.10.19 + * Copyright (c) 2019 Ascensio System SIA. All rights reserved. + * + */ + +define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', + 'common/main/lib/view/AdvancedSettingsWindow', + 'common/main/lib/component/ComboBox', + 'common/main/lib/component/ListView', + 'spreadsheeteditor/main/app/view/SortOptionsDialog' +], function (contentTemplate) { + 'use strict'; + + SSE.Views = SSE.Views || {}; + + SSE.Views.SortDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + alias: 'SortDialog', + contentWidth: 500, + height: 285, + buttons: ['ok', 'cancel'] + }, + + initialize: function (options) { + var me = this; + _.extend(this.options, { + title: this.txtTitle, + template: [ + '
', + '
' + _.template(contentTemplate)({scope: this}) + '
', + '
' + ].join('') + }, options); + + this.api = options.api; + this.handler = options.handler; + this.props = options.props; + + this.sortOptions = {}; + this.sortStore = new Common.UI.DataViewStore(); + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + render: function () { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.sortList = new Common.UI.ListView({ + el: $('#sort-dialog-list', this.$window), + store: new Common.UI.DataViewStore(), + simpleAddMode: true, + emptyText: '', + template: _.template(['
'].join('')), + itemTemplate: _.template([ + '
', + '
', + '
<%= name %>
', + '
<%= scopeName %>
', + '
<%= range %>
', + '
' + ].join('')) + }); + // this.rangeList.on('item:select', _.bind(this.onSelectLevel, this)) + // .on('item:keydown', _.bind(this.onKeyDown, this)); + + this.btnAdd = new Common.UI.Button({ + el: $('#sort-dialog-btn-add') + }); + // this.btnAdd.on('click', _.bind(this.onAddLevel, this, false)); + + this.btnDelete = new Common.UI.Button({ + el: $('#sort-dialog-btn-delete') + }); + // this.btnDelete.on('click', _.bind(this.onDeleteLevel, this)); + + this.btnCopy = new Common.UI.Button({ + el: $('#sort-dialog-btn-copy') + }); + // this.btnCopy.on('click', _.bind(this.onCopyLevel, this, false)); + + this.btnOptions = new Common.UI.Button({ + el: $('#sort-dialog-btn-options') + }); + this.btnOptions.on('click', _.bind(this.onOptions, this, false)); + + this.btnUp = new Common.UI.Button({ + cls: 'btn-toolbar', + iconCls: 'btn-incfont', + hint: this.textUp + }); + this.btnUp.render($('#sort-dialog-btn-up')) ; + // this.btnUp.on('click', _.bind(this.onUpClick, this)); + + this.btnDown = new Common.UI.Button({ + cls: 'btn-toolbar', + iconCls: 'btn-decfont', + hint: this.textDown + }); + this.btnDown.render($('#sort-dialog-btn-down')) ; + // this.btnDown.on('click', _.bind(this.onDownClick, this)); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + _setDefaults: function (props) { + if (props) { + this.sortOptions = { + headers: props.asc_getHasHeaders(), + // sensitive: props.asc_getCaseSensitive(), + sort: props.asc_getColumnSort() + }; + } + }, + + refreshRangeList: function(ranges, selectedItem) { + if (ranges) { + this.ranges = ranges; + var arr = []; + for (var i=0; i0) ? this.textnoNames : this.textEmpty); + } + + var me = this, + store = this.rangeList.store, + models = this.rangesStore.models, + val = this.cmbFilter.getValue(), + isTableFilter = (val<3) ? (val==2) : -1, + isWorkbook = (val>2) ? (val==4) : -1; + if (val>0) + models = this.rangesStore.filter(function(item) { + if (isTableFilter!==-1) + return (isTableFilter===item.get('isTable')); + if (isWorkbook!==-1) + return (isWorkbook===(item.get('scope')===null)); + return false; + }); + + store.reset(models, {silent: false}); + + val = store.length; + this.btnEditRange.setDisabled(!val); + this.btnDeleteRange.setDisabled(!val); + if (val>0) { + if (selectedItem===undefined || selectedItem===null) selectedItem = 0; + if (_.isNumber(selectedItem)) { + if (selectedItem>val-1) selectedItem = val-1; + this.rangeList.selectByIndex(selectedItem); + setTimeout(function() { + me.rangeList.scrollToRecord(store.at(selectedItem)); + }, 50); + + } else if (selectedItem){ // object + var rec = store.findWhere({name: selectedItem.asc_getName(true), scope: selectedItem.asc_getScope()}); + if (rec) { + this.rangeList.selectRecord(rec); + setTimeout(function() { + me.rangeList.scrollToRecord(rec); + }, 50); + } + } + + if (this.userTooltip===true && this.rangeList.cmpEl.find('.lock-user').length>0) + this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me)); + } + _.delay(function () { + me.rangeList.cmpEl.find('.listview').focus(); + me.rangeList.scroller.update({alwaysVisibleY: true}); + }, 100, this); + }, + + onOptions: function () { + var me = this; + + var win = new SSE.Views.SortOptionsDialog({ + props: me.sortOptions, + handler : function(result, settings) { + if (result == 'ok' && settings) { + me.sortOptions = settings; + } + } + }); + win.show(); + }, + + getSettings: function() { + var props = new Asc.CSortProperties(); + props.asc_setHasHeaders(this.sortOptions.headers); + // props.asc_setCaseSensitive(this.sortOptions.sensitive); + props.asc_setColumnSort(this.sortOptions.sort); + + return {}; + }, + + close: function () { + Common.UI.Window.prototype.close.call(this); + }, + + onKeyDown: function (lisvView, record, e) { + if (e.keyCode==Common.UI.Keys.DELETE && !this.btnDelete.isDisabled()) + this.onDeletelevel(); + }, + + txtTitle: 'Sort', + textAdd: 'Add level', + textDelete: 'Delete level', + textCopy: 'Copy level', + textColumn: 'Column', + textSort: 'Sort on', + textOrder: 'Order', + textUp: 'Move level up', + textDown: 'Move level down', + textOptions: 'Options' + + }, SSE.Views.SortDialog || {})); +}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js new file mode 100644 index 0000000000..d4579dfec5 --- /dev/null +++ b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js @@ -0,0 +1,157 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * SortOptionsDialog.js + * + * Created by Julia Radzhabova on 05.10.2019 + * Copyright (c) 2019 Ascensio System SIA. All rights reserved. + * + */ +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/CheckBox', + 'common/main/lib/component/RadioBox', + 'common/main/lib/view/AdvancedSettingsWindow' +], function () { 'use strict'; + + SSE.Views.SortOptionsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + contentWidth: 230, + height: 225 + }, + + initialize : function(options) { + var me = this; + + _.extend(this.options, { + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '
', + '
', + '
', + '
', + '', + '
', + '
', + '
', + '
', + '
', + '
', + '
', + '
' + ].join('') + }, options); + + this.props = options.props; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.chHeaders = new Common.UI.CheckBox({ + el: $('#sort-options-chk-headers'), + labelText: this.textHeaders + }); + + this.chCase = new Common.UI.CheckBox({ + el: $('#sort-options-chk-case'), + labelText: this.textCase + }); + + this.radioTop = new Common.UI.RadioBox({ + el: $('#sort-options-radio-top'), + labelText: this.textTopBottom, + name: 'asc-radio-sort-orient', + checked: true + }).on('change', function(field, newValue) { + }); + + this.radioLeft = new Common.UI.RadioBox({ + el: $('#sort-options-radio-left'), + labelText: this.textLeftRight, + name: 'asc-radio-sort-orient' + }).on('change', function(field, newValue) { + }); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + _setDefaults: function (props) { + if (props) { + this.chHeaders.setValue(props.headers); + this.chCase.setValue(props.sensitive); + (props.sort == 'Row') ? this.radioLeft.setValue(true) : this.radioTop.setValue(true); + } + }, + + getSettings: function () { + return {headers: this.chHeaders.getValue()=='checked', sensitive: this.chCase.getValue()=='checked', sort: this.radioLeft.getValue() ? 'Row' : 'Column'}; + }, + + textTitle: 'Sort Options', + textHeaders: 'My data has headers', + textCase: 'Case sensitive', + textOrientation: 'Orientation', + textTopBottom: 'Sort top to bottom', + textLeftRight: 'Sort left to right' + + }, SSE.Views.SortOptionsDialog || {})) +}); From 488753ac57c47addfacca73f110da69d927f1225 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 5 Oct 2019 16:58:13 +0300 Subject: [PATCH 03/28] [SSE] Custom sort: fill list for custom sort --- apps/common/main/lib/component/ComboBox.js | 11 ++ apps/common/main/resources/less/combobox.less | 4 + .../main/app/template/SortDialog.template | 6 +- .../main/app/view/SortDialog.js | 175 +++++++++++------- 4 files changed, 127 insertions(+), 69 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 5b7a7f4cc9..486790967f 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -217,6 +217,11 @@ define([ }); } + var $list = el.find('.dropdown-menu'); + if ($list.hasClass('menu-absolute')) { + $list.css('min-width', el.outerWidth()); + } + el.on('show.bs.dropdown', _.bind(me.onBeforeShowMenu, me)); el.on('shown.bs.dropdown', _.bind(me.onAfterShowMenu, me)); el.on('hide.bs.dropdown', _.bind(me.onBeforeHideMenu, me)); @@ -292,6 +297,12 @@ define([ tip.hide(); } } + + var $list = this.cmpEl.find('ul'); + if ($list.hasClass('menu-absolute')) { + var offset = this.cmpEl.offset(); + $list.css({left: offset.left, top: offset.top + this.cmpEl.outerHeight() + 2}); + } }, onAfterShowMenu: function(e) { diff --git a/apps/common/main/resources/less/combobox.less b/apps/common/main/resources/less/combobox.less index 9b87f75da9..e054164700 100644 --- a/apps/common/main/resources/less/combobox.less +++ b/apps/common/main/resources/less/combobox.less @@ -106,4 +106,8 @@ padding-top: 0; padding-bottom: 0; } + + .dropdown-menu.menu-absolute { + position: fixed; + } } diff --git a/apps/spreadsheeteditor/main/app/template/SortDialog.template b/apps/spreadsheeteditor/main/app/template/SortDialog.template index 4735250162..3473e8a761 100644 --- a/apps/spreadsheeteditor/main/app/template/SortDialog.template +++ b/apps/spreadsheeteditor/main/app/template/SortDialog.template @@ -13,14 +13,14 @@ - - + + -
+
diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 872a6371d2..52370aa057 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -88,11 +88,10 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', emptyText: '', template: _.template(['
'].join('')), itemTemplate: _.template([ - '
', - '
', - '
<%= name %>
', - '
<%= scopeName %>
', - '
<%= range %>
', + '
', + '
', + '
', + '
', '
' ].join('')) }); @@ -149,76 +148,114 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', // sensitive: props.asc_getCaseSensitive(), sort: props.asc_getColumnSort() }; + + // get name from props + this.column_data = [ + { value: 'a', displayValue: 'a' }, + { value: 'b', displayValue: 'b' }, + { value: 'c', displayValue: 'c' } + ]; + this.sort_data = [ + { value: Asc.c_oAscSortOptions.ByValue, displayValue: this.textValues }, + { value: Asc.c_oAscSortOptions.ByColorFill, displayValue: this.textCellColor }, + { value: Asc.c_oAscSortOptions.ByColorFont, displayValue: this.textFontColor }, + { value: Asc.c_oAscSortOptions.ByIcon, displayValue: this.textCellIcon } + ]; + this.order_data = [ + { value: Asc.c_oAscSortOptions.Ascending, displayValue: this.textAZ }, + { value: Asc.c_oAscSortOptions.Descending, displayValue: this.textZA } + ]; + + this.sortList.on('item:add', _.bind(this.addControls, this)); + this.sortList.on('item:change', _.bind(this.addControls, this)); + this.refreshList(props.asc_getLevels()); } }, - refreshRangeList: function(ranges, selectedItem) { - if (ranges) { - this.ranges = ranges; + refreshList: function(levels) { + this.cmbsColumn = []; + this.cmbsSort = []; + this.cmbsOrder = []; + + if (levels) { var arr = []; - for (var i=0; i0) ? this.textnoNames : this.textEmpty); - } - var me = this, - store = this.rangeList.store, - models = this.rangesStore.models, - val = this.cmbFilter.getValue(), - isTableFilter = (val<3) ? (val==2) : -1, - isWorkbook = (val>2) ? (val==4) : -1; - if (val>0) - models = this.rangesStore.filter(function(item) { - if (isTableFilter!==-1) - return (isTableFilter===item.get('isTable')); - if (isWorkbook!==-1) - return (isWorkbook===(item.get('scope')===null)); - return false; + // arr.push({ + // index: 0, + // name: 'a', + // sort: Asc.c_oAscSortOptions.ByValue, + // order: Asc.c_oAscSortOptions.Ascending + // }); + // arr.push({ + // index: 1, + // name: 's', + // sort: Asc.c_oAscSortOptions.ByValue, + // order: Asc.c_oAscSortOptions.Descending + // }); + + arr.sort(function (a, b) { + return a.index - b.index; }); - - store.reset(models, {silent: false}); - - val = store.length; - this.btnEditRange.setDisabled(!val); - this.btnDeleteRange.setDisabled(!val); - if (val>0) { - if (selectedItem===undefined || selectedItem===null) selectedItem = 0; - if (_.isNumber(selectedItem)) { - if (selectedItem>val-1) selectedItem = val-1; - this.rangeList.selectByIndex(selectedItem); - setTimeout(function() { - me.rangeList.scrollToRecord(store.at(selectedItem)); - }, 50); - - } else if (selectedItem){ // object - var rec = store.findWhere({name: selectedItem.asc_getName(true), scope: selectedItem.asc_getScope()}); - if (rec) { - this.rangeList.selectRecord(rec); - setTimeout(function() { - me.rangeList.scrollToRecord(rec); - }, 50); - } - } - - if (this.userTooltip===true && this.rangeList.cmpEl.find('.lock-user').length>0) - this.rangeList.cmpEl.on('mouseover', _.bind(me.onMouseOverLock, me)).on('mouseout', _.bind(me.onMouseOutLock, me)); + this.sortList.store.reset(arr); } - _.delay(function () { - me.rangeList.cmpEl.find('.listview').focus(); - me.rangeList.scroller.update({alwaysVisibleY: true}); - }, 100, this); + }, + + addControls: function(listView, itemView, item) { + if (!item) return; + + var cmpEl = this.sortList.cmpEl; + var i = item.get('index'); + var el = cmpEl.find('#sort-dialog-cmb-col-' + i), + combo = new Common.UI.ComboBox({ + el : el, + editable : false, + cls : 'input-group-nr', + menuCls : 'menu-absolute', + data : this.column_data + }).on('selected', function(combo, record) { + item.set('name', record.value); + }); + var val = item.get('name'); + (val!==null) && combo.setValue(item.get('name')); + this.cmbsColumn[i] = combo; + + el = cmpEl.find('#sort-dialog-cmb-sort-' + i); + combo = new Common.UI.ComboBox({ + el : el, + editable : false, + cls : 'input-group-nr', + menuCls : 'menu-absolute', + data : this.sort_data + }).on('selected', function(combo, record) { + item.set('sort', record.value); + }); + val = item.get('sort'); + (val!==null) && combo.setValue(val); + this.cmbsSort[i] = combo; + + el = cmpEl.find('#sort-dialog-cmb-order-' + i); + combo = new Common.UI.ComboBox({ + el : el, + editable : false, + cls : 'input-group-nr', + menuCls : 'menu-absolute', + data : this.order_data + }).on('selected', function(combo, record) { + item.set('order', record.value); + }); + val = item.get('order'); + (val!==null) && combo.setValue(val); + this.cmbsOrder[i] = combo; }, onOptions: function () { @@ -262,7 +299,13 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', textOrder: 'Order', textUp: 'Move level up', textDown: 'Move level down', - textOptions: 'Options' + textOptions: 'Options', + textValues: 'Values', + textCellColor: 'Cell color', + textFontColor: 'Font color', + textCellIcon: 'Cell icon', + textAZ: 'A to Z', + textZA: 'Z to A' }, SSE.Views.SortDialog || {})); }); \ No newline at end of file From 8be314b4f44e1bf63762cc1a717dbb763bc7d517 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 7 Oct 2019 15:20:00 +0300 Subject: [PATCH 04/28] [SSE] Custom sort: add/remove levels. Set sort options. --- .../main/app/template/SortDialog.template | 4 +- .../main/app/view/SortDialog.js | 111 ++++++++++++------ .../main/app/view/SortOptionsDialog.js | 22 ++-- 3 files changed, 88 insertions(+), 49 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/template/SortDialog.template b/apps/spreadsheeteditor/main/app/template/SortDialog.template index 3473e8a761..6c4009ed8b 100644 --- a/apps/spreadsheeteditor/main/app/template/SortDialog.template +++ b/apps/spreadsheeteditor/main/app/template/SortDialog.template @@ -13,14 +13,14 @@ - + -
+
diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 52370aa057..4f629963d6 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -53,7 +53,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', options: { alias: 'SortDialog', contentWidth: 500, - height: 285, + height: 294, buttons: ['ok', 'cancel'] }, @@ -84,14 +84,13 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortList = new Common.UI.ListView({ el: $('#sort-dialog-list', this.$window), store: new Common.UI.DataViewStore(), - simpleAddMode: true, emptyText: '', template: _.template(['
'].join('')), itemTemplate: _.template([ '
', - '
', - '
', - '
', + '
', + '
', + '
', '
' ].join('')) }); @@ -101,12 +100,12 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnAdd = new Common.UI.Button({ el: $('#sort-dialog-btn-add') }); - // this.btnAdd.on('click', _.bind(this.onAddLevel, this, false)); + this.btnAdd.on('click', _.bind(this.onAddLevel, this, false)); this.btnDelete = new Common.UI.Button({ el: $('#sort-dialog-btn-delete') }); - // this.btnDelete.on('click', _.bind(this.onDeleteLevel, this)); + this.btnDelete.on('click', _.bind(this.onDeleteLevel, this)); this.btnCopy = new Common.UI.Button({ el: $('#sort-dialog-btn-copy') @@ -134,6 +133,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnDown.render($('#sort-dialog-btn-down')) ; // this.btnDown.on('click', _.bind(this.onDownClick, this)); + this.lblColumn = $('#sort-dialog-label-column'); + this.afterRender(); }, @@ -146,15 +147,17 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortOptions = { headers: props.asc_getHasHeaders(), // sensitive: props.asc_getCaseSensitive(), - sort: props.asc_getColumnSort() + sortcol: props.asc_getColumnSort() }; + this.lblColumn.text(props.asc_getColumnSort() ? this.textColumn : this.textRow); + // get name from props - this.column_data = [ - { value: 'a', displayValue: 'a' }, - { value: 'b', displayValue: 'b' }, - { value: 'c', displayValue: 'c' } - ]; + this.column_data = []; + var values = props.asc_getSortList(); + for (var i=0; i0) && this.sortList.selectByIndex(0); } }, @@ -214,19 +201,20 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', if (!item) return; var cmpEl = this.sortList.cmpEl; - var i = item.get('index'); + var i = item.get('levelIndex'); var el = cmpEl.find('#sort-dialog-cmb-col-' + i), combo = new Common.UI.ComboBox({ el : el, editable : false, cls : 'input-group-nr', menuCls : 'menu-absolute', + menuStyle : 'max-height: 135px;', data : this.column_data }).on('selected', function(combo, record) { - item.set('name', record.value); + item.set('columnIndex', record.value); }); - var val = item.get('name'); - (val!==null) && combo.setValue(item.get('name')); + var val = item.get('columnIndex'); + (val!==null) && combo.setValue(item.get('columnIndex')); this.cmbsColumn[i] = combo; el = cmpEl.find('#sort-dialog-cmb-sort-' + i); @@ -266,17 +254,65 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', handler : function(result, settings) { if (result == 'ok' && settings) { me.sortOptions = settings; + me.lblColumn.text(settings.sortcol ? me.textColumn : me.textRow); + me.props.asc_setHasHeaders(settings.headers); + // me.props.asc_setCaseSensitive(settings.sensitive); + me.props.asc_setColumnSort(settings.sortcol); + me.props.asc_updateSortList(); + me.updateSortValues(); } } }); win.show(); }, + updateSortValues: function() { + var values = this.props.asc_getSortList(); + this.column_data = []; + for (var i=0; i0) && this.sortList.selectByIndex(index', '', '', - '
', + '
', '', '', '', '', - '
', + '
', '', '', '', @@ -113,19 +113,21 @@ define([ }); this.radioTop = new Common.UI.RadioBox({ - el: $('#sort-options-radio-top'), + el: $('#sort-options-radio-row'), labelText: this.textTopBottom, name: 'asc-radio-sort-orient', checked: true - }).on('change', function(field, newValue) { - }); + }).on('change', _.bind(function(field, newValue, eOpts) { + newValue && this.chHeaders.setDisabled(false); + }, this)); this.radioLeft = new Common.UI.RadioBox({ - el: $('#sort-options-radio-left'), + el: $('#sort-options-radio-col'), labelText: this.textLeftRight, name: 'asc-radio-sort-orient' - }).on('change', function(field, newValue) { - }); + }).on('change', _.bind(function(field, newValue, eOpts) { + newValue && this.chHeaders.setDisabled(true); + }, this)); this.afterRender(); }, @@ -138,12 +140,12 @@ define([ if (props) { this.chHeaders.setValue(props.headers); this.chCase.setValue(props.sensitive); - (props.sort == 'Row') ? this.radioLeft.setValue(true) : this.radioTop.setValue(true); + (props.sortcol) ? this.radioTop.setValue(true) : this.radioLeft.setValue(true); } }, getSettings: function () { - return {headers: this.chHeaders.getValue()=='checked', sensitive: this.chCase.getValue()=='checked', sort: this.radioLeft.getValue() ? 'Row' : 'Column'}; + return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), sensitive: this.chCase.getValue()=='checked', sortcol: this.radioTop.getValue()}; }, textTitle: 'Sort Options', From bf226e3cc96e4d937879ebd34d502ff993acc291 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 7 Oct 2019 16:34:10 +0300 Subject: [PATCH 05/28] [SSE] Custom sort: move/copy levels --- .../main/app/view/SortDialog.js | 65 +++++++++++++++++-- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 4f629963d6..65de9c56fe 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -94,8 +94,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', '
' ].join('')) }); - // this.rangeList.on('item:select', _.bind(this.onSelectLevel, this)) - // .on('item:keydown', _.bind(this.onKeyDown, this)); + this.sortList.on('item:select', _.bind(this.onSelectLevel, this)) + .on('item:keydown', _.bind(this.onKeyDown, this)); this.btnAdd = new Common.UI.Button({ el: $('#sort-dialog-btn-add') @@ -110,7 +110,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnCopy = new Common.UI.Button({ el: $('#sort-dialog-btn-copy') }); - // this.btnCopy.on('click', _.bind(this.onCopyLevel, this, false)); + this.btnCopy.on('click', _.bind(this.onCopyLevel, this, false)); this.btnOptions = new Common.UI.Button({ el: $('#sort-dialog-btn-options') @@ -123,7 +123,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', hint: this.textUp }); this.btnUp.render($('#sort-dialog-btn-up')) ; - // this.btnUp.on('click', _.bind(this.onUpClick, this)); + this.btnUp.on('click', _.bind(this.onMoveClick, this, true)); this.btnDown = new Common.UI.Button({ cls: 'btn-toolbar', @@ -131,7 +131,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', hint: this.textDown }); this.btnDown.render($('#sort-dialog-btn-down')) ; - // this.btnDown.on('click', _.bind(this.onDownClick, this)); + this.btnDown.on('click', _.bind(this.onMoveClick, this, false)); this.lblColumn = $('#sort-dialog-label-column'); @@ -195,6 +195,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortList.store.reset(arr); (this.sortList.store.length>0) && this.sortList.selectByIndex(0); } + this.updateButtons(); }, addControls: function(listView, itemView, item) { @@ -291,6 +292,24 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortList.selectRecord(rec); this.sortList.scrollToRecord(rec); } + this.updateButtons(); + }, + + onCopyLevel: function() { + var store = this.sortList.store, + rec = this.sortList.getSelectedRec(); + rec = store.add({ + levelIndex: this.cmbsColumn.length, + columnIndex: rec ? rec.get('columnIndex') : '', + sort: rec ? rec.get('sort') : Asc.c_oAscSortOptions.ByValue, + order: rec ? rec.get('order') : Asc.c_oAscSortOptions.Ascending, + color: rec ? rec.get('color') : null + }, {at: rec ? store.indexOf(rec)+1 : store.length}); + if (rec) { + this.sortList.selectRecord(rec); + this.sortList.scrollToRecord(rec); + } + this.updateButtons(); }, onDeleteLevel: function() { @@ -305,7 +324,26 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', index = store.indexOf(rec); store.remove(rec); (store.length>0) && this.sortList.selectByIndex(index63); + this.btnCopy.setDisabled(this.sortList.store.length<1); + this.btnDelete.setDisabled(this.sortList.store.length<1); + this.updateMoveButtons(); + this.sortList.scroller && this.sortList.scroller.update(); + }, + + updateMoveButtons: function() { + var rec = this.sortList.getSelectedRec(), + index = rec ? this.sortList.store.indexOf(rec) : -1; + this.btnUp.setDisabled(index<1); + this.btnDown.setDisabled(index<0 || index==this.sortList.store.length-1); }, txtTitle: 'Sort', From ca7dc3ebdc5e9c403c6a46704b56942d9f12abeb Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 10 Oct 2019 14:46:39 +0300 Subject: [PATCH 06/28] [SSE] Apply sort settings --- .../main/app/controller/DataTab.js | 4 +- .../main/app/view/SortDialog.js | 118 +++++++++++++----- 2 files changed, 91 insertions(+), 31 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 9cd4ba91f0..abef13c776 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -249,10 +249,10 @@ define([ (new SSE.Views.SortDialog({ props: props, api: me.api, - handler: function (result) { + handler: function (result, settings) { if (result == 'ok') { if (me && me.api) { - + me.api.asc_setSortProps(settings); } } } diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 65de9c56fe..1261859f6d 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -71,9 +71,18 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.api = options.api; this.handler = options.handler; this.props = options.props; + this.levels = []; this.sortOptions = {}; - this.sortStore = new Common.UI.DataViewStore(); + + this.options.handler = function(result, value) { + if ( result != 'ok' || this.isListValid() ) { + if (options.handler) + options.handler.call(this, result, value); + return; + } + return true; + }; Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); }, @@ -161,8 +170,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sort_data = [ { value: Asc.c_oAscSortOptions.ByValue, displayValue: this.textValues }, { value: Asc.c_oAscSortOptions.ByColorFill, displayValue: this.textCellColor }, - { value: Asc.c_oAscSortOptions.ByColorFont, displayValue: this.textFontColor }, - { value: Asc.c_oAscSortOptions.ByIcon, displayValue: this.textCellIcon } + { value: Asc.c_oAscSortOptions.ByColorFont, displayValue: this.textFontColor } ]; this.order_data = [ { value: Asc.c_oAscSortOptions.Ascending, displayValue: this.textAZ }, @@ -176,10 +184,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', }, refreshList: function(levels) { - this.cmbsColumn = []; - this.cmbsSort = []; - this.cmbsOrder = []; - + this.levels = []; if (levels) { var arr = []; for (var i=0; i0) && this.sortList.selectByIndex(index Date: Thu, 10 Oct 2019 16:47:30 +0300 Subject: [PATCH 07/28] [SSE] Fix bug --- apps/spreadsheeteditor/main/app/view/SortDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 1261859f6d..8e976be441 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -394,7 +394,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', level.asc_setSortBy(levelProp.cmbSort.getValue()); level.asc_setDescending(levelProp.cmbOrder.getValue()); // level.asc_setColor(level.color); - arr.push[level]; + arr.push(level); } }); props.asc_setLevels(arr); From 40a62f93e6079f9b40ec13de5773b9e6d007f69f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 1 Nov 2019 16:24:02 +0300 Subject: [PATCH 08/28] [SSE] Fix loading sort settings --- apps/spreadsheeteditor/main/app/view/SortDialog.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 8e976be441..497663f299 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -188,7 +188,10 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', if (levels) { var arr = []; for (var i=0; i0) && this.sortList.selectByIndex(0); From 1c2e09ddd8d1fa26813d1e7aa465a531e7c969c3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 1 Nov 2019 16:31:14 +0300 Subject: [PATCH 09/28] [SSE] Custom sort: add translation for row/column --- apps/spreadsheeteditor/main/app/controller/Main.js | 8 ++++++-- apps/spreadsheeteditor/main/locale/en.json | 2 ++ apps/spreadsheeteditor/main/locale/ru.json | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index e2d4d35708..bb39c6ec64 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -119,7 +119,9 @@ define([ 'Date': this.txtDate, 'Time': this.txtTime, 'Tab': this.txtTab, - 'File': this.txtFile + 'File': this.txtFile, + 'Column': this.txtColumn, + 'Row': this.txtRow }; styleNames.forEach(function(item){ translate[item] = me['txtStyle_' + item.replace(/ /g, '_')] || item; @@ -2433,7 +2435,9 @@ define([ txtTime: 'Time', txtTab: 'Tab', txtFile: 'File', - errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
Please contact your Document Server administrator for details.' + errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
Please contact your Document Server administrator for details.', + txtColumn: 'Column', + txtRow: 'Row' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 835f1d07bf..74c5b37427 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -737,6 +737,8 @@ "SSE.Controllers.Main.warnNoLicense": "This version of %1 editors has certain limitations for concurrent connections to the document server.
If you need more please consider purchasing a commercial license.", "SSE.Controllers.Main.warnNoLicenseUsers": "This version of %1 editors has certain limitations for concurrent users.
If you need more please consider purchasing a commercial license.", "SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", + "SSE.Controllers.Main.txtColumn": "Column", + "SSE.Controllers.Main.txtRow": "Row", "SSE.Controllers.Print.strAllSheets": "All Sheets", "SSE.Controllers.Print.textWarning": "Warning", "SSE.Controllers.Print.txtCustom": "Custom", diff --git a/apps/spreadsheeteditor/main/locale/ru.json b/apps/spreadsheeteditor/main/locale/ru.json index d3dbaf4f2b..7168f9734c 100644 --- a/apps/spreadsheeteditor/main/locale/ru.json +++ b/apps/spreadsheeteditor/main/locale/ru.json @@ -736,6 +736,8 @@ "SSE.Controllers.Main.warnNoLicense": "Эта версия редакторов %1 имеет некоторые ограничения по количеству одновременных подключений к серверу документов.
Если требуется больше, рассмотрите вопрос о покупке коммерческой лицензии.", "SSE.Controllers.Main.warnNoLicenseUsers": "Эта версия редакторов %1 имеет некоторые ограничения по числу одновременно работающих пользователей.
Если требуется больше, рассмотрите вопрос о покупке коммерческой лицензии.", "SSE.Controllers.Main.warnProcessRightsChange": "Вам было отказано в праве на редактирование этого файла.", + "SSE.Controllers.Main.txtColumn": "Столбец", + "SSE.Controllers.Main.txtRow": "Строка", "SSE.Controllers.Print.strAllSheets": "Все листы", "SSE.Controllers.Print.textWarning": "Предупреждение", "SSE.Controllers.Print.txtCustom": "Пользовательская", From 4a8c147701fcca883caa1dbefb23420d727a0441 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 1 Nov 2019 16:43:05 +0300 Subject: [PATCH 10/28] [SSE] Lock sort buttons when sheet is locked --- apps/spreadsheeteditor/main/app/controller/DataTab.js | 2 +- apps/spreadsheeteditor/main/app/view/DataTab.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index abef13c776..789e238ea0 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -262,7 +262,7 @@ define([ onWorksheetLocked: function(index,locked) { if (index == this.api.asc_getActiveWorksheetIndex()) { - Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: [this.view.btnGroup, this.view.btnUngroup]}); + Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort, this.view.btnGroup, this.view.btnUngroup)}); } }, diff --git a/apps/spreadsheeteditor/main/app/view/DataTab.js b/apps/spreadsheeteditor/main/app/view/DataTab.js index 3469726b51..d605bfc010 100644 --- a/apps/spreadsheeteditor/main/app/view/DataTab.js +++ b/apps/spreadsheeteditor/main/app/view/DataTab.js @@ -170,16 +170,16 @@ define([ iconCls: 'btn-to-columns', caption: this.capBtnTextCustomSort, disabled: true, - lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter] + lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock] }); Common.Utils.injectComponent($host.find('#slot-btn-custom-sort'), this.btnCustomSort); this.lockedControls.push(this.btnCustomSort); this.btnsSortDown = Common.Utils.injectButtons($host.find('.slot-sortdesc'), '', 'btn-sort-down', '', - [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter]); + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock]); this.btnsSortUp = Common.Utils.injectButtons($host.find('.slot-sortasc'), '', 'btn-sort-up', '', - [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter]); + [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter, _set.sheetLock]); this.btnsSetAutofilter = Common.Utils.injectButtons($host.find('.slot-btn-setfilter'), '', 'btn-autofilter', '', [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter], From e71e4a74ba35d827e3fb85983a4d5706a018b0a8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 1 Nov 2019 17:08:30 +0300 Subject: [PATCH 11/28] [SSE] Disable some sort settings for filter/table --- apps/spreadsheeteditor/main/app/view/SortDialog.js | 3 ++- .../main/app/view/SortOptionsDialog.js | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 497663f299..368946aafe 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -156,7 +156,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortOptions = { headers: props.asc_getHasHeaders(), // sensitive: props.asc_getCaseSensitive(), - sortcol: props.asc_getColumnSort() + sortcol: props.asc_getColumnSort(), + infilter: !!props.asc_getFilterInside() }; this.lblColumn.text(props.asc_getColumnSort() ? this.textColumn : this.textRow); diff --git a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js index 542f2e00a7..471837f728 100644 --- a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js @@ -115,10 +115,9 @@ define([ this.radioTop = new Common.UI.RadioBox({ el: $('#sort-options-radio-row'), labelText: this.textTopBottom, - name: 'asc-radio-sort-orient', - checked: true + name: 'asc-radio-sort-orient' }).on('change', _.bind(function(field, newValue, eOpts) { - newValue && this.chHeaders.setDisabled(false); + newValue && this.chHeaders.setDisabled(this.props.infilter); }, this)); this.radioLeft = new Common.UI.RadioBox({ @@ -140,12 +139,13 @@ define([ if (props) { this.chHeaders.setValue(props.headers); this.chCase.setValue(props.sensitive); - (props.sortcol) ? this.radioTop.setValue(true) : this.radioLeft.setValue(true); + (props.sortcol || props.infilter) ? this.radioTop.setValue(true) : this.radioLeft.setValue(true); + this.radioLeft.setDisabled(props.infilter); } }, getSettings: function () { - return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), sensitive: this.chCase.getValue()=='checked', sortcol: this.radioTop.getValue()}; + return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), sensitive: this.chCase.getValue()=='checked', sortcol: this.radioTop.getValue(), infilter: this.props.infilter}; }, textTitle: 'Sort Options', From db9754552dbfe1bb634053b61e530d9c31e25a02 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 1 Nov 2019 17:09:25 +0300 Subject: [PATCH 12/28] RadioBox: fix disabled state --- apps/common/main/lib/component/RadioBox.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/common/main/lib/component/RadioBox.js b/apps/common/main/lib/component/RadioBox.js index 9e8e2d1597..b14082b517 100644 --- a/apps/common/main/lib/component/RadioBox.js +++ b/apps/common/main/lib/component/RadioBox.js @@ -111,6 +111,7 @@ define([ return; if (disabled !== this.disabled) { + this.$label.toggleClass('disabled', disabled); this.$radio.toggleClass('disabled', disabled); (disabled) ? this.$radio.attr({disabled: disabled}) : this.$radio.removeAttr('disabled'); } From b4c9a098ec14dd16333678feac3555ada7d98896 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 22 Nov 2019 17:38:04 +0300 Subject: [PATCH 13/28] Add ComboBoxColor component --- .../main/lib/component/ComboBorderSize.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/apps/common/main/lib/component/ComboBorderSize.js b/apps/common/main/lib/component/ComboBorderSize.js index a22123a92a..8f76db4fa4 100644 --- a/apps/common/main/lib/component/ComboBorderSize.js +++ b/apps/common/main/lib/component/ComboBorderSize.js @@ -268,4 +268,71 @@ define([ formcontrol.css('background-position', '0 -' + record.get('offsety') + 'px'); } }, Common.UI.ComboBorderType || {})); + + Common.UI.ComboBoxColor = Common.UI.ComboBox.extend(_.extend({ + template: _.template([ + '
', + '
', + '
', + '
', + '', + '', + '
' + ].join('')), + + itemClicked: function (e) { + var el = $(e.currentTarget).parent(); + + this._selectedItem = this.store.findWhere({ + id: el.attr('id') + }); + if (this._selectedItem) { + $('.selected', $(this.el)).removeClass('selected'); + el.addClass('selected'); + this.updateFormControl(this._selectedItem); + + this.trigger('selected', this, _.extend({}, this._selectedItem.toJSON()), e); + e.preventDefault(); + } + }, + + updateFormControl: function(record) { + var formcontrol = $(this.el).find('.form-control > div'); + + if (record.get('value')!=-1) { + formcontrol[0].innerHTML = ''; + formcontrol.css({'background': '#' + record.get('value'), 'margin-top': '0'}); + } else { + formcontrol[0].innerHTML = record.get('displayValue'); + formcontrol.css({'background': '', 'margin-top': '1px'}); + } + }, + + setValue: function(value) { + var obj; + this._selectedItem = this.store.findWhere((obj={}, obj[this.valueField]=value, obj)); + + $('.selected', $(this.el)).removeClass('selected'); + + if (this._selectedItem) { + this.updateFormControl(this._selectedItem); + $('#' + this._selectedItem.get('id'), $(this.el)).addClass('selected'); + } else { + var formcontrol = $(this.el).find('.form-control > div'); + formcontrol[0].innerHTML = ''; + formcontrol.css('background', ''); + } + } + }, Common.UI.ComboBoxColor || {})); + }); \ No newline at end of file From f6ad6e730718a82e041b121ccb3ac93c14fee2da Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 22 Nov 2019 17:40:08 +0300 Subject: [PATCH 14/28] [SSE] Add sort by color --- .../main/app/view/SortDialog.js | 61 +++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 368946aafe..66f17f8a3c 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -97,9 +97,14 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', template: _.template(['
'].join('')), itemTemplate: _.template([ '
', - '
', - '
', - '
', + '
', + '
', + '<% if (sort==Asc.c_oAscSortOptions.ByColorFill || sort==Asc.c_oAscSortOptions.ByColorFont) { %>', + '
', + '
', + '<% } else { %>', + '
', + '<% } %>', '
' ].join('')) }); @@ -257,6 +262,21 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', (val!==null) && combo.setValue(val); level.cmbSort = combo; + var sort = item.get('sort'); + if (sort==Asc.c_oAscSortOptions.ByColorFill || sort==Asc.c_oAscSortOptions.ByColorFont) { + combo = new Common.UI.ComboBoxColor({ + el : cmpEl.find('#sort-dialog-btn-color-' + i), + editable : false, + menuCls : 'menu-absolute', + data : level.color_data + }).on('selected', function(combo, record) { + item.set('color', record.value); + }); + val = item.get('color'); + (val!==null) && combo.setValue(val); + level.cmbColor = combo; + } + el = cmpEl.find('#sort-dialog-cmb-order-' + i); combo = new Common.UI.ComboBox({ el : el, @@ -304,10 +324,10 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', levelIndex = item.get('levelIndex'); item.set('columnIndex', columnIndex, {silent: true} ); item.set('order', Asc.c_oAscSortOptions.Ascending, {silent: true} ); + item.set('color', -1, {silent: true} ); me.levels[levelIndex].levelProps = (columnIndex!==null) ? me.props.asc_getLevelProps(columnIndex) : undefined; me.addControls(null, null, item); me.updateOrderList(levelIndex); - }); }, @@ -386,6 +406,28 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', ]; level.cmbOrder.setData(level.order_data); level.cmbOrder.setValue(order); + + if (iscolor) { + level.color_data = [{ value: -1, displayValue: (level.cmbSort.getValue()==Asc.c_oAscSortOptions.ByColorFill) ? this.textNone : this.textAuto , color: null}]; + if (level.levelProps) { + var levelColors = (level.cmbSort.getValue()==Asc.c_oAscSortOptions.ByColorFill) ? level.levelProps.asc_getColorsFill() : level.levelProps.asc_getColorsFont(); + levelColors.forEach(function(item, index) { + item && level.color_data.push({ + value: Common.Utils.ThemeColor.getHexColor(item.get_r(), item.get_g(), item.get_b()).toLocaleUpperCase(), + displayValue: Common.Utils.ThemeColor.getHexColor(item.get_r(), item.get_g(), item.get_b()).toLocaleUpperCase(), + color: item + }); + }); + } + level.cmbColor.setData(level.color_data); + level.cmbColor.setDisabled(level.color_data.length<1); + (level.color_data.length>0) && level.cmbColor.setValue(level.color_data[0].value); + + var item = this.sortList.store.at(levelIndex); + if (item) { + item.set('color', -1); + } + } }, getSettings: function() { @@ -404,7 +446,12 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', level.asc_setIndex(columnIndex); level.asc_setSortBy(levelProp.cmbSort.getValue()); level.asc_setDescending(levelProp.cmbOrder.getValue()); - // level.asc_setColor(level.color); + if (levelProp.cmbSort.getValue() == Asc.c_oAscSortOptions.ByColorFill || levelProp.cmbSort.getValue()==Asc.c_oAscSortOptions.ByColorFont) { + var rec = levelProp.cmbColor.getSelectedRecord(); + if (rec) { + level.asc_setColor(rec.color); + } + } arr.push(level); } }); @@ -466,7 +513,9 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', textBelow: 'Below', textLeft: 'Left', textRight: 'Right', - errorEmpty: 'All sort criteria must have a column or row specified.' + errorEmpty: 'All sort criteria must have a column or row specified.', + textAuto: 'Automatic', + textNone: 'None' }, SSE.Views.SortDialog || {})); }); \ No newline at end of file From 39f6b9123bbe7fd23f69cc80532c5836a512aeda Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 22 Nov 2019 17:46:48 +0300 Subject: [PATCH 15/28] [SSE] Change lock for sort options --- apps/spreadsheeteditor/main/app/view/SortDialog.js | 3 ++- apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 66f17f8a3c..f3d67c4420 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -162,7 +162,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', headers: props.asc_getHasHeaders(), // sensitive: props.asc_getCaseSensitive(), sortcol: props.asc_getColumnSort(), - infilter: !!props.asc_getFilterInside() + lockHeaders: !!props.asc_getLockChangeHeaders(), + lockOrientation: !!props.asc_getLockChangeOrientation() }; this.lblColumn.text(props.asc_getColumnSort() ? this.textColumn : this.textRow); diff --git a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js index 471837f728..7fb804652d 100644 --- a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js @@ -117,7 +117,7 @@ define([ labelText: this.textTopBottom, name: 'asc-radio-sort-orient' }).on('change', _.bind(function(field, newValue, eOpts) { - newValue && this.chHeaders.setDisabled(this.props.infilter); + newValue && this.chHeaders.setDisabled(this.props.lockHeaders); }, this)); this.radioLeft = new Common.UI.RadioBox({ @@ -139,13 +139,13 @@ define([ if (props) { this.chHeaders.setValue(props.headers); this.chCase.setValue(props.sensitive); - (props.sortcol || props.infilter) ? this.radioTop.setValue(true) : this.radioLeft.setValue(true); - this.radioLeft.setDisabled(props.infilter); + (props.sortcol || props.lockOrientation) ? this.radioTop.setValue(true) : this.radioLeft.setValue(true); + this.radioLeft.setDisabled(props.lockOrientation); } }, getSettings: function () { - return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), sensitive: this.chCase.getValue()=='checked', sortcol: this.radioTop.getValue(), infilter: this.props.infilter}; + return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), sensitive: this.chCase.getValue()=='checked', sortcol: this.radioTop.getValue(), lockHeaders: this.props.lockHeaders, lockOrientation: this.props.lockOrientation}; }, textTitle: 'Sort Options', From 9a1ed5cf706b0859c410497a22a52089085f40c8 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 26 Nov 2019 10:37:44 +0300 Subject: [PATCH 16/28] Fix ComboBoxColor component --- .../main/lib/component/ComboBorderSize.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/apps/common/main/lib/component/ComboBorderSize.js b/apps/common/main/lib/component/ComboBorderSize.js index 8f76db4fa4..8f01b70713 100644 --- a/apps/common/main/lib/component/ComboBorderSize.js +++ b/apps/common/main/lib/component/ComboBorderSize.js @@ -332,7 +332,44 @@ define([ formcontrol[0].innerHTML = ''; formcontrol.css('background', ''); } + }, + + onResetItems: function() { + if (this.itemsTemplate) { + $(this.el).find('ul').html( $(this.itemsTemplate({ + items: this.store.toJSON(), + scope: this + }))); + } else { + $(this.el).find('ul').html(_.template([ + '<% _.each(items, function(item) { %>', + '<% if (item.value==-1) { %>', + '
  • <%= scope.getDisplayValue(item) %>
  • ', + '<% } else { %>', + '
  • ', + '
    ', + '
  • ', + '<% } %>', + '<% }); %>' + ].join(''))({ + items: this.store.toJSON(), + scope: this + })); + } + + if (!_.isUndefined(this.scroller)) { + this.scroller.destroy(); + delete this.scroller; + } + this.scroller = new Common.UI.Scroller(_.extend({ + el: $('.dropdown-menu', this.cmpEl), + minScrollbarLength : 40, + includePadding : true, + wheelSpeed: 10, + alwaysVisibleY: this.scrollAlwaysVisible + }, this.options.scroller)); } + }, Common.UI.ComboBoxColor || {})); }); \ No newline at end of file From 48fe19c588414c545e1d08d8aa21b178f3b73bf3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 26 Nov 2019 10:39:44 +0300 Subject: [PATCH 17/28] [SSE] Refactoring sort settings (select data in combobox, add limit for rows/columns) --- apps/common/main/lib/component/ListView.js | 8 ++- .../main/app/view/SortDialog.js | 61 ++++++++++++++----- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/apps/common/main/lib/component/ListView.js b/apps/common/main/lib/component/ListView.js index e1a565af61..080d6e15f8 100644 --- a/apps/common/main/lib/component/ListView.js +++ b/apps/common/main/lib/component/ListView.js @@ -67,11 +67,15 @@ define([ this.trigger('items:reset', this); }, - onAddItem: function(record, store, opts) { - var view = new Common.UI.DataViewItem({ + createNewItem: function(record) { + return new Common.UI.DataViewItem({ template: this.itemTemplate, model: record }); + }, + + onAddItem: function(record, store, opts) { + var view = this.createNewItem(record); if (!this.innerEl) this.innerEl = $(this.el).find('.inner'); diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index f3d67c4420..8a9199929d 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -49,7 +49,29 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', SSE.Views = SSE.Views || {}; + var _CustomItem = Common.UI.DataViewItem.extend({ + initialize : function(options) { + Common.UI.BaseView.prototype.initialize.call(this, options); + + var me = this; + + me.template = me.options.template || me.template; + + me.listenTo(me.model, 'change:sort', function() { + me.render(); + me.trigger('change', me, me.model); + }); + me.listenTo(me.model, 'change:selected', function() { + var el = me.$el || $(me.el); + el.toggleClass('selected', me.model.get('selected') && me.model.get('allowSelected')); + me.onSelectChange(); + }); + me.listenTo(me.model, 'remove', me.remove); + } + }); + SSE.Views.SortDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { alias: 'SortDialog', contentWidth: 500, @@ -94,9 +116,10 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', el: $('#sort-dialog-list', this.$window), store: new Common.UI.DataViewStore(), emptyText: '', + enableKeyEvents: false, template: _.template(['
    '].join('')), itemTemplate: _.template([ - '
    ', + '
    ', '
    ', '
    ', '<% if (sort==Asc.c_oAscSortOptions.ByColorFill || sort==Asc.c_oAscSortOptions.ByColorFont) { %>', @@ -108,6 +131,12 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', '
    ' ].join('')) }); + this.sortList.createNewItem = function(record) { + return new _CustomItem({ + template: this.itemTemplate, + model: record + }); + }; this.sortList.on('item:select', _.bind(this.onSelectLevel, this)) .on('item:keydown', _.bind(this.onKeyDown, this)); @@ -170,8 +199,9 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', // get name from props this.column_data = []; - var values = props.asc_getSortList(); - for (var i=0; i Date: Tue, 26 Nov 2019 12:46:04 +0300 Subject: [PATCH 18/28] [SSE] Hide case sensitive option for sorting --- .../main/app/view/SortOptionsDialog.js | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js index 7fb804652d..3dae5613cf 100644 --- a/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortOptionsDialog.js @@ -48,7 +48,7 @@ define([ SSE.Views.SortOptionsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { contentWidth: 230, - height: 225 + height: 200 }, initialize : function(options) { @@ -62,15 +62,15 @@ define([ '
    ', '', '', - '', '', - '', - '', - '', + // '', + // '', + // '', '', ' diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 8a9199929d..461b632418 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -236,12 +236,26 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', order: level.asc_getDescending(), color: level.asc_getColor() }); + if (iscolor) { + var color_data = [{ value: -1, displayValue: (level.asc_getSortBy()==Asc.c_oAscSortOptions.ByColorFill) ? this.textNone : this.textAuto , color: null}]; + if (levelProps) { + var levelColors = (level.asc_getSortBy()==Asc.c_oAscSortOptions.ByColorFill) ? levelProps.asc_getColorsFill() : levelProps.asc_getColorsFont(); + levelColors.forEach(function(item, index) { + item && color_data.push({ + value: Common.Utils.ThemeColor.getHexColor(item.get_r(), item.get_g(), item.get_b()).toLocaleUpperCase(), + displayValue: Common.Utils.ThemeColor.getHexColor(item.get_r(), item.get_g(), item.get_b()).toLocaleUpperCase(), + color: item + }); + }); + } + } this.levels[i] = { levelProps: levelProps, order_data: [ { value: Asc.c_oAscSortOptions.Ascending, displayValue: (iscolor) ? (this.sortOptions.sortcol ? this.textTop : this.textLeft) : (istext ? this.textAZ : this.textAsc) }, { value: Asc.c_oAscSortOptions.Descending, displayValue: (iscolor) ? (this.sortOptions.sortcol ? this.textBelow : this.textRight): (istext ? this.textZA : this.textDesc)} - ] + ], + color_data: color_data }; } this.sortList.store.reset(arr); @@ -300,10 +314,10 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', menuStyle : 'max-height: 135px;', data : level.color_data }).on('selected', function(combo, record) { - item.set('color', record.value); + item.set('color', record.color); }); val = item.get('color'); - (val!==null) && combo.setValue(val); + combo.setValue(val ? Common.Utils.ThemeColor.getHexColor(val.get_r(), val.get_g(), val.get_b()).toLocaleUpperCase() : -1); level.cmbColor = combo; } @@ -358,7 +372,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', levelIndex = item.get('levelIndex'); item.set('columnIndex', columnIndex, {silent: true} ); item.set('order', Asc.c_oAscSortOptions.Ascending, {silent: true} ); - item.set('color', -1, {silent: true} ); + item.set('color', null, {silent: true} ); me.levels[levelIndex].levelProps = (columnIndex!==null) ? me.props.asc_getLevelProps(columnIndex) : undefined; me.addControls(null, null, item); me.updateOrderList(levelIndex); @@ -459,7 +473,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', var item = this.sortList.store.at(levelIndex); if (item) { - item.set('color', -1); + item.set('color', null); } } }, From 9ee1fd00b4709f12f05792d20785a2bb61da7448 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 27 Nov 2019 14:40:32 +0300 Subject: [PATCH 20/28] [SSE] Sort dialog: select cells range for custom rows/columns --- .../main/app/view/CellRangeDialog.js | 3 +- .../main/app/view/SortDialog.js | 86 ++++++++++++++++--- 2 files changed, 76 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js index 3e140366b8..19c89d13b0 100644 --- a/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js +++ b/apps/spreadsheeteditor/main/app/view/CellRangeDialog.js @@ -155,7 +155,8 @@ define([ if (this.inputRange.checkValidate() !== true) return; } - this.options.handler.call(this, this, state); + if (this.options.handler.call(this, this, state)) + return; } this.close(); diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 461b632418..60ee94a1a3 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -198,12 +198,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.lblColumn.text(props.asc_getColumnSort() ? this.textColumn : this.textRow); // get name from props - this.column_data = []; - var values = props.asc_getSortList(), - len = Math.min(values.length, 500); - for (var i=0; i500) + this.column_data.push({ value: -1, displayValue: '(' + (this.sortOptions.sortcol ? this.textMoreCols : this.textMoreRows) + '...)' }); + }, + + updateSortValues: function() { + this.fillSortValues(); var me = this; this.sortList.store.each(function(item) { var columnIndex = (item.get('sort')==Asc.c_oAscSortOptions.ByValue) ? null : 0, @@ -538,6 +546,53 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnDown.setDisabled(index<0 || index==this.sortList.store.length-1); }, + onSelectOther: function(combo, item) { + var me = this; + if (me.api) { + var handlerDlg = function(dlg, result) { + if (result == 'ok') { + var range = dlg.getSettings(); + var isvalid; + if (!_.isEmpty(range)) { + isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.CustomSort, range, true, !this.sortOptions.sortcol); + } + + if (isvalid == Asc.c_oAscError.ID.No) { + var index = me.props.asc_addBySortList(range); + me.fillSortValues(); + combo.setData(this.column_data); + combo.setValue(index); + item.set('columnIndex', index); + this.levels[item.get('levelIndex')].levelProps = me.props.asc_getLevelProps(index); + me.updateOrderList(item.get('levelIndex')); + return false; + } else if (isvalid == Asc.c_oAscError.ID.CustomSortMoreOneSelectedError) + Common.UI.warning({msg: this.sortOptions.sortcol ? this.errorMoreOneCol: this.errorMoreOneRow}); + else if (isvalid == Asc.c_oAscError.ID.CustomSortNotOriginalSelectError) + Common.UI.warning({msg: this.sortOptions.sortcol ? this.errorNotOriginalCol : this.errorNotOriginalRow}); + else + Common.UI.warning({msg: this.txtInvalidRange}); + return true; + } + }; + + var win = new SSE.Views.CellRangeDialog({ + handler: handlerDlg + }).on('close', function() { + me.show(); + }); + + var xy = me.$window.offset(); + me.hide(); + win.show(xy.left + 65, xy.top + 77); + win.setSettings({ + api : me.api, + range : me.props.asc_getRangeStr(), + type : Asc.c_oAscSelectionDialogType.CustomSort + }); + } + }, + txtTitle: 'Sort', textAdd: 'Add level', textDelete: 'Delete level', @@ -563,7 +618,14 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', textRight: 'Right', errorEmpty: 'All sort criteria must have a column or row specified.', textAuto: 'Automatic', - textNone: 'None' + textNone: 'None', + errorNotOriginalCol: 'The column you selected is not in the original selected range.', + errorNotOriginalRow: 'The row you selected is not in the original selected range.', + errorMoreOneRow: 'More than one row is selected.', + errorMoreOneCol: 'More than one column is selected.', + txtInvalidRange: 'Invalid cells range.', + textMoreRows: 'More rows', + textMoreCols: 'More columns' }, SSE.Views.SortDialog || {})); }); \ No newline at end of file From 1c21971194735cc84ee5646a01b5de1b02889a14 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Nov 2019 14:47:10 +0300 Subject: [PATCH 21/28] [SSE] Refactoring sort settings --- .../main/app/view/SortDialog.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 60ee94a1a3..8f4e3a52d6 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -348,12 +348,12 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', props: me.sortOptions, handler : function(result, settings) { if (result == 'ok' && settings) { - me.sortOptions = settings; me.lblColumn.text(settings.sortcol ? me.textColumn : me.textRow); me.props.asc_setHasHeaders(settings.headers); // me.props.asc_setCaseSensitive(settings.sensitive); me.props.asc_setColumnSort(settings.sortcol); - me.props.asc_updateSortList(); + me.props.asc_updateSortList(me.sortOptions.sortcol == settings.sortcol); + me.sortOptions = settings; me.updateSortValues(); } } @@ -554,24 +554,24 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', var range = dlg.getSettings(); var isvalid; if (!_.isEmpty(range)) { - isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.CustomSort, range, true, !this.sortOptions.sortcol); + isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.CustomSort, range, true, !me.sortOptions.sortcol); } if (isvalid == Asc.c_oAscError.ID.No) { var index = me.props.asc_addBySortList(range); me.fillSortValues(); - combo.setData(this.column_data); + combo.setData(me.column_data); combo.setValue(index); item.set('columnIndex', index); - this.levels[item.get('levelIndex')].levelProps = me.props.asc_getLevelProps(index); + me.levels[item.get('levelIndex')].levelProps = me.props.asc_getLevelProps(index); me.updateOrderList(item.get('levelIndex')); return false; } else if (isvalid == Asc.c_oAscError.ID.CustomSortMoreOneSelectedError) - Common.UI.warning({msg: this.sortOptions.sortcol ? this.errorMoreOneCol: this.errorMoreOneRow}); + Common.UI.warning({msg: me.sortOptions.sortcol ? me.errorMoreOneCol: me.errorMoreOneRow}); else if (isvalid == Asc.c_oAscError.ID.CustomSortNotOriginalSelectError) - Common.UI.warning({msg: this.sortOptions.sortcol ? this.errorNotOriginalCol : this.errorNotOriginalRow}); + Common.UI.warning({msg: me.sortOptions.sortcol ? me.errorNotOriginalCol : me.errorNotOriginalRow}); else - Common.UI.warning({msg: this.txtInvalidRange}); + Common.UI.warning({msg: me.txtInvalidRange}); return true; } }; From 5a4fe3df9f3ce1f79e91881ae652f372a4708612 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Nov 2019 15:35:17 +0300 Subject: [PATCH 22/28] [SSE] Refactoring sort settings --- apps/spreadsheeteditor/main/app/view/SortDialog.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 8f4e3a52d6..161635143b 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -366,9 +366,10 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', len = values.length; this.column_data = []; for (var i=0; i500) + if (this.column_data.length>500) this.column_data.push({ value: -1, displayValue: '(' + (this.sortOptions.sortcol ? this.textMoreCols : this.textMoreRows) + '...)' }); }, From 308aab692f8fd4bd4f1b16846f1d3106fe5dacd6 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Nov 2019 15:51:38 +0300 Subject: [PATCH 23/28] [SSE] Update translation --- .../main/app/view/SortDialog.js | 1 - apps/spreadsheeteditor/main/locale/en.json | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 161635143b..fd8ad26eb6 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -608,7 +608,6 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', textValues: 'Values', textCellColor: 'Cell color', textFontColor: 'Font color', - textCellIcon: 'Cell icon', textAZ: 'A to Z', textZA: 'Z to A', textDesc: 'Descending', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index b1889b9385..e5c7ed962f 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1367,6 +1367,8 @@ "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.capBtnTextCustomSort": "Custom Sort", + "SSE.Views.DataTab.tipCustomSort": "Custom sort", "SSE.Views.DigitalFilterDialog.capAnd": "And", "SSE.Views.DigitalFilterDialog.capCondition1": "equals", "SSE.Views.DigitalFilterDialog.capCondition10": "does not end with", @@ -2083,6 +2085,38 @@ "SSE.Views.Spellcheck.txtDictionaryLanguage": "Dictionary Language", "SSE.Views.Spellcheck.txtNextTip": "Go to the next word", "SSE.Views.Spellcheck.txtSpelling": "Spelling", + "SSE.Views.SortDialog.txtTitle": "Sort", + "SSE.Views.SortDialog.textAdd": "Add level", + "SSE.Views.SortDialog.textDelete": "Delete level", + "SSE.Views.SortDialog.textCopy": "Copy level", + "SSE.Views.SortDialog.textColumn": "Column", + "SSE.Views.SortDialog.textRow": "Row", + "SSE.Views.SortDialog.textSort": "Sort on", + "SSE.Views.SortDialog.textOrder": "Order", + "SSE.Views.SortDialog.textUp": "Move level up", + "SSE.Views.SortDialog.textDown": "Move level down", + "SSE.Views.SortDialog.textOptions": "Options", + "SSE.Views.SortDialog.textValues": "Values", + "SSE.Views.SortDialog.textCellColor": "Cell color", + "SSE.Views.SortDialog.textFontColor": "Font color", + "SSE.Views.SortDialog.textAZ": "A to Z", + "SSE.Views.SortDialog.textZA": "Z to A", + "SSE.Views.SortDialog.textDesc": "Descending", + "SSE.Views.SortDialog.textAsc": "Ascending", + "SSE.Views.SortDialog.textTop": "Top", + "SSE.Views.SortDialog.textBelow": "Below", + "SSE.Views.SortDialog.textLeft": "Left", + "SSE.Views.SortDialog.textRight": "Right", + "SSE.Views.SortDialog.errorEmpty": "All sort criteria must have a column or row specified.", + "SSE.Views.SortDialog.textAuto": "Automatic", + "SSE.Views.SortDialog.textNone": "None", + "SSE.Views.SortDialog.errorNotOriginalCol": "The column you selected is not in the original selected range.", + "SSE.Views.SortDialog.errorNotOriginalRow": "The row you selected is not in the original selected range.", + "SSE.Views.SortDialog.errorMoreOneRow": "More than one row is selected.", + "SSE.Views.SortDialog.errorMoreOneCol": "More than one column is selected.", + "SSE.Views.SortDialog.txtInvalidRange": "Invalid cells range.", + "SSE.Views.SortDialog.textMoreRows": "More rows", + "SSE.Views.SortDialog.textMoreCols": "More columns", "SSE.Views.Statusbar.CopyDialog.itemCopyToEnd": "(Copy to end)", "SSE.Views.Statusbar.CopyDialog.itemMoveToEnd": "(Move to end)", "SSE.Views.Statusbar.CopyDialog.textCopyBefore": "Copy before sheet", From ad4f70949f785357038f544dc8ee1764bd451a20 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Nov 2019 16:00:41 +0300 Subject: [PATCH 24/28] [SSE] Sort dialog: add empty level when cells are not sorted --- .../spreadsheeteditor/main/app/view/SortDialog.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index fd8ad26eb6..3d6a42f324 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -218,8 +218,9 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', refreshList: function(levels) { this.levels = []; + + var arr = []; if (levels) { - var arr = []; for (var i=0; i0) && this.sortList.selectByIndex(0); + } else { + arr.push({ + columnIndex: null, + levelIndex: 0, + sort: Asc.c_oAscSortOptions.ByValue, + order: Asc.c_oAscSortOptions.Ascending + }); } + this.sortList.store.reset(arr); + (this.sortList.store.length>0) && this.sortList.selectByIndex(0); + this.updateButtons(); }, From dfd52d388607e9bd7e92996ccbdf693e48b84ac3 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Nov 2019 17:33:54 +0300 Subject: [PATCH 25/28] [SSE] Refactoring sort settings --- apps/spreadsheeteditor/main/app/view/SortDialog.js | 8 ++++---- apps/spreadsheeteditor/main/locale/en.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 3d6a42f324..f985c7c00a 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -378,8 +378,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', if (values[i]==undefined) continue; this.column_data.push({ value: i, displayValue: values[i] }); } - if (this.column_data.length>500) - this.column_data.push({ value: -1, displayValue: '(' + (this.sortOptions.sortcol ? this.textMoreCols : this.textMoreRows) + '...)' }); + if (this.column_data.length>=500) + this.column_data.push({ value: -1, displayValue: this.sortOptions.sortcol ? this.textMoreCols : this.textMoreRows }); }, updateSortValues: function() { @@ -633,8 +633,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', errorMoreOneRow: 'More than one row is selected.', errorMoreOneCol: 'More than one column is selected.', txtInvalidRange: 'Invalid cells range.', - textMoreRows: 'More rows', - textMoreCols: 'More columns' + textMoreRows: '(More rows...)', + textMoreCols: '(More columns...)' }, SSE.Views.SortDialog || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index e5c7ed962f..f90572c3fc 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2115,8 +2115,8 @@ "SSE.Views.SortDialog.errorMoreOneRow": "More than one row is selected.", "SSE.Views.SortDialog.errorMoreOneCol": "More than one column is selected.", "SSE.Views.SortDialog.txtInvalidRange": "Invalid cells range.", - "SSE.Views.SortDialog.textMoreRows": "More rows", - "SSE.Views.SortDialog.textMoreCols": "More columns", + "SSE.Views.SortDialog.textMoreRows": "(More rows...)", + "SSE.Views.SortDialog.textMoreCols": "(More columns...)", "SSE.Views.Statusbar.CopyDialog.itemCopyToEnd": "(Copy to end)", "SSE.Views.Statusbar.CopyDialog.itemMoveToEnd": "(Move to end)", "SSE.Views.Statusbar.CopyDialog.textCopyBefore": "Copy before sheet", From 4b49793b256772ff1cb5e1260017731966903792 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 29 Nov 2019 11:02:00 +0300 Subject: [PATCH 26/28] [SSE] Sort settings: check sort criteria --- .../main/app/view/SortDialog.js | 35 ++++++++++++++++++- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index f985c7c00a..1bd4db483a 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -529,6 +529,37 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', var rec = this.sortList.store.findWhere({columnIndex: null}); if (rec) Common.UI.warning({msg: this.errorEmpty}); + else { + var store = this.sortList.store, + len = store.length; + for (var index=0; index=0; i--) { + var itemcheck = store.at(i), + levelcheck = this.levels[itemcheck.get('levelIndex')]; + if (item.get('columnIndex') == itemcheck.get('columnIndex') && sort == levelcheck.cmbSort.getValue()) { + if (sort == Asc.c_oAscSortOptions.ByColorFill || sort==Asc.c_oAscSortOptions.ByColorFont) { + var colorcheck = levelcheck.cmbColor.getSelectedRecord(); + if (color && colorcheck && color.value == colorcheck.value) { + rec = levelProp.cmbColumn.getSelectedRecord().displayValue; + rec = this.errorSameColumnColor.replace('%1', rec); + break; + } + } else { + rec = levelProp.cmbColumn.getSelectedRecord().displayValue; + rec = this.errorSameColumnValue.replace('%1', rec); + break; + } + } + } + if (rec) + break; + } + rec && Common.UI.warning({msg: rec}); + } return !rec; }, @@ -634,7 +665,9 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', errorMoreOneCol: 'More than one column is selected.', txtInvalidRange: 'Invalid cells range.', textMoreRows: '(More rows...)', - textMoreCols: '(More columns...)' + textMoreCols: '(More columns...)', + errorSameColumnValue: "%1 is being sorted by values more than once.
    Delete the duplicate sort criteria and try again.", + errorSameColumnColor: "%1 is being sorted by the same color more than once.
    Delete the duplicate sort criteria and try again." }, SSE.Views.SortDialog || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index f90572c3fc..1a009da3f9 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2117,6 +2117,8 @@ "SSE.Views.SortDialog.txtInvalidRange": "Invalid cells range.", "SSE.Views.SortDialog.textMoreRows": "(More rows...)", "SSE.Views.SortDialog.textMoreCols": "(More columns...)", + "SSE.Views.SortDialog.errorSameColumnValue": "%1 is being sorted by values more than once.
    Delete the duplicate sort criteria and try again.", + "SSE.Views.SortDialog.errorSameColumnColor": "%1 is being sorted by the same color more than once.
    Delete the duplicate sort criteria and try again.", "SSE.Views.Statusbar.CopyDialog.itemCopyToEnd": "(Copy to end)", "SSE.Views.Statusbar.CopyDialog.itemMoveToEnd": "(Move to end)", "SSE.Views.Statusbar.CopyDialog.textCopyBefore": "Copy before sheet", From ca980870facda48239dc6777d6ae694f2e53f19e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 29 Nov 2019 17:45:09 +0300 Subject: [PATCH 27/28] [SSE] Sort settings: fix copy level --- .../main/app/view/SortDialog.js | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index 1bd4db483a..a161847384 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -295,7 +295,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', } else { item.set('columnIndex', record.value); level.levelProps = me.props.asc_getLevelProps(record.value); - me.updateOrderList(i); + me.updateOrderList(i, item); } }); var val = item.get('columnIndex'); @@ -310,7 +310,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', data : this.sort_data }).on('selected', function(combo, record) { item.set('sort', record.value); - me.updateOrderList(i); + me.updateOrderList(i, item); }); val = item.get('sort'); (val!==null) && combo.setValue(val); @@ -329,6 +329,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', }); val = item.get('color'); combo.setValue(val ? Common.Utils.ThemeColor.getHexColor(val.get_r(), val.get_g(), val.get_b()).toLocaleUpperCase() : -1); + var rec = combo.getSelectedRecord(); + rec && item.set('color', rec.color); level.cmbColor = combo; } @@ -393,7 +395,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', item.set('color', null, {silent: true} ); me.levels[levelIndex].levelProps = (columnIndex!==null) ? me.props.asc_getLevelProps(columnIndex) : undefined; me.addControls(null, null, item); - me.updateOrderList(levelIndex); + me.updateOrderList(levelIndex, item); }); }, @@ -415,9 +417,17 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', onCopyLevel: function() { var store = this.sortList.store, - rec = this.sortList.getSelectedRec(); + rec = this.sortList.getSelectedRec(), + levelIndex = this.levels.length, + copyLevel = this.levels[rec ? rec.get('levelIndex') : null]; + + this.levels[levelIndex] = { + levelProps: copyLevel ? copyLevel.levelProps : null, + order_data: copyLevel ? copyLevel.order_data : null, + color_data: copyLevel ? copyLevel.color_data : null + }; rec = store.add({ - levelIndex: this.levels.length, + levelIndex: levelIndex, columnIndex: rec ? rec.get('columnIndex') : null, sort: rec ? rec.get('sort') : Asc.c_oAscSortOptions.ByValue, order: rec ? rec.get('order') : Asc.c_oAscSortOptions.Ascending, @@ -461,7 +471,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.updateMoveButtons(); }, - updateOrderList: function(levelIndex) { + updateOrderList: function(levelIndex, storeItem) { var level = this.levels[levelIndex], istext = level.levelProps ? level.levelProps.asc_getIsTextData() : true, iscolor = (level.cmbSort.getValue() !== Asc.c_oAscSortOptions.ByValue), @@ -489,10 +499,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', level.cmbColor.setDisabled(level.color_data.length<1); (level.color_data.length>0) && level.cmbColor.setValue(level.color_data[0].value); - var item = this.sortList.store.at(levelIndex); - if (item) { - item.set('color', null); - } + storeItem && storeItem.set('color', null); } }, @@ -605,7 +612,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', combo.setValue(index); item.set('columnIndex', index); me.levels[item.get('levelIndex')].levelProps = me.props.asc_getLevelProps(index); - me.updateOrderList(item.get('levelIndex')); + me.updateOrderList(item.get('levelIndex'), item); return false; } else if (isvalid == Asc.c_oAscError.ID.CustomSortMoreOneSelectedError) Common.UI.warning({msg: me.sortOptions.sortcol ? me.errorMoreOneCol: me.errorMoreOneRow}); From 856b4420b910513c9b7e0d8c4945f3d8c031cd4c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 2 Dec 2019 15:07:56 +0300 Subject: [PATCH 28/28] [SSE] Fix translation for custom sort --- .../main/app/controller/DataTab.js | 14 +++++--------- apps/spreadsheeteditor/main/locale/en.json | 6 ++++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 789e238ea0..1c236b8718 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -221,11 +221,11 @@ define([ if (res) { var config = { width: 500, - title: this.txtSorting, - msg: this.txtExpandSort, + title: this.toolbar.txtSorting, + msg: this.toolbar.txtExpandSort, - buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, - {caption: this.txtSortSelected, primary: true, value: 'sort'}, + buttons: [ {caption: this.toolbar.txtExpand, primary: true, value: 'expand'}, + {caption: this.toolbar.txtSortSelected, primary: true, value: 'sort'}, 'cancel'], callback: function(btn){ if (btn == 'expand' || btn == 'sort') { @@ -273,11 +273,7 @@ define([ this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); }, - textWizard: 'Text to Columns Wizard', - txtExpandSort: 'The data next to the selection will not be sorted. Do you want to expand the selection to include the adjacent data or continue with sorting the currently selected cells only?', - txtExpand: 'Expand and sort', - txtSorting: 'Sorting', - txtSortSelected: 'Sort selected' + textWizard: 'Text to Columns Wizard' }, SSE.Controllers.DataTab || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 1a009da3f9..38ac25523e 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2119,6 +2119,12 @@ "SSE.Views.SortDialog.textMoreCols": "(More columns...)", "SSE.Views.SortDialog.errorSameColumnValue": "%1 is being sorted by values more than once.
    Delete the duplicate sort criteria and try again.", "SSE.Views.SortDialog.errorSameColumnColor": "%1 is being sorted by the same color more than once.
    Delete the duplicate sort criteria and try again.", + "SSE.Views.SortOptionsDialog.textTitle": "Sort Options", + "SSE.Views.SortOptionsDialog.textHeaders": "My data has headers", + "SSE.Views.SortOptionsDialog.textCase": "Case sensitive", + "SSE.Views.SortOptionsDialog.textOrientation": "Orientation", + "SSE.Views.SortOptionsDialog.textTopBottom": "Sort top to bottom", + "SSE.Views.SortOptionsDialog.textLeftRight": "Sort left to right", "SSE.Views.Statusbar.CopyDialog.itemCopyToEnd": "(Copy to end)", "SSE.Views.Statusbar.CopyDialog.itemMoveToEnd": "(Move to end)", "SSE.Views.Statusbar.CopyDialog.textCopyBefore": "Copy before sheet",
    ', + '', '
    ', '
    ', - '
    ', - '
    ', + // '
    ', + // '
    ', '', @@ -100,17 +100,16 @@ define([ render: function() { Common.Views.AdvancedSettingsWindow.prototype.render.call(this); - var me = this; this.chHeaders = new Common.UI.CheckBox({ el: $('#sort-options-chk-headers'), labelText: this.textHeaders }); - this.chCase = new Common.UI.CheckBox({ - el: $('#sort-options-chk-case'), - labelText: this.textCase - }); + // this.chCase = new Common.UI.CheckBox({ + // el: $('#sort-options-chk-case'), + // labelText: this.textCase + // }); this.radioTop = new Common.UI.RadioBox({ el: $('#sort-options-radio-row'), @@ -138,14 +137,14 @@ define([ _setDefaults: function (props) { if (props) { this.chHeaders.setValue(props.headers); - this.chCase.setValue(props.sensitive); + // this.chCase.setValue(props.sensitive); (props.sortcol || props.lockOrientation) ? this.radioTop.setValue(true) : this.radioLeft.setValue(true); this.radioLeft.setDisabled(props.lockOrientation); } }, getSettings: function () { - return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), sensitive: this.chCase.getValue()=='checked', sortcol: this.radioTop.getValue(), lockHeaders: this.props.lockHeaders, lockOrientation: this.props.lockOrientation}; + return {headers: this.radioTop.getValue() && (this.chHeaders.getValue()=='checked'), /*sensitive: this.chCase.getValue()=='checked',*/ sortcol: this.radioTop.getValue(), lockHeaders: this.props.lockHeaders, lockOrientation: this.props.lockOrientation}; }, textTitle: 'Sort Options', From 452cbf26035af6c703f13957536cf1445ec969f1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 26 Nov 2019 12:46:58 +0300 Subject: [PATCH 19/28] [SSE] Fix settings for sorting by color --- .../main/app/template/SortDialog.template | 4 ++-- .../main/app/view/SortDialog.js | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/template/SortDialog.template b/apps/spreadsheeteditor/main/app/template/SortDialog.template index 6c4009ed8b..d4f8168b90 100644 --- a/apps/spreadsheeteditor/main/app/template/SortDialog.template +++ b/apps/spreadsheeteditor/main/app/template/SortDialog.template @@ -13,8 +13,8 @@
    - - + +