[SSE] Добавлена проверка валидности имени таблицы.
В контекстное меню добавлены пункты Select, Delete, Insert для формат. таблицы (+ скрыты соответствующие пункты для работы с ячейками).
This commit is contained in:
parent
936ae4b838
commit
4e85243c90
|
@ -121,6 +121,9 @@ define([
|
||||||
view.pmiDeleteCells.menu.on('item:click', _.bind(me.onDeleteCells, me));
|
view.pmiDeleteCells.menu.on('item:click', _.bind(me.onDeleteCells, me));
|
||||||
view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me));
|
view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me));
|
||||||
view.pmiClear.menu.on('item:click', _.bind(me.onClear, me));
|
view.pmiClear.menu.on('item:click', _.bind(me.onClear, me));
|
||||||
|
view.pmiSelectTable.menu.on('item:click', _.bind(me.onSelectTable, me));
|
||||||
|
view.pmiInsertTable.menu.on('item:click', _.bind(me.onInsertTable, me));
|
||||||
|
view.pmiDeleteTable.menu.on('item:click', _.bind(me.onDeleteTable, me));
|
||||||
view.pmiInsFunction.on('click', _.bind(me.onInsFunction, me));
|
view.pmiInsFunction.on('click', _.bind(me.onInsFunction, me));
|
||||||
view.menuAddHyperlink.on('click', _.bind(me.onInsHyperlink, me));
|
view.menuAddHyperlink.on('click', _.bind(me.onInsHyperlink, me));
|
||||||
view.menuEditHyperlink.on('click', _.bind(me.onInsHyperlink, me));
|
view.menuEditHyperlink.on('click', _.bind(me.onInsHyperlink, me));
|
||||||
|
@ -317,6 +320,33 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSelectTable: function(menu, item) {
|
||||||
|
if (this.api && this.documentHolder.ssMenu.formatTableName) {
|
||||||
|
this.api.asc_changeSelectionFormatTable(this.documentHolder.ssMenu.formatTableName, item.value);
|
||||||
|
|
||||||
|
Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
|
||||||
|
Common.component.Analytics.trackEvent('DocumentHolder', 'Select Table');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onInsertTable: function(menu, item) {
|
||||||
|
if (this.api && this.documentHolder.ssMenu.formatTableName) {
|
||||||
|
this.api.asc_insertCellsInTable(this.documentHolder.ssMenu.formatTableName, item.value);
|
||||||
|
|
||||||
|
Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
|
||||||
|
Common.component.Analytics.trackEvent('DocumentHolder', 'Insert to Table');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onDeleteTable: function(menu, item) {
|
||||||
|
if (this.api && this.documentHolder.ssMenu.formatTableName) {
|
||||||
|
this.api.asc_deleteCellsInTable(this.documentHolder.ssMenu.formatTableName, item.value);
|
||||||
|
|
||||||
|
Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
|
||||||
|
Common.component.Analytics.trackEvent('DocumentHolder', 'Delete from Table');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onInsFunction: function(item) {
|
onInsFunction: function(item) {
|
||||||
var controller = this.getApplication().getController('FormulaDialog');
|
var controller = this.getApplication().getController('FormulaDialog');
|
||||||
if (controller && this.api) {
|
if (controller && this.api) {
|
||||||
|
@ -1115,14 +1145,20 @@ define([
|
||||||
seltype !== c_oAscSelectionType.RangeChart && seltype !== c_oAscSelectionType.RangeChartText && seltype !== c_oAscSelectionType.RangeShapeText)) {
|
seltype !== c_oAscSelectionType.RangeChart && seltype !== c_oAscSelectionType.RangeChartText && seltype !== c_oAscSelectionType.RangeShapeText)) {
|
||||||
if (!showMenu && !documentHolder.ssMenu.isVisible()) return;
|
if (!showMenu && !documentHolder.ssMenu.isVisible()) return;
|
||||||
|
|
||||||
var iscelledit = this.api.isCellEdited;
|
var iscelledit = this.api.isCellEdited,
|
||||||
|
formatTableInfo = cellinfo.asc_getFormatTableInfo(),
|
||||||
|
isintable = (formatTableInfo !== null);
|
||||||
|
documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null;
|
||||||
|
|
||||||
documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu);
|
documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu);
|
||||||
documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft);
|
documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft);
|
||||||
documentHolder.pmiDeleteEntire.setVisible(isrowmenu||iscolmenu);
|
documentHolder.pmiDeleteEntire.setVisible(isrowmenu||iscolmenu);
|
||||||
documentHolder.pmiInsertCells.setVisible(iscellmenu && !iscelledit);
|
documentHolder.pmiInsertCells.setVisible(iscellmenu && !iscelledit && !isintable);
|
||||||
documentHolder.pmiDeleteCells.setVisible(iscellmenu && !iscelledit);
|
documentHolder.pmiDeleteCells.setVisible(iscellmenu && !iscelledit && !isintable);
|
||||||
documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
|
documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable);
|
||||||
|
documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable);
|
||||||
|
documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable);
|
||||||
|
documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit && !isintable);
|
||||||
documentHolder.pmiInsFunction.setVisible(iscellmenu||insfunc);
|
documentHolder.pmiInsFunction.setVisible(iscellmenu||insfunc);
|
||||||
documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit);
|
documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit);
|
||||||
|
|
||||||
|
@ -1138,7 +1174,7 @@ define([
|
||||||
documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes);
|
documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes);
|
||||||
|
|
||||||
/** coauthoring begin **/
|
/** coauthoring begin **/
|
||||||
documentHolder.ssMenu.items[10].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
|
documentHolder.ssMenu.items[13].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
|
||||||
documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
|
documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
|
||||||
/** coauthoring end **/
|
/** coauthoring end **/
|
||||||
documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc);
|
documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc);
|
||||||
|
|
|
@ -72,6 +72,19 @@ define([
|
||||||
value : 'paste'
|
value : 'paste'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
me.pmiSelectTable = new Common.UI.MenuItem({
|
||||||
|
caption : me.txtSelect,
|
||||||
|
menu : new Common.UI.Menu({
|
||||||
|
menuAlign : 'tl-tr',
|
||||||
|
items: [
|
||||||
|
{ caption: this.selectRowText, value: c_oAscChangeSelectionFormatTable.row},
|
||||||
|
{ caption: this.selectColumnText, value: c_oAscChangeSelectionFormatTable.column},
|
||||||
|
{ caption: this.selectDataText, value: c_oAscChangeSelectionFormatTable.data},
|
||||||
|
{ caption: this.selectTableText, value: c_oAscChangeSelectionFormatTable.all}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
me.pmiInsertEntire = new Common.UI.MenuItem({
|
me.pmiInsertEntire = new Common.UI.MenuItem({
|
||||||
caption : me.txtInsert
|
caption : me.txtInsert
|
||||||
});
|
});
|
||||||
|
@ -97,6 +110,19 @@ define([
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
me.pmiInsertTable = new Common.UI.MenuItem({
|
||||||
|
caption : me.txtInsert,
|
||||||
|
menu : new Common.UI.Menu({
|
||||||
|
menuAlign : 'tl-tr',
|
||||||
|
items: [
|
||||||
|
{ caption: me.insertRowAboveText, value: c_oAscInsertOptions.InsertTableRowAbove},
|
||||||
|
{ caption: me.insertRowBelowText, value: c_oAscInsertOptions.InsertTableRowBelow},
|
||||||
|
{ caption: me.insertColumnLeftText, value: c_oAscInsertOptions.InsertTableColLeft},
|
||||||
|
{ caption: me.insertColumnRightText, value: c_oAscInsertOptions.InsertTableColRight}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
me.pmiDeleteEntire = new Common.UI.MenuItem({
|
me.pmiDeleteEntire = new Common.UI.MenuItem({
|
||||||
caption : me.txtDelete
|
caption : me.txtDelete
|
||||||
|
@ -124,6 +150,18 @@ define([
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
me.pmiDeleteTable = new Common.UI.MenuItem({
|
||||||
|
caption : me.txtDelete,
|
||||||
|
menu : new Common.UI.Menu({
|
||||||
|
menuAlign : 'tl-tr',
|
||||||
|
items: [
|
||||||
|
{ caption: this.deleteRowText, value: c_oAscDeleteOptions.DeleteRows},
|
||||||
|
{ caption: this.deleteColumnText, value: c_oAscDeleteOptions.DeleteColumns},
|
||||||
|
{ caption: this.deleteTableText, value: c_oAscDeleteOptions.DeleteColumns}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
me.pmiClear = new Common.UI.MenuItem({
|
me.pmiClear = new Common.UI.MenuItem({
|
||||||
caption : me.txtClear,
|
caption : me.txtClear,
|
||||||
menu : new Common.UI.Menu({
|
menu : new Common.UI.Menu({
|
||||||
|
@ -241,10 +279,13 @@ define([
|
||||||
me.pmiCopy,
|
me.pmiCopy,
|
||||||
me.pmiPaste,
|
me.pmiPaste,
|
||||||
{caption: '--'},
|
{caption: '--'},
|
||||||
|
me.pmiSelectTable,
|
||||||
me.pmiInsertEntire,
|
me.pmiInsertEntire,
|
||||||
me.pmiInsertCells,
|
me.pmiInsertCells,
|
||||||
|
me.pmiInsertTable,
|
||||||
me.pmiDeleteEntire,
|
me.pmiDeleteEntire,
|
||||||
me.pmiDeleteCells,
|
me.pmiDeleteCells,
|
||||||
|
me.pmiDeleteTable,
|
||||||
me.pmiClear,
|
me.pmiClear,
|
||||||
me.pmiSortCells,
|
me.pmiSortCells,
|
||||||
{caption: '--'},
|
{caption: '--'},
|
||||||
|
@ -544,7 +585,19 @@ define([
|
||||||
direct270Text: 'Rotate at 270°',
|
direct270Text: 'Rotate at 270°',
|
||||||
txtAddNamedRange: 'Define Name',
|
txtAddNamedRange: 'Define Name',
|
||||||
textFreezePanes: 'Freeze Panes',
|
textFreezePanes: 'Freeze Panes',
|
||||||
textUnFreezePanes: 'Unfreeze Panes'
|
textUnFreezePanes: 'Unfreeze Panes',
|
||||||
|
txtSelect: 'Select',
|
||||||
|
selectRowText : 'Select Row',
|
||||||
|
selectColumnText : 'Select Entire Column',
|
||||||
|
selectDataText : 'Select Column Data',
|
||||||
|
selectTableText : 'Select Table',
|
||||||
|
insertRowAboveText : 'Insert Row Above',
|
||||||
|
insertRowBelowText : 'Insert Row Below',
|
||||||
|
insertColumnLeftText : 'Insert Column Left',
|
||||||
|
insertColumnRightText : 'Insert Column Right',
|
||||||
|
deleteRowText : 'Delete Row',
|
||||||
|
deleteColumnText : 'Delete Column',
|
||||||
|
deleteTableText : 'Delete Table'
|
||||||
|
|
||||||
}, SSE.Views.DocumentHolder || {}));
|
}, SSE.Views.DocumentHolder || {}));
|
||||||
});
|
});
|
|
@ -38,6 +38,7 @@ define([
|
||||||
this._state = {
|
this._state = {
|
||||||
TableName: '',
|
TableName: '',
|
||||||
TemplateName: '',
|
TemplateName: '',
|
||||||
|
Range: '',
|
||||||
CheckHeader: false,
|
CheckHeader: false,
|
||||||
CheckTotal: false,
|
CheckTotal: false,
|
||||||
CheckBanded: false,
|
CheckBanded: false,
|
||||||
|
@ -45,7 +46,8 @@ define([
|
||||||
CheckLast: false,
|
CheckLast: false,
|
||||||
CheckColBanded: false,
|
CheckColBanded: false,
|
||||||
CheckFilter: false,
|
CheckFilter: false,
|
||||||
DisabledControls: false
|
DisabledControls: false,
|
||||||
|
TableNameError: false
|
||||||
};
|
};
|
||||||
this.lockedControls = [];
|
this.lockedControls = [];
|
||||||
this._locked = false;
|
this._locked = false;
|
||||||
|
@ -127,9 +129,8 @@ define([
|
||||||
name : 'name',
|
name : 'name',
|
||||||
style : 'width: 100%;',
|
style : 'width: 100%;',
|
||||||
validateOnBlur: false
|
validateOnBlur: false
|
||||||
}).on('changed:after', function(input, newValue, oldValue) {
|
|
||||||
// set table name
|
|
||||||
});
|
});
|
||||||
|
this.txtTableName.on('changed:after', _.bind(this.onTableNameChanged, this));
|
||||||
this.lockedControls.push(this.txtTableName);
|
this.lockedControls.push(this.txtTableName);
|
||||||
|
|
||||||
this.btnSelectData = new Common.UI.Button({
|
this.btnSelectData = new Common.UI.Button({
|
||||||
|
@ -197,6 +198,44 @@ define([
|
||||||
Common.NotificationCenter.trigger('edit:complete', this);
|
Common.NotificationCenter.trigger('edit:complete', this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onTableNameChanged: function(input, newValue, oldValue) {
|
||||||
|
this._state.TableName = '';
|
||||||
|
var me = this,
|
||||||
|
isvalid = this.api.asc_checkDefinedName(newValue, null);
|
||||||
|
if (isvalid.asc_getStatus() === true) isvalid = true;
|
||||||
|
else {
|
||||||
|
switch (isvalid.asc_getReason()) {
|
||||||
|
case c_oAscDefinedNameReason.IsLocked:
|
||||||
|
isvalid = this.textIsLocked;
|
||||||
|
break;
|
||||||
|
case c_oAscDefinedNameReason.Existed:
|
||||||
|
isvalid = (oldValue.toLowerCase() == newValue.toLowerCase()) ? true : this.textExistName;
|
||||||
|
break;
|
||||||
|
case c_oAscDefinedNameReason.NameReserved:
|
||||||
|
isvalid = this.textReservedName;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
isvalid = this.textInvalidName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isvalid === true) {
|
||||||
|
// this.api.asc_editDefinedNames(this._state.TableName, new Asc.asc_CDefName(newValue, this._state.Range, null, true));
|
||||||
|
Common.NotificationCenter.trigger('edit:complete', this);
|
||||||
|
} else if (!this._state.TableNameError) {
|
||||||
|
this._state.TableNameError = true;
|
||||||
|
Common.UI.alert({
|
||||||
|
msg: isvalid,
|
||||||
|
title: this.notcriticalErrorTitle,
|
||||||
|
iconCls: 'warn',
|
||||||
|
buttons: ['ok'],
|
||||||
|
callback: function(btn){
|
||||||
|
Common.NotificationCenter.trigger('edit:complete', this);
|
||||||
|
me._state.TableNameError = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
var el = $(this.el);
|
var el = $(this.el);
|
||||||
el.html(this.template({
|
el.html(this.template({
|
||||||
|
@ -225,6 +264,8 @@ define([
|
||||||
this._state.TableName=value;
|
this._state.TableName=value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._state.Range = props.asc_getTableRange();
|
||||||
|
|
||||||
//for table-template
|
//for table-template
|
||||||
value = props.asc_getTableStyleName();
|
value = props.asc_getTableStyleName();
|
||||||
if (this._state.TemplateName!==value || this._isTemplatesChanged) {
|
if (this._state.TemplateName!==value || this._isTemplatesChanged) {
|
||||||
|
@ -324,8 +365,7 @@ define([
|
||||||
var handlerDlg = function(dlg, result) {
|
var handlerDlg = function(dlg, result) {
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
me.api.asc_setSelectionDialogMode(c_oAscSelectionDialogType.None);
|
me.api.asc_setSelectionDialogMode(c_oAscSelectionDialogType.None);
|
||||||
if (me._state.Tablename)
|
// me.api.asc_changeAutoFilter(me._state.TableName, c_oAscChangeFilterOptions.style, fmtname);
|
||||||
me.api.asc_changeAutoFilter(me._state.Tablename, c_oAscChangeFilterOptions.style, fmtname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||||
|
@ -380,7 +420,12 @@ define([
|
||||||
textFilter : 'Filter button',
|
textFilter : 'Filter button',
|
||||||
textTableName : 'Table Name',
|
textTableName : 'Table Name',
|
||||||
textResize : 'Resize table',
|
textResize : 'Resize table',
|
||||||
textSelectData : 'Select Data'
|
textSelectData : 'Select Data',
|
||||||
|
textInvalidName : 'ERROR! Invalid range name',
|
||||||
|
textExistName : 'ERROR! Range with such a name already exists',
|
||||||
|
textIsLocked : 'This element is being edited by another user.',
|
||||||
|
notcriticalErrorTitle : 'Warning',
|
||||||
|
textReservedName : 'The name you are trying to use is already referenced in cell formulas. Please use some other name.'
|
||||||
|
|
||||||
}, SSE.Views.TableSettings || {}));
|
}, SSE.Views.TableSettings || {}));
|
||||||
});
|
});
|
Loading…
Reference in a new issue