[mobile] Comments (added check for the ability to add comments)

This commit is contained in:
JuliaSvinareva 2020-04-15 19:50:15 +03:00
parent 4d5f9edae8
commit cd4826ff92
10 changed files with 112 additions and 22 deletions

View file

@ -769,7 +769,7 @@ define([
me.updateViewComment();
}
if (window.SSE) {
SSE.getController('AddOther').sedHideAddComment(true);
SSE.getController('AddOther').setHideAddComment(true);
}
},
@ -779,7 +779,7 @@ define([
$('.container-view-comment').remove();
}
if (window.SSE) {
SSE.getController('AddOther').sedHideAddComment(false);
SSE.getController('AddOther').setHideAddComment(false);
}
},

View file

@ -462,7 +462,7 @@ define([
lockedHeader = objectValue.get_Locked();
}
if (objectType == Asc.c_oAscTypeSelectElement.Text) {
if (objectType == Asc.c_oAscTypeSelectElement.Paragraph) {
isText = true;
lockedText = objectValue.get_Locked();
} else if (objectType == Asc.c_oAscTypeSelectElement.Image) {
@ -571,7 +571,9 @@ define([
});
}
if (_canViewComments) {
var isObject = isShape || isChart || isImage || isTable;
var hideAddComment = !_canViewComments || me.api.can_AddQuotedComment() === false || lockedText || lockedTable || lockedImage || lockedHeader || (!isText && isObject);
if (!hideAddComment) {
arrItems.push({
caption: me.menuAddComment,
event: 'addcomment'

View file

@ -94,6 +94,51 @@ define([
var me = this;
$('#add-other-pagebreak').single('click', _.bind(me.onPageBreak, me));
$('#add-other-columnbreak').single('click', _.bind(me.onColumnBreak, me));
this.view.hideInsertComments = this.isHideInsertComment();
},
isHideInsertComment: function() {
var stack = this.api.getSelectedElements();
var isText = false,
isTable = false,
isImage = false,
isChart = false,
isShape = false,
isLink = false,
lockedText = false,
lockedTable = false,
lockedImage = false,
lockedHeader = false;
_.each(stack, function (item) {
var objectType = item.get_ObjectType(),
objectValue = item.get_ObjectValue();
if (objectType == Asc.c_oAscTypeSelectElement.Header) {
lockedHeader = objectValue.get_Locked();
}
if (objectType == Asc.c_oAscTypeSelectElement.Paragraph) {
isText = true;
lockedText = objectValue.get_Locked();
} else if (objectType == Asc.c_oAscTypeSelectElement.Image) {
lockedImage = objectValue.get_Locked();
if (objectValue && objectValue.get_ChartProperties()) {
isChart = true;
} else if (objectType && objectValue.get_ShapeProperties()) {
isShape = true;
} else {
isImage = true;
}
} else if (objectType == Asc.c_oAscTypeSelectElement.Table) {
isTable = true;
lockedTable = objectValue.get_Locked();
} else if (objectType == Asc.c_oAscTypeSelectElement.Hyperlink) {
isLink = true;
}
});
if (stack.length > 0) {
var isObject = isShape || isChart || isImage || isTable;
return (this.api.can_AddQuotedComment() === false || lockedText || lockedTable || lockedImage || lockedHeader || (!isText && isObject));
}
return true;
},
onPageShow: function (view, pageId) {

View file

@ -70,7 +70,12 @@ define([
$('#add-other-link').single('click', _.bind(me.showLink, me));
$('#add-other-pagenumber').single('click', _.bind(me.showPagePosition, me));
$('#add-other-footnote').single('click', _.bind(me.showPageFootnote, me));
$('#add-other-comment').single('click', _.bind(me.showPageComment, me));
if (this.hideInsertComments) {
$('#item-comment').hide();
} else {
$('#item-comment').show();
$('#add-other-comment').single('click', _.bind(me.showPageComment, me));
}
me.initControls();
},

View file

@ -350,7 +350,8 @@ define([
});
}
if (_canViewComments) {
var hideAddComment = (isText && isChart) || me.api.can_AddQuotedComment() === false || !_canViewComments;
if (!hideAddComment) {
arrItems.push({
caption: me.menuAddComment,
event: 'addcomment'

View file

@ -83,14 +83,37 @@ define([
initEvents: function () {
var me = this;
this.view.hideInsertComments = this.isHideInsertComment();
},
isHideInsertComment: function() {
var stack = this.api.getSelectedElements();
var isText = false,
isChart = false;
_.each(stack, function (item) {
var objectType = item.get_ObjectType();
if (objectType == Asc.c_oAscTypeSelectElement.Paragraph) {
isText = true;
} else if (objectType == Asc.c_oAscTypeSelectElement.Chart) {
isChart = true;
}
});
if (stack.length > 0) {
var topObject = stack[stack.length - 1],
topObjectValue = topObject.get_ObjectValue(),
objectLocked = _.isFunction(topObjectValue.get_Locked) ? topObjectValue.get_Locked() : false;
!objectLocked && (objectLocked = _.isFunction(topObjectValue.get_LockDelete) ? topObjectValue.get_LockDelete() : false);
if (!objectLocked) {
return ((isText && isChart) || this.api.can_AddQuotedComment() === false);
}
}
return true;
},
onPageShow: function (view, pageId) {
var me = this;
$('.page[data-page=addother-comment] li a').single('click', _.buffered(me.onInsertComment, 100, me));
if (pageId == '#addother-insert-comment') {
me.initInsertComment(false);
}

View file

@ -64,11 +64,14 @@ define([
},
initEvents: function () {
var me = this;
if (this.hideInsertComments) {
$('#item-comment').hide();
} else {
$('#item-comment').show();
$('#add-other-comment').single('click', _.bind(this.showPageComment, this));
}
$('#add-other-comment').single('click', _.bind(me.showPageComment, me));
me.initControls();
this.initControls();
},
// Render layout

View file

@ -416,7 +416,7 @@ define([
caption: me.menuViewComment,
event: 'viewcomment'
});
} else {
} else if (iscellmenu) {
arrItems.push({
caption: me.menuAddComment,
event: 'addcomment'

View file

@ -80,8 +80,8 @@ define([
this.view.canViewComments = mode.canViewComments;
},
sedHideAddComment: function(hide) {
this.view.isHideAddComment = hide; //prohibit adding multiple comments in one cell
setHideAddComment: function(hide) {
this.view.isComments = hide; //prohibit adding multiple comments in one cell
},
onLaunch: function () {
@ -92,6 +92,17 @@ define([
if ( args && !(_.indexOf(args.panels, 'image') < 0) ) {
this.onPageShow(this.getView('AddOther'), '#addother-insimage');
}
this.view.hideInsertComments = this.isHideInsertComment();
},
isHideInsertComment: function() {
var cellinfo = this.api.asc_getCellInfo();
var iscelllocked = cellinfo.asc_getLocked(),
seltype = cellinfo.asc_getFlags().asc_getSelectionType();
if (seltype === Asc.c_oAscSelectionType.RangeCells && !iscelllocked) {
return false;
}
return true;
},
onPageShow: function (view, pageId) {
@ -148,7 +159,7 @@ define([
var value = $('#comment-text').val();
if (value.length > 0) {
if (SSE.getController('Common.Controllers.Collaboration').onAddNewComment(value, documentFlag)) {
this.view.isHideAddComment = true;
this.view.isComments = true;
}
SSE.getController('AddContainer').hideModal();
}

View file

@ -135,7 +135,12 @@ define([
$page.find('#add-other-insimage').single('click', _.bind(me.showInsertImage, me));
$page.find('#add-other-link').single('click', _.bind(me.showInsertLink, me));
$page.find('#add-other-sort').single('click', _.bind(me.showSortPage, me));
$page.find('#add-other-comment').single('click', _.bind(me.showPageComment, me));
if (me.hideInsertComments || me.isComments) {
$('#item-comment').hide();
} else {
$('#item-comment').show();
$('#add-other-comment').single('click', _.bind(me.showPageComment, me));
}
me.initControls();
},
@ -156,11 +161,6 @@ define([
if (!this.canViewComments) {
this.layout.find('#addother-root-view #item-comment').remove();
}
if (this.isHideAddComment) {
this.layout.find('#addother-root-view #item-comment').hide();
} else {
this.layout.find('#addother-root-view #item-comment').show();
}
return this.layout
.find('#addother-root-view')
.html();