Fix Bug 37570

This commit is contained in:
Julia Radzhabova 2018-05-17 17:34:04 +03:00
parent 2e15b1dbc1
commit 0523524829
2 changed files with 63 additions and 43 deletions

View file

@ -760,6 +760,7 @@ define([
user = usersStore.findWhere({id: userId}); user = usersStore.findWhere({id: userId});
if (user) { if (user) {
this.getPopover() && this.getPopover().saveText(); this.getPopover() && this.getPopover().saveText();
this.view.saveText();
cur.set('lock', true); cur.set('lock', true);
cur.set('lockuserid', this.view.getUserName(user.get('username'))); cur.set('lockuserid', this.view.getUserName(user.get('username')));
} }
@ -771,6 +772,7 @@ define([
if (cur) { if (cur) {
cur.set('lock', false); cur.set('lock', false);
this.getPopover() && this.getPopover().loadText(); this.getPopover() && this.getPopover().loadText();
this.view.loadText();
} }
}, },
onApiShowComment: function (uids, posX, posY, leftX, opts, hint) { onApiShowComment: function (uids, posX, posY, leftX, opts, hint) {

View file

@ -183,7 +183,7 @@ define([
newHeight = 0; newHeight = 0;
function updateTextBoxHeight() { function updateTextBoxHeight() {
scrollPos = $(view.scroller.el).scrollTop(); scrollPos = view.scroller.getScrollTop();
if (domTextBox.scrollHeight > domTextBox.clientHeight) { if (domTextBox.scrollHeight > domTextBox.clientHeight) {
textBox.css({height: (domTextBox.scrollHeight + lineHeight) + 'px'}); textBox.css({height: (domTextBox.scrollHeight + lineHeight) + 'px'});
@ -841,50 +841,51 @@ define([
render: function () { render: function () {
var me = this; var me = this;
this.$el.html(this.template({ if (!this.rendered) {
textAddCommentToDoc: me.textAddCommentToDoc, this.$el.html(this.template({
textAddComment: me.textAddComment, textAddCommentToDoc: me.textAddCommentToDoc,
textCancel: me.textCancel, textAddComment: me.textAddComment,
textEnterCommentHint: me.textEnterCommentHint, textCancel: me.textCancel,
maxCommLength: Asc.c_oAscMaxCellOrCommentLength textEnterCommentHint: me.textEnterCommentHint,
})); maxCommLength: Asc.c_oAscMaxCellOrCommentLength
}));
this.buttonAddCommentToDoc = new Common.UI.Button({ this.buttonAddCommentToDoc = new Common.UI.Button({
el: $('.btn.new',this.$el), el: $('.btn.new', this.$el),
enableToggle: false enableToggle: false
}); });
this.buttonAdd = new Common.UI.Button({ this.buttonAdd = new Common.UI.Button({
action: 'add', action: 'add',
el: $('.btn.add', this.$el), el: $('.btn.add', this.$el),
enableToggle: false enableToggle: false
}); });
this.buttonCancel = new Common.UI.Button({ this.buttonCancel = new Common.UI.Button({
el: $('.btn.cancel', this.$el), el: $('.btn.cancel', this.$el),
enableToggle: false enableToggle: false
}); });
this.buttonAddCommentToDoc.on('click', _.bind(this.onClickShowBoxDocumentComment, this)); this.buttonAddCommentToDoc.on('click', _.bind(this.onClickShowBoxDocumentComment, this));
this.buttonAdd.on('click', _.bind(this.onClickAddDocumentComment, this)); this.buttonAdd.on('click', _.bind(this.onClickAddDocumentComment, this));
this.buttonCancel.on('click', _.bind(this.onClickCancelDocumentComment, this)); this.buttonCancel.on('click', _.bind(this.onClickCancelDocumentComment, this));
this.txtComment = $('#comment-msg-new', this.el); this.txtComment = $('#comment-msg-new', this.el);
this.txtComment.keydown(function (event) { this.txtComment.keydown(function (event) {
if ((event.ctrlKey || event.metaKey) && !event.altKey && event.keyCode == Common.UI.Keys.RETURN) { if ((event.ctrlKey || event.metaKey) && !event.altKey && event.keyCode == Common.UI.Keys.RETURN) {
me.onClickAddDocumentComment(); me.onClickAddDocumentComment();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
} else if (event.keyCode === Common.UI.Keys.TAB) { } else if (event.keyCode === Common.UI.Keys.TAB) {
var $this, end, start; var $this, end, start;
start = this.selectionStart; start = this.selectionStart;
end = this.selectionEnd; end = this.selectionEnd;
$this = $(this); $this = $(this);
$this.val($this.val().substring(0, start) + '\t' + $this.val().substring(end)); $this.val($this.val().substring(0, start) + '\t' + $this.val().substring(end));
this.selectionStart = this.selectionEnd = start + 1; this.selectionStart = this.selectionEnd = start + 1;
event.stopImmediatePropagation();
event.preventDefault();
}
});
event.stopImmediatePropagation();
event.preventDefault();
}
});
}
var CommentsPanelDataView = Common.UI.DataView.extend((function() { var CommentsPanelDataView = Common.UI.DataView.extend((function() {
var parentView = me; var parentView = me;
@ -983,7 +984,6 @@ define([
})()); })());
if (CommentsPanelDataView) { if (CommentsPanelDataView) {
if (this.commentsView) { if (this.commentsView) {
this.commentsView.render($('.messages-ct',me.el));
this.commentsView.onResetItems(); this.commentsView.onResetItems();
} else { } else {
this.commentsView = new CommentsPanelDataView({ this.commentsView = new CommentsPanelDataView({
@ -1139,8 +1139,9 @@ define([
} }
} }
this.setupLayout(); if (!this.rendered) this.setupLayout();
this.update(); this.update();
this.rendered = true;
return this; return this;
}, },
@ -1204,6 +1205,23 @@ define([
this.showEditContainer(false); this.showEditContainer(false);
}, },
saveText: function (clear) {
if (this.commentsView && this.commentsView.cmpEl.find('.lock-area').length<1) {
this.textVal = undefined;
if (!clear) {
this.textVal = this.commentsView.getActiveTextBoxVal();
} else {
this.commentsView.clearTextBoxBind();
}
}
},
loadText: function () {
if (this.textVal && this.commentsView) {
var textBox = this.commentsView.getTextBox();
textBox && textBox.val(this.textVal);
}
},
hookTextBox: function () { hookTextBox: function () {
var me = this, var me = this,
textBox = this.commentsView.getTextBox(); textBox = this.commentsView.getTextBox();