Sort comment on api event
This commit is contained in:
parent
32b1aa05c1
commit
b28c877fe2
|
@ -194,7 +194,6 @@ define([
|
|||
this.api.asc_registerCallback('asc_onUpdateCommentPosition', _.bind(this.onApiUpdateCommentPosition, this));
|
||||
this.api.asc_registerCallback('asc_onDocumentPlaceChanged', _.bind(this.onDocumentPlaceChanged, this));
|
||||
this.api.asc_registerCallback('asc_onDeleteComment', _.bind(this.onDeleteComment, this)); // only for PE, when del or ctrl+x pressed
|
||||
this.api.asc_registerCallback('asc_onChangePosition', _.bind(this.onApiChangePosition, this)); // change comment position in document
|
||||
this.api.asc_registerCallback('asc_onChangePositions', _.bind(this.onApiChangePositions, this)); // change comments position in document
|
||||
}
|
||||
},
|
||||
|
@ -733,7 +732,7 @@ define([
|
|||
} else
|
||||
this.collection.push(comment);
|
||||
|
||||
this.updateComments(true);
|
||||
this.updateComments(true, this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc'); // don't sort by position
|
||||
|
||||
if (this.showPopover) {
|
||||
if (null !== data.asc_getQuoteText()) {
|
||||
|
@ -753,7 +752,7 @@ define([
|
|||
comment.get('groupName') ? this.addCommentToGroupCollection(comment) : this.collection.push(comment);
|
||||
}
|
||||
|
||||
this.updateComments(true);
|
||||
this.updateComments(true, this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc');
|
||||
},
|
||||
onApiRemoveComment: function (id, silentUpdate) {
|
||||
for (var name in this.groupCollection) {
|
||||
|
@ -816,8 +815,7 @@ define([
|
|||
((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime())));
|
||||
|
||||
var user = this.userCollection.findOriginalUser(data.asc_getUserId());
|
||||
var needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username')) ||
|
||||
this.getComparator() == 'position-asc' || this.getComparator() == 'position-desc';
|
||||
var needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username'));
|
||||
comment.set('comment', data.asc_getText());
|
||||
comment.set('userid', data.asc_getUserId());
|
||||
comment.set('username', data.asc_getUserName());
|
||||
|
@ -826,7 +824,6 @@ define([
|
|||
comment.set('resolved', data.asc_getSolved());
|
||||
comment.set('quote', data.asc_getQuoteText());
|
||||
comment.set('userdata', data.asc_getUserData());
|
||||
comment.set('position', t.api.asc_GetCommentLogicPosition(id));
|
||||
comment.set('time', date.getTime());
|
||||
comment.set('date', t.dateToLocaleTimeString(date));
|
||||
comment.set('editable', (t.mode.canEditComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName()));
|
||||
|
@ -1110,25 +1107,13 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onApiChangePosition: function (id, data) {
|
||||
var comment = this.findComment(id) || this.findCommentInGroup(id);
|
||||
if (comment) {
|
||||
var needSort = (this.getComparator() == 'position-asc' || this.getComparator() == 'position-desc') && (data.asc_getPosition() !== comment.get('position'));
|
||||
comment.set('position', data.asc_getPosition());
|
||||
needSort && this.updateComments(true);
|
||||
onApiChangePositions: function (uids) {
|
||||
for (var i = 0; i < uids.length; ++i) {
|
||||
var id = uids[i],
|
||||
comment = this.findComment(id) || this.findCommentInGroup(id);
|
||||
comment && comment.set('position', this.api.asc_GetCommentLogicPosition(id));
|
||||
}
|
||||
},
|
||||
|
||||
onApiChangePositions: function (comments) {
|
||||
var needSort = false;
|
||||
for (var i = 0; i < comments.length; ++i) {
|
||||
var comment = this.findComment(comments[i].Id) || this.findCommentInGroup(comments[i].Id);
|
||||
if (comment) {
|
||||
needSort = needSort || (comments[i].Comment.asc_getPosition() !== comment.get('position'));
|
||||
comment.set('position', comments[i].Comment.asc_getPosition());
|
||||
}
|
||||
}
|
||||
needSort && (this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc') && this.updateComments(true);
|
||||
(this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc') && this.updateComments(true);
|
||||
},
|
||||
|
||||
// internal
|
||||
|
@ -1328,7 +1313,6 @@ define([
|
|||
resolved : data.asc_getSolved(),
|
||||
unattached : !_.isUndefined(data.asc_getDocumentFlag) ? data.asc_getDocumentFlag() : false,
|
||||
userdata : data.asc_getUserData(),
|
||||
position : this.api.asc_GetCommentLogicPosition(id),
|
||||
id : Common.UI.getId(),
|
||||
time : date.getTime(),
|
||||
showReply : false,
|
||||
|
|
|
@ -66,7 +66,7 @@ define([
|
|||
lockuserid : '',
|
||||
unattached : false,
|
||||
userdata : '',
|
||||
position : 0,
|
||||
position : -1,
|
||||
|
||||
id : Common.UI.getId(), // internal
|
||||
time : 0,
|
||||
|
|
Loading…
Reference in a new issue