Commit 01514822 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

Add asc_onChangeComments, asc_onRemoveComments events

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54485 954022d7-b5bf-4e40-9824-e11837661b57
parent f513ab50
...@@ -825,26 +825,35 @@ function asc_CCellCommentator(currentSheet) { ...@@ -825,26 +825,35 @@ function asc_CCellCommentator(currentSheet) {
_this.updateCommentsDependencies = function(bInsert, operType, updateRange) { _this.updateCommentsDependencies = function(bInsert, operType, updateRange) {
var bChange = true;
var UpdatePair = function(comment, bChange) { var UpdatePair = function(comment, bChange) {
this.comment = comment; this.comment = comment;
this.bChange = bChange; this.bChange = bChange;
} }
var aChangedComments = []; // Array of UpdatePair-objects var aChangedComments = []; // Array of UpdatePair
function updateCommentsList(aComments) { function updateCommentsList(aComments) {
if ( aComments.length ) { if ( aComments.length ) {
_this.bSaveHistory = false; _this.bSaveHistory = false;
var changeArray = [];
var removeArray = [];
for (var i = 0; i < aComments.length; i++) { for (var i = 0; i < aComments.length; i++) {
if ( aComments[i].bChange ) {
_this.asc_changeComment(aComments[i].comment.asc_getId(), aComments[i].comment, /*bChangeCoords*/true, /*bNoEvent*/true);
changeArray.push({"Id": aComments[i].comment.asc_getId(), "Comment": aComments[i].comment});
}
else {
_this.asc_removeComment(aComments[i].comment.asc_getId(), /*bNoEvent*/true);
removeArray.push(aComments[i].comment.asc_getId());
}
}
if ( aComments[i].bChange ) if ( changeArray.length )
_this.asc_changeComment(aComments[i].comment.asc_getId(), aComments[i].comment, true); _this.worksheet.model.workbook.handlers.trigger("asc_onChangeComments", changeArray);
if ( removeArray.length )
_this.worksheet.model.workbook.handlers.trigger("asc_onRemoveComments", removeArray);
// Delete
else
_this.asc_removeComment(aComments[i].comment.asc_getId());
}
_this.bSaveHistory = true; _this.bSaveHistory = true;
_this.drawCommentCells(); _this.drawCommentCells();
} }
...@@ -1472,7 +1481,7 @@ asc_CCellCommentator.prototype = { ...@@ -1472,7 +1481,7 @@ asc_CCellCommentator.prototype = {
_this.isLockedComment(oComment, true, callbackFunc); _this.isLockedComment(oComment, true, callbackFunc);
}, },
asc_changeComment: function(id, oComment, bChangeCoords) { asc_changeComment: function(id, oComment, bChangeCoords, bNoEvent) {
var _this = this; var _this = this;
var comment = _this.asc_findComment(id); var comment = _this.asc_findComment(id);
...@@ -1509,6 +1518,7 @@ asc_CCellCommentator.prototype = { ...@@ -1509,6 +1518,7 @@ asc_CCellCommentator.prototype = {
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
comment.asc_addReply(oComment.asc_getReply(i)); comment.asc_addReply(oComment.asc_getReply(i));
} }
if ( !bNoEvent )
_this.worksheet.model.workbook.handlers.trigger("asc_onChangeCommentData", comment.asc_getId(), comment); _this.worksheet.model.workbook.handlers.trigger("asc_onChangeCommentData", comment.asc_getId(), comment);
} }
...@@ -1530,7 +1540,7 @@ asc_CCellCommentator.prototype = { ...@@ -1530,7 +1540,7 @@ asc_CCellCommentator.prototype = {
_this.isLockedComment(comment, true, callbackFunc); _this.isLockedComment(comment, true, callbackFunc);
}, },
asc_removeComment: function(id) { asc_removeComment: function(id, bNoEvent) {
var _this = this; var _this = this;
var comment = _this.asc_findComment(id); var comment = _this.asc_findComment(id);
...@@ -1554,6 +1564,7 @@ asc_CCellCommentator.prototype = { ...@@ -1554,6 +1564,7 @@ asc_CCellCommentator.prototype = {
} }
comment.oParent.aReplies.splice(i, 1); comment.oParent.aReplies.splice(i, 1);
bResult = true;
break; break;
} }
} }
...@@ -1568,12 +1579,14 @@ asc_CCellCommentator.prototype = { ...@@ -1568,12 +1579,14 @@ asc_CCellCommentator.prototype = {
} }
_this.aComments.splice(i, 1); _this.aComments.splice(i, 1);
bResult = true;
break; break;
} }
} }
_this.worksheet.draw(); _this.worksheet.draw();
} }
_this.drawCommentCells(); _this.drawCommentCells();
if ( !bNoEvent )
_this.worksheet.model.workbook.handlers.trigger("asc_onRemoveComment", id); _this.worksheet.model.workbook.handlers.trigger("asc_onRemoveComment", id);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment