[SSE] Add lock for controls on the Pivot tab

This commit is contained in:
Julia Radzhabova 2019-10-04 16:17:05 +03:00
parent 8124fa2666
commit 30e5e09766
5 changed files with 42 additions and 17 deletions

View file

@ -147,7 +147,7 @@ define([
onApiSelectionChanged: function(info) { onApiSelectionChanged: function(info) {
var seltype = info.asc_getFlags().asc_getSelectionType(), var seltype = info.asc_getFlags().asc_getSelectionType(),
coauth_disable = (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) ? (info.asc_getLocked() === true || info.asc_getLockedTable() === true) : false; coauth_disable = (!this.mode.isEditMailMerge && !this.mode.isEditDiagram) ? (info.asc_getLocked() === true || info.asc_getLockedTable() === true || info.asc_getLockedPivotTable()===true) : false;
var is_chart_text = seltype == Asc.c_oAscSelectionType.RangeChartText, var is_chart_text = seltype == Asc.c_oAscSelectionType.RangeChartText,
is_chart = seltype == Asc.c_oAscSelectionType.RangeChart, is_chart = seltype == Asc.c_oAscSelectionType.RangeChart,

View file

@ -99,8 +99,10 @@ define([
if (api) { if (api) {
this.api = api; this.api = api;
this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this)); this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this));
this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this));
this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this)); this.api.asc_registerCallback('asc_onSelectionChanged', _.bind(this.onSelectionChanged, this));
Common.NotificationCenter.on('cells:range', _.bind(this.onCellsRange, this));
} }
}, },
@ -377,16 +379,22 @@ define([
}, },
onSelectionChanged: function(info) { onSelectionChanged: function(info) {
if (this.rangeSelectionMode || !this.appConfig.isEdit) return; if (this.rangeSelectionMode || !this.appConfig.isEdit || !this.view) return;
var selectType = info.asc_getFlags().asc_getSelectionType(), var selectType = info.asc_getFlags().asc_getSelectionType(),
pivotInfo = info.asc_getPivotTableInfo(); pivotInfo = info.asc_getPivotTableInfo();
this.view.SetDisabled(!pivotInfo || info.asc_getLockedPivotTable()); Common.Utils.lockControls(SSE.enumLock.noPivot, !pivotInfo, {array: this.view.lockedControls});
Common.Utils.lockControls(SSE.enumLock.editPivot, !!pivotInfo, {array: [this.view.btnAddPivot]});
if (pivotInfo) if (pivotInfo)
this.ChangeSettings(pivotInfo); this.ChangeSettings(pivotInfo);
}, },
onCellsRange: function(status) {
this.rangeSelectionMode = (status != Asc.c_oAscSelectionDialogType.None);
},
createToolbarPanel: function() { createToolbarPanel: function() {
return this.view.getPanel(); return this.view.getPanel();
}, },

View file

