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_onUpdateCommentPosition', _.bind(this.onApiUpdateCommentPosition, this));
|
||||||
this.api.asc_registerCallback('asc_onDocumentPlaceChanged', _.bind(this.onDocumentPlaceChanged, 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_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
|
this.api.asc_registerCallback('asc_onChangePositions', _.bind(this.onApiChangePositions, this)); // change comments position in document
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -733,7 +732,7 @@ define([
|
||||||
} else
|
} else
|
||||||
this.collection.push(comment);
|
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 (this.showPopover) {
|
||||||
if (null !== data.asc_getQuoteText()) {
|
if (null !== data.asc_getQuoteText()) {
|
||||||
|
@ -753,7 +752,7 @@ define([
|
||||||
comment.get('groupName') ? this.addCommentToGroupCollection(comment) : this.collection.push(comment);
|
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) {
|
onApiRemoveComment: function (id, silentUpdate) {
|
||||||
for (var name in this.groupCollection) {
|
for (var name in this.groupCollection) {
|
||||||
|
@ -816,8 +815,7 @@ define([
|
||||||
((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime())));
|
((data.asc_getTime() == '') ? new Date() : new Date(this.stringUtcToLocalDate(data.asc_getTime())));
|
||||||
|
|
||||||
var user = this.userCollection.findOriginalUser(data.asc_getUserId());
|
var user = this.userCollection.findOriginalUser(data.asc_getUserId());
|
||||||
var needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username')) ||
|
var needSort = (this.getComparator() == 'author-asc' || this.getComparator() == 'author-desc') && (data.asc_getUserName() !== comment.get('username'));
|
||||||
this.getComparator() == 'position-asc' || this.getComparator() == 'position-desc';
|
|
||||||
comment.set('comment', data.asc_getText());
|
comment.set('comment', data.asc_getText());
|
||||||
comment.set('userid', data.asc_getUserId());
|
comment.set('userid', data.asc_getUserId());
|
||||||
comment.set('username', data.asc_getUserName());
|
comment.set('username', data.asc_getUserName());
|
||||||
|
@ -826,7 +824,6 @@ define([
|
||||||
comment.set('resolved', data.asc_getSolved());
|
comment.set('resolved', data.asc_getSolved());
|
||||||
comment.set('quote', data.asc_getQuoteText());
|
comment.set('quote', data.asc_getQuoteText());
|
||||||
comment.set('userdata', data.asc_getUserData());
|
comment.set('userdata', data.asc_getUserData());
|
||||||
comment.set('position', t.api.asc_GetCommentLogicPosition(id));
|
|
||||||
comment.set('time', date.getTime());
|
comment.set('time', date.getTime());
|
||||||
comment.set('date', t.dateToLocaleTimeString(date));
|
comment.set('date', t.dateToLocaleTimeString(date));
|
||||||
comment.set('editable', (t.mode.canEditComments || (data.asc_getUserId() == t.currentUserId)) && AscCommon.UserInfoParser.canEditComment(data.asc_getUserName()));
|
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) {
|
onApiChangePositions: function (uids) {
|
||||||
var comment = this.findComment(id) || this.findCommentInGroup(id);
|
for (var i = 0; i < uids.length; ++i) {
|
||||||
if (comment) {
|
var id = uids[i],
|
||||||
var needSort = (this.getComparator() == 'position-asc' || this.getComparator() == 'position-desc') && (data.asc_getPosition() !== comment.get('position'));
|
comment = this.findComment(id) || this.findCommentInGroup(id);
|
||||||
comment.set('position', data.asc_getPosition());
|
comment && comment.set('position', this.api.asc_GetCommentLogicPosition(id));
|
||||||
needSort && this.updateComments(true);
|
|
||||||
}
|
}
|
||||||
},
|
(this.getComparator() === 'position-asc' || this.getComparator() === 'position-desc') && this.updateComments(true);
|
||||||
|
|
||||||
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);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// internal
|
// internal
|
||||||
|
@ -1328,7 +1313,6 @@ define([
|
||||||
resolved : data.asc_getSolved(),
|
resolved : data.asc_getSolved(),
|
||||||
unattached : !_.isUndefined(data.asc_getDocumentFlag) ? data.asc_getDocumentFlag() : false,
|
unattached : !_.isUndefined(data.asc_getDocumentFlag) ? data.asc_getDocumentFlag() : false,
|
||||||
userdata : data.asc_getUserData(),
|
userdata : data.asc_getUserData(),
|
||||||
position : this.api.asc_GetCommentLogicPosition(id),
|
|
||||||
id : Common.UI.getId(),
|
id : Common.UI.getId(),
|
||||||
time : date.getTime(),
|
time : date.getTime(),
|
||||||
showReply : false,
|
showReply : false,
|
||||||
|
|
|
@ -66,7 +66,7 @@ define([
|
||||||
lockuserid : '',
|
lockuserid : '',
|
||||||
unattached : false,
|
unattached : false,
|
||||||
userdata : '',
|
userdata : '',
|
||||||
position : 0,
|
position : -1,
|
||||||
|
|
||||||
id : Common.UI.getId(), // internal
|
id : Common.UI.getId(), // internal
|
||||||
time : 0,
|
time : 0,
|
||||||
|
|
Loading…
Reference in a new issue