diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index cd7528c4b..c6b114db6 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -338,10 +338,31 @@ define([ onSortCells: function(menu, item) { if (this.api) { - this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor); + var res = this.api.asc_sortCellsRangeExpand(); + if (res) { + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtExpandSort, + iconCls: 'warn', + buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, + {caption: this.txtSortSelected, primary: true, value: 'sort'}, + 'cancel'], + callback: _.bind(function(btn){ + if (btn == 'expand' || btn == 'sort') { + this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, btn == 'expand'); + } + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + }, this) + }; + Common.UI.alert(config); + } else { + this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor, res !== null); - Common.NotificationCenter.trigger('edit:complete', this.documentHolder); - Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + Common.NotificationCenter.trigger('edit:complete', this.documentHolder); + Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); + } } }, @@ -2299,7 +2320,11 @@ define([ deleteText : 'Delete', deleteRowText : 'Delete Row', deleteColumnText : 'Delete Column', - txtNoChoices: 'There are no choices for filling the cell.
Only text values from the column can be selected for replacement.' + txtNoChoices: 'There are no choices for filling the cell.
Only text values from the column can be selected for replacement.', + 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.DocumentHolder || {})); }); \ 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 3a842b476..38d001d64 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -839,8 +839,27 @@ define([ }, onSortType: function(type, btn) { - if (this.api) - this.api.asc_sortColFilter(type, ''); + if (this.api) { + var res = this.api.asc_sortCellsRangeExpand(); + if (res) { + var config = { + width: 500, + title: this.txtSorting, + msg: this.txtExpandSort, + iconCls: 'warn', + buttons: [ {caption: this.txtExpand, primary: true, value: 'expand'}, + {caption: this.txtSortSelected, primary: true, value: 'sort'}, + 'cancel'], + callback: _.bind(function(btn){ + if (btn == 'expand' || btn == 'sort') { + this.api.asc_sortColFilter(type, '', undefined, undefined, btn == 'expand'); + } + }, this) + }; + Common.UI.alert(config); + } else + this.api.asc_sortColFilter(type, '', undefined, undefined, res !== null); + } }, onSearch: function(type, btn) { @@ -2966,6 +2985,11 @@ define([ txtMatrix_2_2_LineBracket : 'Empty Matrix with Brackets', txtMatrix_2_2_DLineBracket : 'Empty Matrix with Brackets', txtMatrix_Flat_Round : 'Sparse Matrix', - txtMatrix_Flat_Square : 'Sparse Matrix' + txtMatrix_Flat_Square : 'Sparse Matrix', + 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.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index dc25078cd..52b663215 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -194,6 +194,10 @@ "SSE.Controllers.DocumentHolder.txtTop": "Top", "SSE.Controllers.DocumentHolder.txtUnderbar": "Bar under text", "SSE.Controllers.DocumentHolder.txtWidth": "Width", + "SSE.Controllers.DocumentHolder.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?", + "SSE.Controllers.DocumentHolder.txtExpand": "Expand and sort", + "SSE.Controllers.DocumentHolder.txtSorting": "Sorting", + "SSE.Controllers.DocumentHolder.txtSortSelected": "Sort selected", "SSE.Controllers.LeftMenu.newDocumentTitle": "Unnamed spreadsheet", "SSE.Controllers.LeftMenu.textByColumns": "By columns", "SSE.Controllers.LeftMenu.textByRows": "By rows", @@ -675,6 +679,10 @@ "SSE.Controllers.Toolbar.txtSymbol_xsi": "Xi", "SSE.Controllers.Toolbar.txtSymbol_zeta": "Zeta", "SSE.Controllers.Toolbar.warnMergeLostData": "Only the data from the upper-left cell will remain in the merged cell.
Are you sure you want to continue?", + "SSE.Controllers.Toolbar.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?", + "SSE.Controllers.Toolbar.txtExpand": "Expand and sort", + "SSE.Controllers.Toolbar.txtSorting": "Sorting", + "SSE.Controllers.Toolbar.txtSortSelected": "Sort selected", "SSE.Views.AutoFilterDialog.btnCustomFilter": "Custom Filter", "SSE.Views.AutoFilterDialog.cancelButtonText": "Cancel", "SSE.Views.AutoFilterDialog.okButtonText": "OK",