[Comments] Save text for new (not added) comment: clear text when esc, close or add button pressed
This commit is contained in:
parent
99f7070c7a
commit
6da9f77db0
|
@ -1299,8 +1299,8 @@ define([
|
|||
dialog.hide();
|
||||
}
|
||||
|
||||
dialog.handlerHide = (function () {
|
||||
me.clearDummyComment();
|
||||
dialog.handlerHide = (function (clear) {
|
||||
me.clearDummyComment(clear);
|
||||
});
|
||||
|
||||
anchor = this.api.asc_getAnchorPosition();
|
||||
|
@ -1309,7 +1309,7 @@ define([
|
|||
anchor.asc_getY(),
|
||||
this.hintmode ? anchor.asc_getX() : undefined);
|
||||
|
||||
dialog.showComments(true, false, true);
|
||||
dialog.showComments(true, false, true, dialog.getDummyText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1323,12 +1323,14 @@ define([
|
|||
this.hidereply = false;
|
||||
this.isSelectedComment = false;
|
||||
this.uids = [];
|
||||
this.isDummyComment = false;
|
||||
|
||||
this.popoverComments.reset();
|
||||
if (this.getPopover().isVisible()) {
|
||||
this.getPopover().hideComments();
|
||||
}
|
||||
|
||||
this.isDummyComment = false;
|
||||
|
||||
comment.asc_putText(commentVal);
|
||||
comment.asc_putTime(this.utcDateToString(new Date()));
|
||||
comment.asc_putOnlyOfficeTime(this.ooDateToString(new Date()));
|
||||
|
@ -1348,7 +1350,7 @@ define([
|
|||
}
|
||||
}
|
||||
},
|
||||
clearDummyComment: function () {
|
||||
clearDummyComment: function (clear) {
|
||||
if (this.isDummyComment) {
|
||||
this.isDummyComment = false;
|
||||
|
||||
|
@ -1360,6 +1362,9 @@ define([
|
|||
|
||||
var dialog = this.getPopover();
|
||||
if (dialog) {
|
||||
clear && dialog.clearDummyText();
|
||||
dialog.saveDummyText();
|
||||
|
||||
dialog.handlerHide = (function () {
|
||||
});
|
||||
|
||||
|
|
|
@ -386,6 +386,7 @@ define([
|
|||
|
||||
if (record.get('dummy')) {
|
||||
var commentVal = this.getActiveTextBoxVal();
|
||||
me.clearDummyText();
|
||||
if (commentVal.length > 0)
|
||||
me.fireEvent('comment:addDummyComment', [commentVal]);
|
||||
else {
|
||||
|
@ -414,6 +415,7 @@ define([
|
|||
|
||||
} else if (btn.hasClass('btn-inner-close', false)) {
|
||||
if (record.get('dummy')) {
|
||||
me.clearDummyText();
|
||||
me.hide();
|
||||
return;
|
||||
}
|
||||
|
@ -460,7 +462,7 @@ define([
|
|||
me.commentsView.autoHeightTextBox();
|
||||
me.$window.find('textarea').keydown(function (event) {
|
||||
if (event.keyCode == Common.UI.Keys.ESC) {
|
||||
me.hide();
|
||||
me.hide(true); // clear text in dummy comment
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -583,7 +585,7 @@ define([
|
|||
|
||||
hide: function () {
|
||||
if (this.handlerHide) {
|
||||
this.handlerHide();
|
||||
this.handlerHide.apply(this, arguments);
|
||||
}
|
||||
|
||||
this.hideTips();
|
||||
|
@ -846,6 +848,22 @@ define([
|
|||
|
||||
return undefined;
|
||||
},
|
||||
saveDummyText: function () {
|
||||
if (this.commentsView && this.commentsView.cmpEl.find('.lock-area').length < 1) {
|
||||
this.textDummyVal = this.commentsView.getActiveTextBoxVal();
|
||||
}
|
||||
},
|
||||
clearDummyText: function () {
|
||||
if (this.commentsView && this.commentsView.cmpEl.find('.lock-area').length < 1) {
|
||||
this.textDummyVal = undefined;
|
||||
var textBox = this.commentsView.getTextBox();
|
||||
textBox && textBox.val('');
|
||||
this.commentsView.clearTextBoxBind();
|
||||
}
|
||||
},
|
||||
getDummyText: function() {
|
||||
return this.textDummyVal || '';
|
||||
},
|
||||
|
||||
hookTextBox: function () {
|
||||
var me = this, textBox = this.commentsView.getTextBox();
|
||||
|
|
Loading…
Reference in a new issue