[SSE] Apply view settings

This commit is contained in:
Julia Radzhabova 2020-07-09 19:04:54 +03:00
parent 0acbad6fa0
commit 30edbea008
3 changed files with 76 additions and 13 deletions

View file

@ -62,8 +62,11 @@ define([
setApi: function (api) { setApi: function (api) {
if (api) { if (api) {
this.api = api; this.api = api;
this.api.asc_registerCallback('asc_onZoomChanged', this.onApiZoomChange.bind(this));
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this));
this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this)); // this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onWorksheetLocked, this));
this.api.asc_registerCallback('asc_onSheetsChanged', this.onApiSheetChanged.bind(this));
this.api.asc_registerCallback('asc_onUpdateSheetViewSettings', this.onApiSheetChanged.bind(this));
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
} }
@ -77,9 +80,17 @@ define([
}); });
this.addListeners({ this.addListeners({
'ViewTab': { 'ViewTab': {
'viewtab:freeze': this.onFreeze 'viewtab:freeze': this.onFreeze,
'viewtab:formula': this.onViewSettings,
'viewtab:headings': this.onViewSettings,
'viewtab:gridlines': this.onViewSettings,
'viewtab:zoom': this.onZoom
},
'Statusbar': {
'sheet:changed': this.onApiSheetChanged.bind(this)
} }
}); });
Common.NotificationCenter.on('layout:changed', _.bind(this.onLayoutChanged, this));
}, },
SetDisabled: function(state) { SetDisabled: function(state) {
@ -99,22 +110,58 @@ define([
if (!this.toolbar.editMode || !this.view) return; if (!this.toolbar.editMode || !this.view) return;
}, },
onFreeze: function() { onFreeze: function(state) {
var me = this; if (this.api) {
Common.NotificationCenter.trigger('edit:complete', me.toolbar); this.api.asc_freezePane();
}
Common.NotificationCenter.trigger('edit:complete', this.view);
}, },
onWorksheetLocked: function(index,locked) { onZoom: function(zoom) {
if (index == this.api.asc_getActiveWorksheetIndex()) { if (this.api) {
Common.Utils.lockControls(SSE.enumLock.sheetLock, locked, {array: this.view.btnsSortDown.concat(this.view.btnsSortUp, this.view.btnCustomSort, this.view.btnGroup, this.view.btnUngroup)}); this.api.asc_setZoom(zoom/100);
} }
Common.NotificationCenter.trigger('edit:complete', this.view);
}, },
onViewSettings: function(type, value){
if (this.api) {
switch (type) {
case 0: this.getApplication().getController('Viewport').header.fireEvent('formulabar:hide', [ value!=='checked']); break;
case 1: this.api.asc_setDisplayHeadings(value=='checked'); break;
case 2: this.api.asc_setDisplayGridlines( value=='checked'); break;
}
}
Common.NotificationCenter.trigger('edit:complete', this.view);
},
// 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)});
// }
// },
onApiSheetChanged: function() { onApiSheetChanged: function() {
if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return; if (!this.toolbar.mode || !this.toolbar.mode.isEdit || this.toolbar.mode.isEditDiagram || this.toolbar.mode.isEditMailMerge) return;
var currentSheet = this.api.asc_getActiveWorksheetIndex(); var params = this.api.asc_getSheetViewSettings();
this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet)); this.view.chHeadings.setValue(!!params.asc_getShowRowColHeaders(), true);
this.view.chGridlines.setValue(!!params.asc_getShowGridLines(), true);
this.view.btnFreezePanes.toggle(!!params.asc_getIsFreezePane(), true);
// var currentSheet = this.api.asc_getActiveWorksheetIndex();
// this.onWorksheetLocked(currentSheet, this.api.asc_isWorksheetLockedOrDeleted(currentSheet));
},
onLayoutChanged: function(area) {
if (area=='celleditor' && arguments[1]) {
this.view.chFormula.setValue(arguments[1]=='showed', true);
}
},
onApiZoomChange: function(zf, type){
var value = Math.floor((zf + .005) * 100);
this.view.cmbZoom.setValue(value, value + '%');
} }
}, SSE.Controllers.ViewTab || {})); }, SSE.Controllers.ViewTab || {}));

View file

@ -207,7 +207,7 @@ define([
}, this)); }, this));
} }
var mnuitemHideFormulaBar = new Common.UI.MenuItem({ me.header.mnuitemHideFormulaBar = new Common.UI.MenuItem({
caption : me.textHideFBar, caption : me.textHideFBar,
checked : Common.localStorage.getBool('sse-hidden-formula'), checked : Common.localStorage.getBool('sse-hidden-formula'),
checkable : true, checkable : true,
@ -261,7 +261,7 @@ define([
style: 'min-width: 180px;', style: 'min-width: 180px;',
items: [ items: [
me.header.mnuitemCompactToolbar, me.header.mnuitemCompactToolbar,
mnuitemHideFormulaBar, me.header.mnuitemHideFormulaBar,
{caption:'--'}, {caption:'--'},
me.header.mnuitemHideHeadings, me.header.mnuitemHideHeadings,
me.header.mnuitemHideGridlines, me.header.mnuitemHideGridlines,
@ -391,6 +391,7 @@ define([
case 'celleditor': case 'celleditor':
if (arguments[1]) { if (arguments[1]) {
this.boxSdk.css('border-top', arguments[1]=='hidden'?'none':''); this.boxSdk.css('border-top', arguments[1]=='hidden'?'none':'');
this.header.mnuitemHideFormulaBar.setChecked(arguments[1]=='hidden', true);
} }
this.viewport.celayout.doLayout(); this.viewport.celayout.doLayout();
break; break;

View file

@ -51,6 +51,19 @@ define([
me.btnFreezePanes.on('click', function (btn, e) { me.btnFreezePanes.on('click', function (btn, e) {
me.fireEvent('viewtab:freeze', [btn.pressed]); me.fireEvent('viewtab:freeze', [btn.pressed]);
}); });
this.chFormula.on('change', function (field, value) {
me.fireEvent('viewtab:formula', [0, value]);
});
this.chHeadings.on('change', function (field, value) {
me.fireEvent('viewtab:headings', [1, value]);
});
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]);
});
} }
return { return {
@ -108,6 +121,7 @@ define([
this.lockedControls.push(this.btnFreezePanes); this.lockedControls.push(this.btnFreezePanes);
this.cmbZoom = new Common.UI.ComboBox({ this.cmbZoom = new Common.UI.ComboBox({
el : $host.find('#slot-field-zoom'),
cls : 'input-group-nr', cls : 'input-group-nr',
menuStyle : 'min-width: 55px;', menuStyle : 'min-width: 55px;',
hint : me.tipFontSize, hint : me.tipFontSize,
@ -123,11 +137,12 @@ define([
{ displayValue: "200%", value: 200 } { displayValue: "200%", value: 200 }
] ]
}); });
Common.Utils.injectComponent($host.find('#slot-field-zoom'), this.cmbZoom); this.cmbZoom.setValue(100);
this.chFormula = new Common.UI.CheckBox({ this.chFormula = new Common.UI.CheckBox({
el: $host.findById('#slot-chk-formula'), el: $host.findById('#slot-chk-formula'),
labelText: this.textFormula, labelText: this.textFormula,
value: !Common.localStorage.getBool('sse-hidden-formula'),
lock : [_set.lostConnect, _set.coAuth] lock : [_set.lostConnect, _set.coAuth]
}); });
this.lockedControls.push(this.chFormula); this.lockedControls.push(this.chFormula);