From 45304408a7db9855101f14fc1f9a702602640fbc Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 Dec 2019 10:18:57 +0300 Subject: [PATCH] [SSE] Change layout for sort dialog --- .../main/app/template/SortDialog.template | 4 +- .../main/app/view/SortDialog.js | 63 +++++++++++++++---- apps/spreadsheeteditor/main/locale/en.json | 4 +- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/template/SortDialog.template b/apps/spreadsheeteditor/main/app/template/SortDialog.template index d4f8168b9..f06364964 100644 --- a/apps/spreadsheeteditor/main/app/template/SortDialog.template +++ b/apps/spreadsheeteditor/main/app/template/SortDialog.template @@ -13,8 +13,8 @@ - - + + diff --git a/apps/spreadsheeteditor/main/app/view/SortDialog.js b/apps/spreadsheeteditor/main/app/view/SortDialog.js index b78defbb3..255baed32 100644 --- a/apps/spreadsheeteditor/main/app/view/SortDialog.js +++ b/apps/spreadsheeteditor/main/app/view/SortDialog.js @@ -74,7 +74,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', options: { alias: 'SortDialog', - contentWidth: 500, + contentWidth: 560, height: 294, buttons: ['ok', 'cancel'] }, @@ -112,6 +112,14 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', Common.Views.AdvancedSettingsWindow.prototype.render.call(this); var me = this; + var span = $(''); + me.$window.append(span); + span.text(this.textSortBy); + var captionWidth = span.width(); + span.text(this.textThenBy); + captionWidth = Math.ceil(Math.max(captionWidth, span.width()))+10; + span.remove(); + this.sortList = new Common.UI.ListView({ el: $('#sort-dialog-list', this.$window), store: new Common.UI.DataViewStore(), @@ -119,15 +127,18 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', enableKeyEvents: false, template: _.template(['
'].join('')), itemTemplate: _.template([ - '
', - '
', - '
', - '<% if (sort==Asc.c_oAscSortOptions.ByColorFill || sort==Asc.c_oAscSortOptions.ByColorFont) { %>', - '
', - '
', - '<% } else { %>', - '
', - '<% } %>', + '
', + '', + '
', + '
', + '
', + '<% if (sort==Asc.c_oAscSortOptions.ByColorFill || sort==Asc.c_oAscSortOptions.ByColorFont) { %>', + '
', + '
', + '<% } else { %>', + '
', + '<% } %>', + '
', '
' ].join('')) }); @@ -177,6 +188,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnDown.on('click', _.bind(this.onMoveClick, this, false)); this.lblColumn = $('#sort-dialog-label-column'); + this.lblSort = $('#sort-dialog-label-sort'); this.afterRender(); }, @@ -213,6 +225,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortList.on('item:add', _.bind(this.addControls, this)); this.sortList.on('item:change', _.bind(this.addControls, this)); this.refreshList(props.asc_getLevels()); + this.initListHeaders(); } }, @@ -278,6 +291,14 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.updateButtons(); }, + initListHeaders: function() { + var pos = this.sortList.cmpEl.find('#sort-dialog-cmb-sort-0').position(); + pos && this.lblColumn.width(Math.floor(pos.left)-3); + pos = this.sortList.cmpEl.find('#sort-dialog-btn-color-0').position(); + !pos && (pos = this.sortList.cmpEl.find('#sort-dialog-cmb-order-0').position()); + pos && this.lblSort.width(Math.floor(pos.left)-5 - this.lblColumn.width()); + }, + addControls: function(listView, itemView, item) { if (!item) return; @@ -360,6 +381,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', cmpEl.on('mousedown', '.combobox', function(){ me.sortList.selectRecord(item); }); + + this.updateLevelCaptions(true); }, onOptions: function () { @@ -489,6 +512,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.sortList.scrollToRecord(rec); } this.updateMoveButtons(); + this.updateLevelCaptions(); }, onSelectLevel: function(lisvView, itemView, record) { @@ -608,6 +632,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnCopy.setDisabled(this.sortList.store.length<1); this.btnDelete.setDisabled(this.sortList.store.length<1); this.updateMoveButtons(); + this.updateLevelCaptions(true); this.sortList.scroller && this.sortList.scroller.update(); }, @@ -618,6 +643,17 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', this.btnDown.setDisabled(index<0 || index==this.sortList.store.length-1); }, + updateLevelCaptions: function(all) { + var captions = this.$window.find('.level-caption'); + if (captions.length<1) return; + + if (all) + captions.text(this.textThenBy); + else + (captions.length>1) && (captions[1].innerText = this.textThenBy); + captions[0].innerText = this.textSortBy; + }, + onSelectOther: function(combo, item) { var me = this; if (me.api) { @@ -688,7 +724,7 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', textLeft: 'Left', textRight: 'Right', errorEmpty: 'All sort criteria must have a column or row specified.', - textAuto: 'Automatic', + textAuto: 'Auto', 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.', @@ -698,7 +734,8 @@ define([ 'text!spreadsheeteditor/main/app/template/SortDialog.template', textMoreRows: '(More rows...)', 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." - + errorSameColumnColor: "%1 is being sorted by the same color more than once.
Delete the duplicate sort criteria and try again.", + textSortBy: 'Sort by', + textThenBy: 'Then by' }, 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 a31103b5e..a67670234 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -2118,7 +2118,7 @@ "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.textAuto": "Auto", "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.", @@ -2129,6 +2129,8 @@ "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.SortDialog.textSortBy": "Sort by", + "SSE.Views.SortDialog.textThenBy": "Then by", "SSE.Views.SortOptionsDialog.textTitle": "Sort Options", "SSE.Views.SortOptionsDialog.textHeaders": "My data has headers", "SSE.Views.SortOptionsDialog.textCase": "Case sensitive",