diff --git a/apps/common/mobile/lib/controller/collaboration/Comments.jsx b/apps/common/mobile/lib/controller/collaboration/Comments.jsx index a92e56edd..125112339 100644 --- a/apps/common/mobile/lib/controller/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Comments.jsx @@ -272,10 +272,7 @@ class AddCommentController extends Component { !!comment.asc_putDocumentFlag && comment.asc_putDocumentFlag(documentFlag); api.asc_addComment(comment); - - return true; } - return false; } render() { return( @@ -316,10 +313,10 @@ class EditCommentController extends Component { ascComment.asc_putDocumentFlag(comment.unattached); } - var reply = comment.replies; + const reply = comment.replies; if (reply && reply.length > 0) { reply.forEach((reply) => { - var addReply = (typeof Asc.asc_CCommentDataWord !== 'undefined' ? new Asc.asc_CCommentDataWord(null) : new Asc.asc_CCommentData(null)); + const addReply = (typeof Asc.asc_CCommentDataWord !== 'undefined' ? new Asc.asc_CCommentDataWord(null) : new Asc.asc_CCommentData(null)); if (addReply) { addReply.asc_putText(reply.reply); addReply.asc_putTime(utcDateToString(new Date(reply.time))); diff --git a/apps/common/mobile/lib/store/comments.js b/apps/common/mobile/lib/store/comments.js index 36928d62b..86248d9d2 100644 --- a/apps/common/mobile/lib/store/comments.js +++ b/apps/common/mobile/lib/store/comments.js @@ -7,7 +7,6 @@ export class storeComments { collectionComments: observable, groupCollectionComments: observable, filter: observable, - groupCollectionFilter: observable, showComments: observable, changeShowComment: action, @@ -17,7 +16,7 @@ export class storeComments { changeComment: action, changeFilter: action, - sortComments: computed, + groupCollectionFilter: computed, isOpenEditComment: observable, openEditComment: action, @@ -31,7 +30,6 @@ export class storeComments { groupCollectionComments = []; filter = undefined; - groupCollectionFilter = []; // for sse showComments = []; changeShowComment (uid) { @@ -42,54 +40,16 @@ export class storeComments { } addComment (comment) { - comment.groupName ? this.addCommentToGroupCollection(comment) : this.addCommentToCollection(comment); - } - - addCommentToCollection (comment) { - this.collectionComments.push(comment); - } - - addCommentToGroupCollection (comment) { - const groupName = comment.groupName; - if (!this.groupCollectionComments[groupName]) { - this.groupCollectionComments[groupName] = []; - } - this.groupCollectionComments[groupName].push(comment); - if (typeof this.filter === 'object' && this.filter.indexOf(groupName) !== -1) { - this.groupCollectionFilter.push(comment); - } + comment.groupName ? this.groupCollectionComments.push(comment) : this.collectionComments.push(comment); } removeComment (id) { - if (this.collectionComments.length > 0) { - this.removeCommentFromCollection(id); - } else { - this.removeCommentFromGroups(id); - } - } - - removeCommentFromCollection (id) { - const index = this.collectionComments.findIndex((comment) => { + const collection = this.collectionComments.length > 0 ? this.collectionComments : this.groupCollectionComments; + const index = collection.findIndex((comment) => { return comment.uid === id; }); if (index !== -1) { - this.collectionComments.splice(index, 1); - } - } - - removeCommentFromGroups (id) { - for (let name in this.groupCollectionComments) { - const store = this.groupCollectionComments[name]; - const comment = store.find((item) => { - return item.uid === id; - }); - const index = store.indexOf(comment); - if (index !== -1) { - this.groupCollectionComments[name].splice(index, 1); - if (typeof this.filter === 'object' && this.filter.indexOf(name) !== -1) { - this.groupCollectionFilter.splice(this.groupCollectionFilter.indexOf(comment), 1); - } - } + collection.splice(index, 1); } } @@ -111,43 +71,28 @@ export class storeComments { } changeFilter (filter) { - let comments = []; this.filter = filter; - filter.forEach((item) => { - if (!this.groupCollectionComments[item]) - this.groupCollectionComments[item] = []; - comments = comments.concat(this.groupCollectionComments[item]); - }); - this.groupCollectionFilter = comments; } findComment (id) { - let comment = this.collectionComments.find((item) => { + const collection = this.collectionComments.length > 0 ? this.collectionComments : this.groupCollectionComments; + let comment = collection.find((item) => { return item.uid === id; }); - if (!comment) { - comment = this.findCommentInGroup(id); - } return comment; } - findCommentInGroup (id) { - let model; - for (let name in this.groupCollectionComments) { - const store = this.groupCollectionComments[name]; - const uid = typeof id === 'object' && id.isArray() ? id[0] : id; - model = store.find((item) => { - return item.uid === uid; + get groupCollectionFilter () { + if (this.filter && this.groupCollectionComments.length > 0) { + const arr = []; + this.filter.forEach((groupName) => { + this.groupCollectionComments.forEach((comment) => { + if (comment.groupName === groupName) { + arr.push(comment); + } + }); }); - if (model) return model; - } - return model; - } - - get sortComments () { - const comments = (this.groupCollectionFilter.length !== 0) ? this.groupCollectionFilter : (this.collectionComments.length !== 0 ? this.collectionComments : false); - if (comments.length > 0) { - return [...comments].sort((a, b) => a.time > b.time ? 1 : -1); + return arr; } return false; } diff --git a/apps/common/mobile/lib/view/collaboration/Comments.jsx b/apps/common/mobile/lib/view/collaboration/Comments.jsx index 2cdf138da..2fd0dbdfa 100644 --- a/apps/common/mobile/lib/view/collaboration/Comments.jsx +++ b/apps/common/mobile/lib/view/collaboration/Comments.jsx @@ -41,12 +41,11 @@ const AddCommentPopup = inject("storeComments")(observer(props => { { - if (props.onAddNewComment(stateText, false)) { - f7.popup.close('.add-comment-popup'); - setTimeout(() => { - props.closeAddComment(); - }, 500) - } + f7.popup.close('.add-comment-popup'); + setTimeout(() => { + props.closeAddComment(); + props.onAddNewComment(stateText, false) + }, 500); }}> {Device.android ? : _t.textDone} @@ -108,9 +107,10 @@ const AddCommentDialog = inject("storeComments")(observer(props => { const done = document.getElementById('comment-done'); done.addEventListener('click', () => { const value = document.getElementById('comment-text').value; - if (value.length > 0 && props.onAddNewComment(value, false)) { + if (value.length > 0) { f7.dialog.close(); props.closeAddComment(); + props.onAddNewComment(value, false); } }); const area = document.getElementById('comment-text'); @@ -197,16 +197,20 @@ const EditCommentPopup = inject("storeComments")(observer(({storeComments, comme { f7.popup.close('.edit-comment-popup'); - storeComments.openEditComment(false); + setTimeout(() => { + storeComments.openEditComment(false); + }, 500); }}>{_t.textCancel} {_t.textEditComment} { - onEditComment(comment, stateText); f7.popup.close('.edit-comment-popup'); - storeComments.openEditComment(false); + setTimeout(() => { + storeComments.openEditComment(false); + onEditComment(comment, stateText); + }, 500); }} > {Device.android ? : _t.textDone} @@ -317,17 +321,21 @@ const AddReplyPopup = inject("storeComments")(observer(({storeComments, userInfo { - storeComments.openAddReply(false); f7.popup.close('.add-reply-popup'); + setTimeout(() => { + storeComments.openAddReply(false); + }, 500); }}>{_t.textCancel} {_t.textAddReply} { - onAddReply(comment, stateText); - storeComments.openAddReply(false); f7.popup.close('.add-reply-popup'); + setTimeout(() => { + storeComments.openAddReply(false); + onAddReply(comment, stateText); + }, 500); }}> {Device.android ? : _t.textDone} @@ -433,16 +441,20 @@ const EditReplyPopup = inject("storeComments")(observer(({storeComments, comment { f7.popup.close('.edit-reply-popup'); - storeComments.openEditReply(false); + setTimeout(() => { + storeComments.openEditReply(false); + }, 500); }}>{_t.textCancel} {_t.textEditReply} { - onEditReply(comment, reply, stateText); f7.popup.close('.edit-reply-popup'); - storeComments.openEditReply(false); + setTimeout(() => { + storeComments.openEditReply(false); + onEditReply(comment, reply, stateText); + }, 500); }} > {Device.android ? : _t.textDone} @@ -548,7 +560,8 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes const isAndroid = Device.android; const viewMode = !storeAppOptions.canComments; - const comments = storeComments.sortComments; + const comments = storeComments.groupCollectionFilter || storeComments.collectionComments; + const sortComments = comments.length > 0 ? [...comments].sort((a, b) => a.time > b.time ? 1 : -1) : null; const [clickComment, setComment] = useState(); const [commentActionsOpened, openActionComment] = useState(false); @@ -559,10 +572,10 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes return ( - {!comments ? + {!sortComments ?
{_t.textNoComments}
: - {comments.map((comment, indexComment) => { + {sortComments.map((comment, indexComment) => { return (
diff --git a/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx b/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx index c07d48a8a..85ffc2e93 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/add/AddOther.jsx @@ -22,7 +22,8 @@ class AddOtherController extends Component { const cellinfo = Common.EditorApi.get().asc_getCellInfo(); const iscelllocked = cellinfo.asc_getLocked(); const seltype = cellinfo.asc_getSelectionType(); - return !(seltype === Asc.c_oAscSelectionType.RangeCells && !iscelllocked); + const isComments = cellinfo.asc_getComments().length > 0; + return (!(seltype === Asc.c_oAscSelectionType.RangeCells && !iscelllocked) || isComments); } render () { diff --git a/apps/spreadsheeteditor/mobile/src/page/app.jsx b/apps/spreadsheeteditor/mobile/src/page/app.jsx index 28fac09c7..b38f5c34a 100644 --- a/apps/spreadsheeteditor/mobile/src/page/app.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/app.jsx @@ -34,9 +34,8 @@ export default class extends React.Component { return ( {/* Your main view, should have "view-main" class */} - - - + + ) } diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index ef2c0d5f6..ae75b14d4 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -70,7 +70,7 @@ export default class MainPage extends Component { this.handleClickToOpenOptions('edit')}> this.handleClickToOpenOptions('add')}> { Device.phone ? null : } - this.handleClickToOpenOptions('coauth')}> + this.handleClickToOpenOptions('coauth')}> this.handleClickToOpenOptions('settings')}>