[SSE] Data tab: add sort down button

This commit is contained in:
Julia Radzhabova 2019-05-31 17:48:14 +03:00
parent 065a1943c0
commit 68d2d406e0
4 changed files with 62 additions and 17 deletions

View file

@ -118,6 +118,9 @@ define([
'go:editor': function() { 'go:editor': function() {
Common.Gateway.requestEditRights(); Common.Gateway.requestEditRights();
} }
},
'DataTab': {
'data:sort': this.onSortType
} }
}); });
Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this)); Common.NotificationCenter.on('page:settings', _.bind(this.onApiSheetChanged, this));
@ -312,7 +315,6 @@ define([
toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this)); toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this));
toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this)); toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this));
toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this)); toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this));
toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending));
toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending)); toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this));
toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this));
@ -2192,7 +2194,7 @@ define([
} }
need_disable = this._state.controlsdisabled.filters || (val===null); need_disable = this._state.controlsdisabled.filters || (val===null);
toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable,
{ array: [toolbar.btnSortDown, toolbar.btnSortUp, toolbar.btnTableTemplate,toolbar.btnSetAutofilter] }); { array: [toolbar.btnSortUp, toolbar.btnTableTemplate,toolbar.btnSetAutofilter].concat(toolbar.btnsSortDown) });
val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null; val = (formatTableInfo) ? formatTableInfo.asc_getTableStyleName() : null;
if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) { if (this._state.tablestylename !== val && this.toolbar.mnuTableTemplatePicker) {
@ -2222,11 +2224,11 @@ define([
toolbar.lockToolbar(SSE.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate, toolbar.btnInsertHyperlink]}); toolbar.lockToolbar(SSE.enumLock.multiselect, this._state.multiselect, { array: [toolbar.btnTableTemplate, toolbar.btnInsertHyperlink]});
this._state.inpivot = !!info.asc_getPivotTableInfo(); this._state.inpivot = !!info.asc_getPivotTableInfo();
toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnSetAutofilter, toolbar.btnClearAutofilter, toolbar.btnSortDown, toolbar.btnSortUp]}); toolbar.lockToolbar(SSE.enumLock.editPivot, this._state.inpivot, { array: [toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnSetAutofilter, toolbar.btnClearAutofilter, toolbar.btnSortUp].concat(toolbar.btnsSortDown)});
need_disable = !this.appConfig.canModifyFilter; need_disable = !this.appConfig.canModifyFilter;
toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnSortDown, toolbar.btnSortUp, toolbar.btnSetAutofilter, toolbar.lockToolbar(SSE.enumLock.cantModifyFilter, need_disable, { array: [toolbar.btnSortUp, toolbar.btnSetAutofilter,
toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ]}); toolbar.btnTableTemplate, toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2] ].concat(toolbar.btnsSortDown)});
} }
@ -2422,7 +2424,7 @@ define([
need_disable = this._state.controlsdisabled.filters || (val===null); need_disable = this._state.controlsdisabled.filters || (val===null);
me.toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable, me.toolbar.lockToolbar(SSE.enumLock.ruleFilter, need_disable,
{ array: [me.toolbar.btnSortDown, me.toolbar.btnSortUp, me.toolbar.btnSetAutofilter] }); { array: [me.toolbar.btnSortUp, me.toolbar.btnSetAutofilter].concat(me.toolbar.btnsSortDown) });
need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true); need_disable = this._state.controlsdisabled.filters || !filterInfo || (filterInfo.asc_getIsApplyAutoFilter()!==true);
me.toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array:[me.toolbar.btnClearAutofilter]}); me.toolbar.lockToolbar(SSE.enumLock.ruleDelFilter, need_disable, {array:[me.toolbar.btnClearAutofilter]});
@ -3094,7 +3096,10 @@ define([
if ( !config.isEditDiagram && !config.isEditMailMerge ) { if ( !config.isEditDiagram && !config.isEditMailMerge ) {
var datatab = me.getApplication().getController('DataTab'); var datatab = me.getApplication().getController('DataTab');
datatab.setApi(me.api).setConfig({toolbar: me}); datatab.setApi(me.api).setConfig({toolbar: me});
Array.prototype.push.apply(me.toolbar.lockControls, datatab.getView('DataTab').getButtons());
datatab = datatab.getView('DataTab');
Array.prototype.push.apply(me.toolbar.lockControls, datatab.getButtons());
me.toolbar.btnsSortDown = datatab.getButtons('sort-down');
if ( !config.isOffline ) { if ( !config.isOffline ) {
tab = {action: 'pivot', caption: me.textPivot}; tab = {action: 'pivot', caption: me.textPivot};

View file

@ -76,7 +76,7 @@
<div class="separator long"></div> <div class="separator long"></div>
<div class="group"> <div class="group">
<div class="elset"> <div class="elset">
<span class="btn-slot split" id="slot-btn-sortdesc"></span> <span class="btn-slot split slot-sortdesc"></span>
<span class="btn-slot" id="slot-btn-sortasc"></span> <span class="btn-slot" id="slot-btn-sortasc"></span>
</div> </div>
<div class="elset"> <div class="elset">
@ -153,6 +153,14 @@
</div> </div>
</section> </section>
<section class="panel" data-tab="data"> <section class="panel" data-tab="data">
<div class="group">
<div class="elset">
<span class="btn-slot slot-sortdesc"></span>
</div>
<div class="elset">
</div>
</div>
<div class="separator long"></div>
<div class="group"> <div class="group">
<span class="btn-slot text x-huge" id="slot-btn-text-column"></span> <span class="btn-slot text x-huge" id="slot-btn-text-column"></span>
</div> </div>

View file

@ -66,6 +66,11 @@ define([
me.btnHide.on('click', function (b, e) { me.btnHide.on('click', function (b, e) {
me.fireEvent('data:hide'); me.fireEvent('data:hide');
}); });
me.btnsSortDown.forEach(function(button) {
button.on('click', function (b, e) {
me.fireEvent('data:sort', [Asc.c_oAscSortOptions.Ascending]);
});
});
} }
return { return {
@ -76,6 +81,7 @@ define([
this.toolbar = options.toolbar; this.toolbar = options.toolbar;
this.lockedControls = []; this.lockedControls = [];
this.btnsSortDown = [];
var me = this, var me = this,
$host = me.toolbar.$el, $host = me.toolbar.$el,
@ -87,6 +93,27 @@ define([
cmp.rendered ? $slot.append(cmp.$el) : cmp.render($slot); cmp.rendered ? $slot.append(cmp.$el) : cmp.render($slot);
}; };
var _injectComponents = function ($slots, iconCls, split, menu, caption, lock, btnsArr) {
$slots.each(function(index, el) {
var _cls = 'btn-toolbar';
/x-huge/.test(el.className) && (_cls += ' x-huge icon-top');
var button = new Common.UI.Button({
id: "id-toolbar-" + iconCls + index,
cls: _cls,
iconCls: iconCls,
caption: caption,
split: split,
menu: menu,
lock: lock,
disabled: true
}).render( $slots.eq(index) );
btnsArr.push(button);
me.lockedControls.push(button);
});
};
this.btnGroup = new Common.UI.Button({ this.btnGroup = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-img-group', iconCls: 'btn-img-group',
@ -141,6 +168,10 @@ define([
_injectComponent('#slot-btn-hide-details', this.btnHide); _injectComponent('#slot-btn-hide-details', this.btnHide);
this.lockedControls.push(this.btnHide); this.lockedControls.push(this.btnHide);
_injectComponents($host.find('.slot-sortdesc'), 'btn-sort-down', false, false, '',
[_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot],
this.btnsSortDown);
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
}, },
@ -166,6 +197,10 @@ define([
me.btnGroup.updateHint(me.tipGroup); me.btnGroup.updateHint(me.tipGroup);
me.btnTextToColumns.updateHint(me.tipToColumns); me.btnTextToColumns.updateHint(me.tipToColumns);
me.btnsSortDown.forEach( function(btn) {
btn.updateHint(me.toolbar.txtSortAZ);
});
setEvents.call(me); setEvents.call(me);
}); });
}, },
@ -175,8 +210,12 @@ define([
this.fireEvent('show', this); this.fireEvent('show', this);
}, },
getButtons: function() { getButtons: function(type) {
if (type == 'sort-down')
return this.btnsSortDown;
else if (type===undefined)
return this.lockedControls; return this.lockedControls;
return [];
}, },
SetDisabled: function (state) { SetDisabled: function (state) {

View file

@ -716,13 +716,6 @@ define([
menu : new Common.UI.Menu({cls: 'menu-shapes'}) menu : new Common.UI.Menu({cls: 'menu-shapes'})
}); });
me.btnSortDown = new Common.UI.Button({
id : 'id-toolbar-btn-sort-down',
cls : 'btn-toolbar',
iconCls : 'btn-sort-down',
lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.ruleFilter, _set.editPivot, _set.cantModifyFilter]
});
me.btnSortUp = new Common.UI.Button({ me.btnSortUp = new Common.UI.Button({
id : 'id-toolbar-btn-sort-up', id : 'id-toolbar-btn-sort-up',
cls : 'btn-toolbar', cls : 'btn-toolbar',