[DE mobile] Fix locked settings in context menu

This commit is contained in:
Julia Svinareva 2019-05-08 14:31:48 +03:00
parent d8a722c1c4
commit 01440c04af

View file

@ -407,15 +407,25 @@ define([
isImage = false, isImage = false,
isChart = false, isChart = false,
isShape = false, isShape = false,
isLink = false; isLink = false,
lockedText = false,
lockedTable = false,
lockedImage = false,
lockedHeader = false;
_.each(stack, function (item) { _.each(stack, function (item) {
var objectType = item.get_ObjectType(), var objectType = item.get_ObjectType(),
objectValue = item.get_ObjectValue(); objectValue = item.get_ObjectValue();
if (objectType == Asc.c_oAscTypeSelectElement.Header) {
lockedHeader = objectValue.get_Locked();
}
if (objectType == Asc.c_oAscTypeSelectElement.Text) { if (objectType == Asc.c_oAscTypeSelectElement.Text) {
isText = true; isText = true;
lockedText = objectValue.get_Locked();
} else if (objectType == Asc.c_oAscTypeSelectElement.Image) { } else if (objectType == Asc.c_oAscTypeSelectElement.Image) {
lockedImage = objectValue.get_Locked();
if (objectValue && objectValue.get_ChartProperties()) { if (objectValue && objectValue.get_ChartProperties()) {
isChart = true; isChart = true;
} else if (objectType && objectValue.get_ShapeProperties()) { } else if (objectType && objectValue.get_ShapeProperties()) {
@ -425,22 +435,20 @@ define([
} }
} else if (objectType == Asc.c_oAscTypeSelectElement.Table) { } else if (objectType == Asc.c_oAscTypeSelectElement.Table) {
isTable = true; isTable = true;
lockedTable = objectValue.get_Locked();
} else if (objectType == Asc.c_oAscTypeSelectElement.Hyperlink) { } else if (objectType == Asc.c_oAscTypeSelectElement.Hyperlink) {
isLink = true; isLink = true;
} }
}); });
if (stack.length > 0) { if (stack.length > 0) {
var topObject = _.find(stack.reverse(), function(obj){ return obj.get_ObjectType() != Asc.c_oAscTypeSelectElement.SpellCheck; }),
topObjectValue = topObject.get_ObjectValue(),
objectLocked = _.isFunction(topObjectValue.get_Locked) ? topObjectValue.get_Locked() : false;
var swapItems = function(items, indexBefore, indexAfter) { var swapItems = function(items, indexBefore, indexAfter) {
items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0]; items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0];
}; };
if (!objectLocked && _isEdit && !me.isDisconnected) { if (_isEdit && !me.isDisconnected) {
if (canCopy) { if (!lockedText && !lockedTable && !lockedImage && !lockedHeader && canCopy) {
menuItems.push({ menuItems.push({
caption: me.menuCut, caption: me.menuCut,
event: 'cut' event: 'cut'
@ -450,43 +458,49 @@ define([
swapItems(menuItems, 0, 1); swapItems(menuItems, 0, 1);
} }
menuItems.push({ if (!lockedText && !lockedTable && !lockedImage && !lockedHeader) {
caption: me.menuPaste, menuItems.push({
event: 'paste' caption: me.menuPaste,
}); event: 'paste'
});
}
if(isTable && me.api.CheckBeforeMergeCells()) { if(isTable && me.api.CheckBeforeMergeCells() && !lockedTable && !lockedHeader) {
menuItems.push({ menuItems.push({
caption: me.menuMerge, caption: me.menuMerge,
event: 'merge' event: 'merge'
}); });
} }
if(isTable && me.api.CheckBeforeSplitCells()) { if(isTable && me.api.CheckBeforeSplitCells() && !lockedTable && !lockedHeader) {
menuItems.push({ menuItems.push({
caption: me.menuSplit, caption: me.menuSplit,
event: 'split' event: 'split'
}); });
} }
menuItems.push({ if(!lockedText && !lockedTable && !lockedImage && !lockedHeader) {
caption: me.menuDelete, menuItems.push({
event: 'delete' caption: me.menuDelete,
}); event: 'delete'
});
}
if(isTable) { if(isTable && !lockedTable && !lockedText && !lockedHeader) {
menuItems.push({ menuItems.push({
caption: me.menuDeleteTable, caption: me.menuDeleteTable,
event: 'deletetable' event: 'deletetable'
}); });
} }
menuItems.push({ if(!lockedText && !lockedTable && !lockedImage && !lockedHeader){
caption: me.menuEdit, menuItems.push({
event: 'edit' caption: me.menuEdit,
}); event: 'edit'
});
}
if (!_.isEmpty(me.api.can_AddHyperlink())) { if (!_.isEmpty(me.api.can_AddHyperlink()) && !lockedHeader) {
menuItems.push({ menuItems.push({
caption: me.menuAddLink, caption: me.menuAddLink,
event: 'addlink' event: 'addlink'