Add custom sort button

This commit is contained in:
Julia Radzhabova 2019-10-01 14:20:52 +03:00
parent 4a776615d2
commit ef8a9c8d0d
4 changed files with 49 additions and 10 deletions

View file

@ -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 || {}));
});

View file

@ -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});

View file

@ -185,14 +185,17 @@
<section class="panel" data-tab="data">
<div class="group">
<div class="elset">
<span class="btn-slot split slot-sortdesc"></span>
<span class="btn-slot slot-sortasc"></span>
<span class="btn-slot split slot-btn-setfilter"></span>
<span class="btn-slot slot-sortdesc"></span>
</div>
<div class="elset">
<span class="btn-slot split slot-btn-setfilter"></span>
<span class="btn-slot slot-btn-clear-filter"></span>
<span class="btn-slot split slot-btn-clear-filter"></span>
<span class="btn-slot slot-sortasc"></span>
</div>
</div>
<div class="group" style="padding-left: 0;">
<span class="btn-slot text x-huge" id="slot-btn-custom-sort"></span>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-text-column"></span>

View file

@ -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 || {}));
});