[SSE] Show sheet views

This commit is contained in:
Julia Radzhabova 2020-07-09 20:42:25 +03:00
parent 30edbea008
commit 026e17cc13
2 changed files with 33 additions and 5 deletions

View file

@ -84,7 +84,10 @@ define([
'viewtab:formula': this.onViewSettings,
'viewtab:headings': this.onViewSettings,
'viewtab:gridlines': this.onViewSettings,
'viewtab:zoom': this.onZoom
'viewtab:zoom': this.onZoom,
'viewtab:showview': this.onShowView,
'viewtab:openview': this.onOpenView
// 'viewtab:manager': this.onOpenManager
},
'Statusbar': {
'sheet:changed': this.onApiSheetChanged.bind(this)
@ -135,6 +138,29 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.view);
},
onShowView: function() {
var views = this.api.asc_getNamedSheetViews(),
menu = this.view.btnSheetView.menu._innerMenu,
active = false;
menu.removeItems(1, menu.items.length-1);
_.each(views, function(item, index) {
menu.addItem(new Common.UI.MenuItem({
caption : item.asc_getName(),
checkable: true,
allowDepress: false,
checked : item.asc_getIsActive()
}));
if (item.asc_getIsActive())
active = true;
});
menu.items[0].setChecked(!active, true);
},
onOpenView: function(item) {
this.api && this.api.asc_setActiveNamedSheetView((item.value == 'default') ? null : item.name);
},
// onWorksheetLocked: function(index,locked) {
// if (index == this.api.asc_getActiveWorksheetIndex()) {
// Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort, this.view.btnGroup, this.view.btnUngroup)});

View file

@ -60,7 +60,6 @@ define([
this.chGridlines.on('change', function (field, value) {
me.fireEvent('viewtab:gridlines', [2, value]);
});
this.cmbZoom.on('selected', function(combo, record) {
me.fireEvent('viewtab:zoom', [record.value]);
});
@ -222,7 +221,7 @@ define([
setButtonMenu: function(btn) {
var me = this,
arr = [{caption: me.textDefault, value: 'default'}];
arr = [{caption: me.textDefault, value: 'default', checkable: true, allowDepress: false}];
btn.setMenu(new Common.UI.Menu({
items: [
{template: _.template('<div id="id-toolbar-sheet-view-menu-" style="display: flex;" class="open"></div>')},
@ -242,6 +241,8 @@ define([
_.delay(function() {
menu._innerMenu && menu._innerMenu.cmpEl.focus();
}, 10);
}).on('show:before', function (menu, e) {
me.fireEvent('viewtab:showview');
}).on('keydown:before', _.bind(me.onBeforeKeyDown, this));
var menu = new Common.UI.Menu({
@ -257,8 +258,9 @@ define([
top : 0
});
menu.cmpEl.attr({tabindex: "-1"});
menu.on('item:click', function (menu, item, e) {
me.fireEvent('viewtab:openview', [{name: item.caption, value: item.value}]);
menu.on('item:toggle', function (menu, item, state, e) {
if (!!state)
me.fireEvent('viewtab:openview', [{name: item.caption, value: item.value}]);
}).on('keydown:before', _.bind(me.onBeforeKeyDown, this));
btn.menu._innerMenu = menu;
menu._outerMenu = btn.menu;