fix: locks

This commit is contained in:
nikita_bartoshuk
2025-07-17 18:10:26 +03:00
parent e34046b7be
commit 4573ea71fa
4 changed files with 96 additions and 117 deletions

View File

@ -69,12 +69,9 @@ define([
};
this.lockedControls = [];
this._locked = false;
this.wsLock = false;
this.wsProps = [];
this.isEditCell = false;
this.application = this.getApplication();
this.toolbar = this.application.getController('Toolbar');
this._originalProps = null;
this._noApply = false;
this.addListeners({
'TableDesignTab': {
@ -82,7 +79,10 @@ define([
'tabledesigntab:advanced': _.bind(this.openAdvancedSettings, this),
'tabledesigntab:style': _.bind(this.onTableStyleSelect, this),
'tabledesigntab:selectdata': _.bind(this.onSelectData, this),
'tabledesign:namechanged': _.bind(this.onTableNameChanged, this)
'tabledesign:namechanged': _.bind(this.onTableNameChanged, this),
'tabledesigntab:convertrange': _.bind(this.convertToRange, this),
'tabledesigntab:edit': _.bind(this.onEditClick, this),
'tabledesigntab:stylechange': _.bind(this.changeTableInfo, this)
},
});
},
@ -170,9 +170,7 @@ define([
}
},
ChangeSettings: function(props, wsLock, wsProps) {
this.wsLock = wsLock;
this.wsProps = wsProps;
ChangeSettings: function(props) {
if (props )//formatTableInfo
{
this._originalProps = props;
@ -235,7 +233,7 @@ define([
this._state.CheckFilter=value;
}
if (view.chFilterButton.isDisabled() !== (!this._state.CheckHeader || this._locked || value===null))
view.chFilterButton.setDisabled(!this._state.CheckHeader || this._locked || value===null || this.wsLock);
view.chFilterButton.setDisabled(!this._state.CheckHeader || this._locked || value===null);
if (needTablePictures)
this.onApiInitTableStyles(this.api.asc_getTablePictures(props));
@ -263,12 +261,37 @@ define([
},
onTableStyleSelect: function(record){
if (this.api && !this._noApply) {
if (this.api) {
this.api.asc_changeAutoFilter(this._state.TableName, Asc.c_oAscChangeFilterOptions.style, record.get('name'));
}
Common.NotificationCenter.trigger('edit:complete', this);
},
convertToRange: function(btn) {
if (this.api) this.api.asc_convertTableToRange(this._state.TableName);
Common.NotificationCenter.trigger('edit:complete', this);
},
changeTableInfo: function(type, stateName, newValue) {
this._state[stateName] = undefined;
if (this.api)
this.api.asc_changeFormatTableInfo(this._state.TableName, type, newValue=='checked');
Common.NotificationCenter.trigger('edit:complete', this);
},
onEditClick: function(item) {
if (this.api) {
if (item.options.idx>=0 && item.options.idx<4)
this.api.asc_changeSelectionFormatTable(this._state.TableName, item.value);
else if (item.options.idx>=4 && item.options.idx<8) {
this.api.asc_insertCellsInTable(this._state.TableName, item.value);
} else {
this.api.asc_deleteCellsInTable(this._state.TableName, item.value);
}
}
Common.NotificationCenter.trigger('edit:complete', this);
},
setApi: function(api) {
if (api) {
this.api = api;
@ -315,10 +338,10 @@ define([
styles.menuPicker.store.reset([]);
var templates = [];
var groups = [
{id: 'menu-table-group-custom', caption: self.view.txtGroupPivot_Custom, templates: []},
{id: 'menu-table-group-light', caption: self.view.txtGroupPivot_Light, templates: []},
{id: 'menu-table-group-medium', caption: self.view.txtGroupPivot_Medium, templates: []},
{id: 'menu-table-group-dark', caption: self.view.txtGroupPivot_Dark, templates: []},
{id: 'menu-table-group-custom', caption: self.view.txtGroupTable_Custom, templates: []},
{id: 'menu-table-group-light', caption: self.view.txtGroupTable_Light, templates: []},
{id: 'menu-table-group-medium', caption: self.view.txtGroupTable_Medium, templates: []},
{id: 'menu-table-group-dark', caption: self.view.txtGroupTable_Dark, templates: []},
{id: 'menu-table-group-no-name', caption: '&nbsp', templates: []},
];
_.each(Templates, function(template, index){
@ -411,12 +434,8 @@ define([
},
setConfig: function(config) {
this.toolbar = config.toolbar;
var mode = config.mode;
this.view = this.createView('TableDesignTab', {
toolbar: this.toolbar.toolbar,
mode: mode,
compactToolbar: this.toolbar.toolbar.isCompactView
toolbar: config.toolbar.toolbar
});
},
@ -424,10 +443,6 @@ define([
this.view && this.view.SetDisabled(state);
},
onInsertPivot: function(btn, opts){
this.fireEvent('pivottable:create');
},
onInsertSlicer: function() {
var me = this,
props = me.api.asc_beforeInsertSlicer();

View File

@ -3131,7 +3131,7 @@ define([
}
need_disable = this._state.controlsdisabled.filters || (val===null);
toolbar.lockToolbar(Common.enumLock.ruleFilter, need_disable,
{ array: toolbar.btnsSetAutofilter.concat(toolbar.btnCustomSort, toolbar.btnTableTemplate, toolbar.btnInsertTable, toolbar.btnRemoveDuplicates, toolbar.btnDataValidation) });
{ array: toolbar.btnsSetAutofilter.concat(toolbar.btnCustomSort, toolbar.btnTableTemplate, toolbar.btnInsertTable, toolbar.btnDataValidation).concat(toolbar.btnsRemoveDuplicates)});
toolbar.lockToolbar(Common.enumLock.tableHasSlicer, filterInfo && filterInfo.asc_getIsSlicerAdded(), { array: toolbar.btnsSetAutofilter });
@ -3184,13 +3184,12 @@ define([
this.toolbar.setTab('pivot');
this._state.inpivot = inpivot;
}
toolbar.lockToolbar(Common.enumLock.editPivot, this._state.inpivot, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnInsertTable, toolbar.btnRemoveDuplicates, toolbar.btnDataValidation)});
toolbar.lockToolbar(Common.enumLock.editPivot, this._state.inpivot, { array: toolbar.btnsSetAutofilter.concat(toolbar.btnMerge, toolbar.btnInsertHyperlink, toolbar.btnInsertTable, toolbar.btnDataValidation).concat(toolbar.btnsRemoveDuplicates)});
toolbar.lockToolbar(Common.enumLock.noSlicerSource, !(this._state.inpivot || formatTableInfo), { array: [toolbar.btnInsertSlicer]});
need_disable = !this.appConfig.canModifyFilter;
toolbar.lockToolbar(Common.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, toolbar.btnRemoveDuplicates, toolbar.btnDataValidation)});
toolbar.btnClearStyle.menu.items[0], toolbar.btnClearStyle.menu.items[2], toolbar.btnInsertTable, toolbar.btnDataValidation).concat(toolbar.btnsRemoveDuplicates).concat(toolbar.btnsTableDesign)});
}
val = xfs.asc_getNumFormatInfo();
@ -4524,7 +4523,7 @@ define([
me.toolbar.btnsSetAutofilter = datatab.getButtons('set-filter');
me.toolbar.btnsClearAutofilter = datatab.getButtons('clear-filter');
me.toolbar.btnCustomSort = datatab.getButtons('sort-custom');
me.toolbar.btnRemoveDuplicates = datatab.getButtons('rem-duplicates');
me.toolbar.btnsRemoveDuplicates = [datatab.getButtons('rem-duplicates')];
me.toolbar.btnDataValidation = datatab.getButtons('data-validation');
var formulatab = me.getApplication().getController('FormulaDialog');
@ -4552,13 +4551,15 @@ define([
var tabledesigntab = me.getApplication().getController('TableDesignTab');
tabledesigntab.setApi(me.api).setConfig({toolbar: me});
var view = tabledesigntab.getView('TableDesignTab');
view.setApi(me.api);
var tabledesignbuttons = view.getButtons();
var $panel = tabledesigntab.createToolbarPanel();
if ($panel) {
me.toolbar.addTab(tab, $panel, Common.UI.LayoutManager.lastTabIdx+1);
me._state.intabledesign && me.toolbar.setVisible('tabledesign', true);
Array.prototype.push.apply(me.toolbar.lockControls, view.getButtons());
Array.prototype.push.apply(me.toolbar.lockControls, tabledesignbuttons);
}
me.toolbar.btnsRemoveDuplicates.push(view.getButtons('rem-duplicates'));
me.toolbar.btnsTableDesign = tabledesignbuttons;
}
if (!config.compactHeader) {

View File

@ -120,35 +120,34 @@ define([
this.tableStyles.on('click', function (combo, record) {
me.fireEvent('tabledesigntab:style', [record]);
});
this.btnInsertPivot.on('click', function (btn,e) {
me.fireEvent('tabledesigntab:insertpivot');
});
this.btnInsertSlicer.on('click', function (btn, e) {
me.fireEvent('tabledesigntab:insertslicer');
});
this.txtTableName.on('click', function (btn, e) {
me.fireEvent('tabledesign:namechanged');
})
});
this.btnConvertRange.on('click', function (btn, e) {
me.fireEvent('tabledesigntab:convertrange')
});
this.btnInsertPivot.on('click', function () {
me.fireEvent('pivottable:create');
});
this.btnRemDuplicates.on('click', function(btn){
Common.NotificationCenter.trigger('data:remduplicates', this);
});
this.btnEdit.menu.on('item:click', function(menu, item, e) {
me.fireEvent('tabledesigntab:edit', [item])
});
this.tableStyles.openButton.menu.on('show:after', function () {
me.tableStyles.menuPicker.scroller.update({alwaysVisibleY: true});
});
}
return {
options: {},
initialize: function (options) {
this.lockedControls = [];
this._locked = false;
this.wsLock = false;
this.wsProps = [];
this.isEditCell = false;
var controller = SSE.getController('TableDesignTab');
this._state = controller._state
this._noApply = false;
Common.UI.BaseView.prototype.initialize.call(this);
this.toolbar = options.toolbar;
this.appConfig = options.mode;
this.lockedControls = [];
@ -158,7 +157,7 @@ define([
this.btnResizeTable = new Common.UI.Button({
cls: 'btn-toolbar',
iconCls: 'toolbar__icon btn-resize-table',
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
caption: this.txtResize,
dataHint: '1',
dataHintDirection: 'left',
@ -170,7 +169,7 @@ define([
cls : 'btn-toolbar align-left',
iconCls : 'toolbar__icon btn-rows-and-columns',
caption : this.txtRowsCols,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, , _set.cantModifyFilter],
style : 'width: 100%;',
menu: new Common.UI.Menu({
menuAlign: 'tr-br',
@ -197,57 +196,46 @@ define([
this.lockedControls.push(this.btnEdit);
this.btnEdit.menu.on('show:after', _.bind( function(menu){
if (this.api) {
menu.items[5].setDisabled(!this._originalProps.asc_getIsInsertRowAbove());
menu.items[6].setDisabled(!this._originalProps.asc_getIsInsertRowBelow());
menu.items[7].setDisabled(!this._originalProps.asc_getIsInsertColumnLeft());
menu.items[8].setDisabled(!this._originalProps.asc_getIsInsertColumnRight());
menu.items[5].setDisabled(!this._originalProps.asc_getIsInsertRowAbove());
menu.items[6].setDisabled(!this._originalProps.asc_getIsInsertRowBelow());
menu.items[7].setDisabled(!this._originalProps.asc_getIsInsertColumnLeft());
menu.items[8].setDisabled(!this._originalProps.asc_getIsInsertColumnRight());
menu.items[10].setDisabled(!this._originalProps.asc_getIsDeleteRow());
menu.items[11].setDisabled(!this._originalProps.asc_getIsDeleteColumn());
menu.items[12].setDisabled(!this._originalProps.asc_getIsDeleteTable());
}
menu.items[10].setDisabled(!this._originalProps.asc_getIsDeleteRow());
menu.items[11].setDisabled(!this._originalProps.asc_getIsDeleteColumn());
menu.items[12].setDisabled(!this._originalProps.asc_getIsDeleteTable());
}, this));
this.btnEdit.menu.on('item:click', _.bind(this.onEditClick, this));
this.lockedControls.push(this.btnEdit);
this.btnRemDuplicates = new Common.UI.Button({
cls : 'btn-toolbar align-left',
iconCls : 'toolbar__icon btn-remove-duplicates',
caption : this.txtRemDuplicates,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
style : 'width: 100%;',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.btnRemDuplicates.on('click', _.bind(function(btn){
Common.NotificationCenter.trigger('data:remduplicates', this);
}, this));
this.lockedControls.push(this.btnRemDuplicates);
this.btnConvertRange = new Common.UI.Button({
cls : 'btn-toolbar align-left',
iconCls : 'toolbar__icon btn-convert-to-range',
caption : this.txtConvertToRange,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
style : 'width: 100%;',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.btnConvertRange.on('click', _.bind(function(btn){
if (this.api) this.api.asc_convertTableToRange(this._state.TableName);
Common.NotificationCenter.trigger('edit:complete', this);
}, this));
this.lockedControls.push(this.btnConvertRange);
this.btnInsertSlicer = new Common.UI.Button({
cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-big-slicer',
caption : this.txtSlicer,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
style : 'width: 100%;',
dataHint : '1',
dataHintDirection: 'left',
@ -259,18 +247,17 @@ define([
cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-big-pivot-sum',
caption : this.txtPivot,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
style : 'width: 100%;',
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
});
this.btnInsertPivot.on('click', _.bind(this.onInsertPiv, this))
this.lockedControls.push(this.btnInsertPivot);
this.chHeaderRow = new Common.UI.CheckBox({
labelText: this.txtHeaderRow,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set.wsLock, _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -279,7 +266,7 @@ define([
this.chTotalRow = new Common.UI.CheckBox({
labelText: this.txtTotalRow,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set.wsLock, _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -288,7 +275,7 @@ define([
this.chFirstColumn = new Common.UI.CheckBox({
labelText: this.txtFirstColumn,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set['FormatCells'], _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -297,7 +284,7 @@ define([
this.chLastColumn = new Common.UI.CheckBox({
labelText: this.txtLastColumn,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set['FormatCells'], _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -306,7 +293,7 @@ define([
this.chBandedRows = new Common.UI.CheckBox({
labelText: this.txtBandedRows,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set['FormatCells'], _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -315,7 +302,7 @@ define([
this.chBandedColumns = new Common.UI.CheckBox({
labelText: this.txtBandedColumns,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set['FormatCells'], _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -324,7 +311,7 @@ define([
this.chFilterButton = new Common.UI.CheckBox({
labelText: this.txtFilterButton,
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell],
lock : [_set.sheetLock, _set.lostConnect, _set.coAuth, _set.editCell, _set.wsLock, _set.cantModifyFilter],
dataHint : '1',
dataHintDirection: 'left',
dataHintOffset: 'small'
@ -335,7 +322,7 @@ define([
cls : 'btn-toolbar x-huge icon-top',
iconCls : 'toolbar__icon btn-big-pivot-sum',
caption : this.txtAltText,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
style : 'width: 100%;',
dataHint : '1',
dataHintDirection: 'left',
@ -360,7 +347,7 @@ define([
menuMaxHeight : 300,
groups : new Common.UI.DataViewGroupStore(),
autoWidth : true,
lock: [_set.editCell, _set.editText, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.selSlicer, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock],
lock: [_set.editCell, _set.selRangeEdit, _set.lostConnect, _set.coAuth, _set.wsLock, _set.cantModifyFilter],
beforeOpenHandler: function(e) {
var cmp = this,
menu = cmp.openButton.menu,
@ -408,16 +395,9 @@ define([
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
},
onInsertPiv: function() {
var me = this;
me.fireEvent('pivottable:create');
},
onCheckStyleChange: function(type, stateName, field, newValue, oldValue, eOpts) {
this._state[stateName] = undefined;
if (this.api)
this.api.asc_changeFormatTableInfo(this._state.TableName, type, newValue=='checked');
Common.NotificationCenter.trigger('edit:complete', this);
var me = this;
me.fireEvent('tabledesigntab:stylechange', [type, stateName, newValue]);
},
render: function (el) {
@ -427,26 +407,6 @@ define([
return this;
},
setApi: function(api) {
if (api) {
this.api = api;
}
return this;
},
onEditClick: function(menu, item, e) {
if (this.api) {
if (item.options.idx>=0 && item.options.idx<4)
this.api.asc_changeSelectionFormatTable(this._state.TableName, item.value);
else if (item.options.idx>=4 && item.options.idx<8) {
this.api.asc_insertCellsInTable(this._state.TableName, item.value);
} else {
this.api.asc_deleteCellsInTable(this._state.TableName, item.value);
}
}
Common.NotificationCenter.trigger('edit:complete', this);
},
getPanel: function () {
this.$el = $(_.template(template)( {} ));
var $host = this.$el;
@ -491,8 +451,11 @@ define([
},
getButtons: function(type) {
if (type===undefined)
if (type===undefined) {
return this.lockedControls;
} else if (type==='rem-duplicates') {
return this.btnRemDuplicates
}
return [];
},
@ -507,10 +470,10 @@ define([
txtResize: 'Resize table',
txtRowsCols: 'Rows & Columns',
tipRowsCols: 'Rows & Columns',
txtGroupPivot_Custom: 'Custom',
txtGroupPivot_Light: 'Light',
txtGroupPivot_Medium: 'Medium',
txtGroupPivot_Dark: 'Dark',
txtGroupTable_Custom: 'Custom',
txtGroupTable_Light: 'Light',
txtGroupTable_Medium: 'Medium',
txtGroupTable_Dark: 'Dark',
tipResize: 'Change the size of this table by adding or removing rows and columns.',
tipRemDuplicates: 'Removing duplicate lines from a sheet.',
tipConvertRange: 'Convert this table to a regular range of cells.',

View File

@ -4653,10 +4653,10 @@
"SSE.Views.TableDesignTab.txtResize": "Resize table",
"SSE.Views.TableDesignTab.txtRowsCols": "Rows & Columns",
"SSE.Views.TableDesignTab.tipRowsCols": "Rows & Columns",
"SSE.Views.TableDesignTab.txtGroupPivot_Custom": "Custom",
"SSE.Views.TableDesignTab.txtGroupPivot_Light": "Light",
"SSE.Views.TableDesignTab.txtGroupPivot_Medium": "Medium",
"SSE.Views.TableDesignTab.txtGroupPivot_Dark": "Dark",
"SSE.Views.TableDesignTab.txtGroupTable_Custom": "Custom",
"SSE.Views.TableDesignTab.txtGroupTable_Light": "Light",
"SSE.Views.TableDesignTab.txtGroupTable_Medium": "Medium",
"SSE.Views.TableDesignTab.txtGroupTable_Dark": "Dark",
"SSE.Views.TableDesignTab.tipResize": "Change the size of this table by adding or removing rows and columns.",
"SSE.Views.TableDesignTab.tipRemDuplicates": "Removing duplicate lines from a sheet.",
"SSE.Views.TableDesignTab.tipConvertRange": "Convert this table to a regular range of cells.",