View comments in final/original display mode (don't disable left comments panel)

This commit is contained in:
Julia Radzhabova 2019-01-14 16:51:23 +03:00
parent 34453c96c6
commit 61ce51f6a1
7 changed files with 58 additions and 34 deletions

View file

@ -74,7 +74,7 @@ define([
subEditStrings : {}, subEditStrings : {},
filter : undefined, filter : undefined,
hintmode : false, hintmode : false,
previewmode: false, viewmode: false,
isSelectedComment : false, isSelectedComment : false,
uids : [], uids : [],
oldUids : [], oldUids : [],
@ -169,7 +169,7 @@ define([
this.currentUserName = data.config.user.fullname; this.currentUserName = data.config.user.fullname;
this.sdkViewName = data['sdkviewname'] || this.sdkViewName; this.sdkViewName = data['sdkviewname'] || this.sdkViewName;
this.hintmode = data['hintmode'] || false; this.hintmode = data['hintmode'] || false;
this.previewmode = data['previewmode'] || false; this.viewmode = data['viewmode'] || false;
} }
}, },
setApi: function (api) { setApi: function (api) {
@ -194,10 +194,8 @@ define([
setMode: function(mode) { setMode: function(mode) {
this.mode = mode; this.mode = mode;
this.isModeChanged = true; // change show-comment mode from/to hint mode using canComments flag this.isModeChanged = true; // change show-comment mode from/to hint mode using canComments flag
if (!this.mode.canComments) { this.view.viewmode = !this.mode.canComments;
this.view.changeLayout(mode); this.view.changeLayout(mode);
}
return this; return this;
}, },
// //
@ -283,8 +281,6 @@ define([
return false; return false;
}, },
onShowComment: function (id, selected) { onShowComment: function (id, selected) {
if (this.previewmode) return;
var comment = this.findComment(id); var comment = this.findComment(id);
if (comment) { if (comment) {
if (null !== comment.get('quote')) { if (null !== comment.get('quote')) {
@ -818,11 +814,9 @@ define([
} }
}, },
onApiShowComment: function (uids, posX, posY, leftX, opts, hint) { onApiShowComment: function (uids, posX, posY, leftX, opts, hint) {
if (this.previewmode) return;
this.isModeChanged = false;
var same_uids = (0 === _.difference(this.uids, uids).length) && (0 === _.difference(uids, this.uids).length); var same_uids = (0 === _.difference(this.uids, uids).length) && (0 === _.difference(uids, this.uids).length);
if (hint && this.isSelectedComment && same_uids) { if (hint && this.isSelectedComment && same_uids && !this.isModeChanged) {
// хотим показать тот же коментарий что был и выбран // хотим показать тот же коментарий что был и выбран
return; return;
} }
@ -833,7 +827,7 @@ define([
if (popover) { if (popover) {
this.clearDummyComment(); this.clearDummyComment();
if (this.isSelectedComment && same_uids) { if (this.isSelectedComment && same_uids && !this.isModeChanged) {
//NOTE: click to sdk view ? //NOTE: click to sdk view ?
if (this.api) { if (this.api) {
//this.view.txtComment.blur(); //this.view.txtComment.blur();
@ -905,6 +899,7 @@ define([
popover.setLeftTop(posX, posY, leftX); popover.setLeftTop(posX, posY, leftX);
popover.showComments(animate, false, true, text); popover.showComments(animate, false, true, text);
} }
this.isModeChanged = false;
}, },
onApiHideComment: function (hint) { onApiHideComment: function (hint) {
var t = this; var t = this;
@ -940,8 +935,6 @@ define([
} }
}, },
onApiUpdateCommentPosition: function (uids, posX, posY, leftX) { onApiUpdateCommentPosition: function (uids, posX, posY, leftX) {
if (this.previewmode) return;
var i, useAnimation = false, var i, useAnimation = false,
comment = null, comment = null,
text = undefined, text = undefined,
@ -1480,9 +1473,16 @@ define([
}, },
setPreviewMode: function(mode) { setPreviewMode: function(mode) {
this.previewmode = mode; if (this.viewmode === mode) return;
this.viewmode = mode;
if (mode)
this.prevcanComments = this.mode.canComments;
this.mode.canComments = (mode) ? false : this.prevcanComments;
this.closeEditing();
this.setMode(this.mode);
this.updateComments(true);
if (this.getPopover()) if (this.getPopover())
this.getPopover().hide(); this.getPopover().update(true);
} }
}, Common.Controllers.Comments || {})); }, Common.Controllers.Comments || {}));

View file

@ -573,13 +573,11 @@ define([
app.getController('Common.Controllers.Plugins').getView('Common.Views.Plugins').disableControls(disable); app.getController('Common.Controllers.Plugins').getView('Common.Views.Plugins').disableControls(disable);
} }
var leftMenu = app.getController('LeftMenu').leftMenu;
leftMenu.btnComments.setDisabled(disable);
if (disable) leftMenu.close();
var comments = app.getController('Common.Controllers.Comments'); var comments = app.getController('Common.Controllers.Comments');
if (comments) if (comments)
comments.setPreviewMode(disable); comments.setPreviewMode(disable);
var leftMenu = app.getController('LeftMenu').leftMenu;
leftMenu.getMenu('file').miProtect.setDisabled(disable); leftMenu.getMenu('file').miProtect.setDisabled(disable);
if (this.view) { if (this.view) {

View file

@ -10,7 +10,7 @@
<% if (quote!==null && quote!=='') { %> <% if (quote!==null && quote!=='') { %>
<div class="user-quote"><%=scope.getFixedQuote(quote)%></div> <div class="user-quote"><%=scope.getFixedQuote(quote)%></div>
<% } %> <% } %>
<% if (!editText || hint) { %> <% if (!editText || scope.viewmode) { %>
<div class="user-message" data-can-copy="true"><%=scope.pickLink(comment)%></div> <div class="user-message" data-can-copy="true"><%=scope.pickLink(comment)%></div>
<% } else { %> <% } else { %>
<div class="inner-edit-ct"> <div class="inner-edit-ct">
@ -25,14 +25,14 @@
<% if (replys.length) { %> <% if (replys.length) { %>
<div class="reply-arrow img-commonctrl"></div> <div class="reply-arrow img-commonctrl"></div>
<% _.each(replys, function (item, index) { %> <% _.each(replys, function (item, index) { %>
<div class="reply-item-ct" <% if (hint && index==replys.length-1) { %>style="padding-bottom: 0;" <% } %>;> <div class="reply-item-ct" <% if (scope.viewmode && index==replys.length-1) { %>style="padding-bottom: 0;" <% } %>;>
<div class="user-name"> <div class="user-name">
<div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %> <div class="color" style="display: inline-block; background-color: <% if (item.get("usercolor")!==null) { %><%=item.get("usercolor")%><% } else { %> #cfcfcf <% } %>; " ></div><%= scope.getUserName(item.get("username")) %>
</div> </div>
<div class="user-date"><%=item.get("date")%></div> <div class="user-date"><%=item.get("date")%></div>
<% if (!item.get("editText")) { %> <% if (!item.get("editText")) { %>
<div class="user-message" data-can-copy="true"><%=scope.pickLink(item.get("reply"))%></div> <div class="user-message" data-can-copy="true"><%=scope.pickLink(item.get("reply"))%></div>
<% if (!hint) { %> <% if (!scope.viewmode) { %>
<div class="btns-reply-ct"> <div class="btns-reply-ct">
<% if (item.get("editable")) { %> <% if (item.get("editable")) { %>
<div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div> <div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div>
@ -53,7 +53,7 @@
<!-- add reply button --> <!-- add reply button -->
<% if (!showReply && !hint) { %> <% if (!showReply && !scope.viewmode) { %>
<% if (replys.length) { %> <% if (replys.length) { %>
<label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label> <label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>
<% } else { %> <% } else { %>
@ -63,7 +63,7 @@
<!-- edit buttons --> <!-- edit buttons -->
<% if (!editText && !lock && !hint) { %> <% if (!editText && !lock && !scope.viewmode) { %>
<div class="edit-ct"> <div class="edit-ct">
<% if (editable) { %> <% if (editable) { %>
<div class="btn-edit img-commonctrl"></div> <div class="btn-edit img-commonctrl"></div>

View file

@ -79,6 +79,7 @@ define([
addCommentHeight: 45, addCommentHeight: 45,
newCommentHeight: 110, newCommentHeight: 110,
textBoxAutoSizeLocked: undefined, // disable autosize textbox textBoxAutoSizeLocked: undefined, // disable autosize textbox
viewmode: false,
initialize: function (options) { initialize: function (options) {
Common.UI.BaseView.prototype.initialize.call(this, options); Common.UI.BaseView.prototype.initialize.call(this, options);
@ -550,13 +551,38 @@ define([
}, },
changeLayout: function(mode) { changeLayout: function(mode) {
var me = this,
add = $('.new-comment-ct', this.el),
to = $('.add-link-ct', this.el),
msgs = $('.messages-ct', this.el);
msgs.toggleClass('stretch', !mode.canComments);
if (!mode.canComments) { if (!mode.canComments) {
var add = $('.new-comment-ct', this.el),
to = $('.add-link-ct', this.el),
msgs = $('.messages-ct', this.el);
add.hide(); to.hide(); add.hide(); to.hide();
msgs.addClass('stretch');
this.layout.changeLayout([{el: msgs[0], rely: false, stretch: true}]); this.layout.changeLayout([{el: msgs[0], rely: false, stretch: true}]);
} else {
var container = $('#comments-box', this.el),
items = container.find(' > .layout-item');
to.show();
this.layout.changeLayout([{el: items[0], rely: true,
resize: {
hidden: false,
autohide: false,
fmin: (function () {
var height = container.height();
if (add.css('display') !== 'none') {
if (height * 0.5 < me.newCommentHeight)
return height - me.newCommentHeight;
}
return height * 0.5;
}),
fmax: (function () {
if (add.css('display') !== 'none')
return container.height() - me.newCommentHeight;
return container.height() - me.addCommentHeight;
})
}},
{el: items[1], stretch: true},
{el: items[2], stretch: true}]);
} }
}, },

View file

@ -390,8 +390,8 @@ define([
DE.getController('DocumentHolder').getView().SetDisabled(disable, true); DE.getController('DocumentHolder').getView().SetDisabled(disable, true);
DE.getController('Navigation') && DE.getController('Navigation').SetDisabled(disable); DE.getController('Navigation') && DE.getController('Navigation').SetDisabled(disable);
var leftMenu = DE.getController('LeftMenu').leftMenu; // var leftMenu = DE.getController('LeftMenu').leftMenu;
leftMenu.btnComments.setDisabled(disable); // leftMenu.btnComments.setDisabled(disable);
var comments = DE.getController('Common.Controllers.Comments'); var comments = DE.getController('Common.Controllers.Comments');
if (comments) if (comments)
comments.setPreviewMode(disable); comments.setPreviewMode(disable);

View file

@ -343,8 +343,8 @@ define([
PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable); PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable);
var leftMenu = PE.getController('LeftMenu').leftMenu; // var leftMenu = PE.getController('LeftMenu').leftMenu;
leftMenu.btnComments.setDisabled(disable); // leftMenu.btnComments.setDisabled(disable);
var comments = PE.getController('Common.Controllers.Comments'); var comments = PE.getController('Common.Controllers.Comments');
if (comments) if (comments)
comments.setPreviewMode(disable); comments.setPreviewMode(disable);

View file

@ -389,8 +389,8 @@ define([
SSE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable); SSE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
SSE.getController('DocumentHolder').SetDisabled(disable, true); SSE.getController('DocumentHolder').SetDisabled(disable, true);
var leftMenu = SSE.getController('LeftMenu').leftMenu; // var leftMenu = SSE.getController('LeftMenu').leftMenu;
leftMenu.btnComments.setDisabled(disable); // leftMenu.btnComments.setDisabled(disable);
var comments = SSE.getController('Common.Controllers.Comments'); var comments = SSE.getController('Common.Controllers.Comments');
if (comments) if (comments)
comments.setPreviewMode(disable); comments.setPreviewMode(disable);