@ -1947,7 +1947,7 @@ define([
return this.onApiSelectionChanged_MailMergeEditor(info); return this.onApiSelectionChanged_MailMergeEditor(info);
var selectionType = info.asc_getFlags().asc_getSelectionType(), var selectionType = info.asc_getFlags().asc_getSelectionType(),
coauth_disable = (!this.toolbar.mode.isEditMailMerge && !this.toolbar.mode.isEditDiagram) ? (info.asc_getLocked()===true || info.asc_getLockedTable()===true) : false, coauth_disable = (!this.toolbar.mode.isEditMailMerge && !this.toolbar.mode.isEditDiagram) ? (info.asc_getLocked()===true || info.asc_getLockedTable()===true || info.asc_getLockedPivotTable()===true) : false,
editOptionsDisabled = this._disableEditOptions(selectionType, coauth_disable), editOptionsDisabled = this._disableEditOptions(selectionType, coauth_disable),
me = this, me = this,
toolbar = this.toolbar, toolbar = this.toolbar,
@ -3149,10 +3149,12 @@ define([
if ( !config.isOffline ) { if ( !config.isOffline ) {
tab = {action: 'pivot', caption: me.textPivot}; tab = {action: 'pivot', caption: me.textPivot};
$panel = me.getApplication().getController('PivotTable').createToolbarPanel(); var pivottab = me.getApplication().getController('PivotTable');
$panel = pivottab.createToolbarPanel();
if ($panel) { if ($panel) {
me.toolbar.addTab(tab, $panel, 5); me.toolbar.addTab(tab, $panel, 5);
me.toolbar.setVisible('pivot', true); me.toolbar.setVisible('pivot', true);
Array.prototype.push.apply(me.toolbar.lockControls, pivottab.getView('PivotTable').getButtons());
} }
} }

View file

@ -152,23 +152,29 @@ define([
this.appConfig = options.mode; this.appConfig = options.mode;
this.lockedControls = []; this.lockedControls = [];
var _set = SSE.enumLock;
this.chRowHeader = new Common.UI.CheckBox({ this.chRowHeader = new Common.UI.CheckBox({
labelText: this.textRowHeader labelText: this.textRowHeader,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.chRowHeader); this.lockedControls.push(this.chRowHeader);
this.chColHeader = new Common.UI.CheckBox({ this.chColHeader = new Common.UI.CheckBox({
labelText: this.textColHeader labelText: this.textColHeader,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.chColHeader); this.lockedControls.push(this.chColHeader);
this.chRowBanded = new Common.UI.CheckBox({ this.chRowBanded = new Common.UI.CheckBox({
labelText: this.textRowBanded labelText: this.textRowBanded,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.chRowBanded); this.lockedControls.push(this.chRowBanded);
this.chColBanded = new Common.UI.CheckBox({ this.chColBanded = new Common.UI.CheckBox({
labelText: this.textColBanded labelText: this.textColBanded,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.chColBanded); this.lockedControls.push(this.chColBanded);
@ -176,7 +182,8 @@ define([
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-add-pivot', iconCls: 'btn-add-pivot',
caption: this.txtCreate, caption: this.txtCreate,
disabled : false disabled : false,
lock : [_set.lostConnect, _set.coAuth, _set.editPivot]
}); });
// this.lockedControls.push(this.btnAddPivot); // this.lockedControls.push(this.btnAddPivot);
@ -185,6 +192,7 @@ define([
iconCls : 'btn-pivot-layout', iconCls : 'btn-pivot-layout',
caption : this.capLayout, caption : this.capLayout,
disabled : true, disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot],
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
items: [ items: [
{ caption: this.mniLayoutCompact, value: 0 }, { caption: this.mniLayoutCompact, value: 0 },
@ -203,6 +211,7 @@ define([
iconCls : 'btn-blank-rows', iconCls : 'btn-blank-rows',
caption : this.capBlankRows, caption : this.capBlankRows,
disabled : true, disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot],
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
items: [ items: [
{ caption: this.mniInsertBlankLine, value: 'insert' }, { caption: this.mniInsertBlankLine, value: 'insert' },
@ -217,6 +226,7 @@ define([
iconCls : 'btn-subtotals', iconCls : 'btn-subtotals',
caption : this.capSubtotals, caption : this.capSubtotals,
disabled : true, disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot],
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
items: [ items: [
{ caption: this.mniNoSubtotals, value: 0 }, { caption: this.mniNoSubtotals, value: 0 },
@ -232,6 +242,7 @@ define([
iconCls : 'btn-grand-totals', iconCls : 'btn-grand-totals',
caption : this.capGrandTotals, caption : this.capGrandTotals,
disabled : true, disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot],
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
items: [ items: [
{ caption: this.mniOffTotals, value: 0 }, { caption: this.mniOffTotals, value: 0 },
@ -247,14 +258,16 @@ define([
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-update-pivot', iconCls: 'btn-update-pivot',
caption: this.txtRefresh, caption: this.txtRefresh,
disabled : true disabled : true,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.btnRefreshPivot); this.lockedControls.push(this.btnRefreshPivot);
this.btnSelectPivot = new Common.UI.Button({ this.btnSelectPivot = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'btn-select-pivot', iconCls: 'btn-select-pivot',
caption: this.txtSelect caption: this.txtSelect,
lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.btnSelectPivot); this.lockedControls.push(this.btnSelectPivot);
@ -263,8 +276,8 @@ define([
enableKeyEvents : true, enableKeyEvents : true,
itemWidth : 61, itemWidth : 61,
itemHeight : 49, itemHeight : 49,
menuMaxHeight : 300 menuMaxHeight : 300,
// lock : [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth] lock : [_set.lostConnect, _set.coAuth, _set.noPivot]
}); });
this.lockedControls.push(this.pivotStyles); this.lockedControls.push(this.pivotStyles);
@ -320,11 +333,12 @@ define([
this.fireEvent('show', this); this.fireEvent('show', this);
}, },
getButton: function(type, parent) { getButtons: function(type) {
return this.lockedControls.concat(this.btnAddPivot);
}, },
SetDisabled: function (state) { SetDisabled: function (state) {
this.lockedControls && this.lockedControls.forEach(function(button) { this.lockedControls.concat(this.btnAddPivot).forEach(function(button) {
if ( button ) { if ( button ) {
button.setDisabled(state); button.setDisabled(state);
} }

View file

@ -90,7 +90,8 @@ define([
namedRangeLock: 'named-range-lock', namedRangeLock: 'named-range-lock',
multiselectCols:'is-multiselect-cols', multiselectCols:'is-multiselect-cols',
headerLock: 'header-lock', headerLock: 'header-lock',
sheetLock: 'sheet-lock' sheetLock: 'sheet-lock',
noPivot: 'no-pivot'
}; };
SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({ SSE.Views.Toolbar = Common.UI.Mixtbar.extend(_.extend({