Skip to content

Commit

Permalink
Show comments in view mode (hints, left panel, advanced settings in t…
Browse files Browse the repository at this point in the history
…he File menu)
  • Loading branch information
JuliaRadzhabova committed Dec 17, 2018
1 parent 1153d9a commit f621e67
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 66 deletions.
44 changes: 44 additions & 0 deletions apps/common/main/lib/component/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,50 @@ define([
doLayout: function() {
},

changeLayout: function(items) {
var panel, resizer, stretch = false;
this.panels = [];
items.forEach(function(item) {
item.el instanceof HTMLElement && (item.el = $(item.el));
panel = _.extend(new LayoutPanel(), item);
if ( panel.stretch ) {
stretch = true;
panel.rely = false;
panel.resize = false;
}

this.panels.push(panel);

if (panel.resize) {
resizer = {
isresizer : true,
minpos : panel.resize.min||0,
maxpos : panel.resize.max||0,
fmin : panel.resize.fmin,
fmax : panel.resize.fmax,
behaviour : panel.behaviour,
index : this.splitters.length,
offset : panel.resize.offset || 0
};

if (!stretch) {
panel.resize.el =
resizer.el = panel.el.after('<div class="layout-resizer after"></div>').next();
this.panels.push(resizer);
} else {
panel.resize.el =
resizer.el = panel.el.before('<div class="layout-resizer before"></div>').prev();
this.panels.splice(this.panels.length - 1, 0, resizer);
}

this.splitters.push({resizer:resizer});

panel.resize.hidden && resizer.el.hide();
Common.Gateway.on('processmouse', this.resize.eventStop);
}
}, this);
},

getElementHeight: function(el) {
return parseInt(el.css('height'));
},
Expand Down
15 changes: 10 additions & 5 deletions apps/common/main/lib/controller/Comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ define([
setMode: function(mode) {
this.mode = mode;
this.isModeChanged = true; // change show-comment mode from/to hint mode using canComments flag
if (!this.mode.canComments) {
this.view.changeLayout(mode);
}

return this;
},
//
Expand Down Expand Up @@ -1188,6 +1192,7 @@ define([
hideAddReply : !_.isUndefined(this.hidereply) ? this.hidereply : (this.showPopover ? true : false),
scope : this.view,
editable : this.mode.canEditComments || (data.asc_getUserId() == this.currentUserId),
hint : !this.mode.canComments,
groupName : (groupname && groupname.length>1) ? groupname[1] : null
});
if (comment) {
Expand Down Expand Up @@ -1403,12 +1408,12 @@ define([
if ('none' !== panel.css('display')) {
this.view.txtComment.focus();
}
if (this.view.needRender)
this.updateComments(true);
else if (this.view.needUpdateFilter)
this.onUpdateFilter(this.view.needUpdateFilter);
this.view.update();
}
if (this.view.needRender)
this.updateComments(true);
else if (this.view.needUpdateFilter)
this.onUpdateFilter(this.view.needUpdateFilter);
this.view.update();
}
},

Expand Down
14 changes: 8 additions & 6 deletions apps/common/main/lib/template/Comments.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<% if (quote!==null && quote!=='') { %>
<div class="user-quote"><%=scope.getFixedQuote(quote)%></div>
<% } %>
<% if (!editText) { %>
<% if (!editText || hint) { %>
<div class="user-message" data-can-copy="true"><%=scope.pickLink(comment)%></div>
<% } else { %>
<div class="inner-edit-ct">
Expand All @@ -24,20 +24,22 @@

<% if (replys.length) { %>
<div class="reply-arrow img-commonctrl"></div>
<% _.each(replys, function (item) { %>
<div class="reply-item-ct">
<% _.each(replys, function (item, index) { %>
<div class="reply-item-ct" <% if (hint && index==replys.length-1) { %>style="padding-bottom: 0;" <% } %>;>
<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>
<div class="user-date"><%=item.get("date")%></div>
<% if (!item.get("editText")) { %>
<div class="user-message" data-can-copy="true"><%=scope.pickLink(item.get("reply"))%></div>
<% if (!hint) { %>
<div class="btns-reply-ct">
<% if (item.get("editable")) { %>
<div class="btn-edit img-commonctrl" data-value="<%=item.get("id")%>"></div>
<% } %>
<div class="btn-delete img-commonctrl" data-value="<%=item.get("id")%>"></div>
</div>
</div>
<%}%>
<% } else { %>
<div class="inner-edit-ct">
<textarea class="msg-reply textarea-fix user-select" maxlength="maxCommLength"><%=item.get("reply")%></textarea>
Expand All @@ -51,7 +53,7 @@

<!-- add reply button -->

<% if (!showReply) { %>
<% if (!showReply && !hint) { %>
<% if (replys.length) { %>
<label class="user-reply" style="margin-left: 20px; margin-top: 5px;" role="presentation" tabindex="-1">textAddReply</label>
<% } else { %>
Expand All @@ -61,7 +63,7 @@

<!-- edit buttons -->

<% if (!editText && !lock) { %>
<% if (!editText && !lock && !hint) { %>
<div class="edit-ct">
<% if (editable) { %>
<div class="btn-edit img-commonctrl"></div>
Expand Down
12 changes: 12 additions & 0 deletions apps/common/main/lib/view/Comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,17 @@ define([
this.autoHeightTextBox();
},

changeLayout: function(mode) {
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();
msgs.addClass('stretch');
this.layout.changeLayout([{el: msgs[0], rely: false, stretch: true}]);
}
},

updateLayout: function () {
var container = $('#comments-box', this.el), add = $('.new-comment-ct', this.el);
if (add.css('display') !== 'none') {
Expand All @@ -561,6 +572,7 @@ define([
autoHeightTextBox: function () {
var me = this, domTextBox = null, lineHeight = 0, minHeight = 44;
var textBox = $('#comment-msg-new', this.el);
if (textBox.length<1) return;

function updateTextBoxHeight() {

Expand Down
4 changes: 4 additions & 0 deletions apps/common/main/resources/less/comments.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
height: 300px;
border-bottom: 1px solid @gray-dark;

&.stretch {
border-bottom: none;
}

.ps-scrollbar-y-rail {
margin-top: 5px;
margin-bottom: 5px;
Expand Down
10 changes: 5 additions & 5 deletions apps/documenteditor/main/app/controller/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ define([
createDelayedElements: function() {
/** coauthoring begin **/
if ( this.mode.canCoAuthoring ) {
this.leftMenu.btnComments[(this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide']();
if (this.mode.canComments)
this.leftMenu.btnComments[(this.mode.canViewComments && !this.mode.isLightVersion) ? 'show' : 'hide']();
if (this.mode.canViewComments)
this.leftMenu.setOptionsPanel('comment', this.getApplication().getController('Common.Controllers.Comments').getView());

this.leftMenu.btnChat[(this.mode.canChat && !this.mode.isLightVersion) ? 'show' : 'hide']();
Expand Down Expand Up @@ -406,7 +406,7 @@ define([
Common.Utils.InternalSettings.set("de-settings-livecomment", value);
var resolved = Common.localStorage.getBool("de-settings-resolvedcomment");
Common.Utils.InternalSettings.set("de-settings-resolvedcomment", resolved);
if (this.mode.canComments && this.leftMenu.panelComments.isVisible())
if (this.mode.canViewComments && this.leftMenu.panelComments.isVisible())
value = resolved = true;
(value) ? this.api.asc_showComments(resolved) : this.api.asc_hideComments();
/** coauthoring end **/
Expand Down Expand Up @@ -653,7 +653,7 @@ define([
if (value && this.leftMenu._state.pluginIsRunning) {
this.leftMenu.panelPlugins.show();
if (this.mode.canCoAuthoring) {
this.mode.canComments && this.leftMenu.panelComments['hide']();
this.mode.canViewComments && this.leftMenu.panelComments['hide']();
this.mode.canChat && this.leftMenu.panelChat['hide']();
}
}
Expand Down Expand Up @@ -751,7 +751,7 @@ define([
}
return false;
case 'comments':
if (this.mode.canCoAuthoring && this.mode.canComments && !this.mode.isLightVersion) {
if (this.mode.canCoAuthoring && this.mode.canViewComments && !this.mode.isLightVersion) {
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu('comments');
this.getApplication().getController('Common.Controllers.Comments').onAfterShow();
Expand Down
12 changes: 6 additions & 6 deletions apps/documenteditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ define([
this.appOptions.canSendEmailAddresses = this.appOptions.canLicense && this.editorConfig.canSendEmailAddresses && this.appOptions.canEdit && this.appOptions.canCoAuthoring;
this.appOptions.canComments = this.appOptions.canLicense && (this.permissions.comment===undefined ? this.appOptions.isEdit : this.permissions.comment) && (this.editorConfig.mode !== 'view');
this.appOptions.canComments = this.appOptions.canComments && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);
this.appOptions.canViewComments = this.appOptions.canComments || !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);
this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false);
this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit;
this.appOptions.canPrint = (this.permissions.print !== false);
Expand Down Expand Up @@ -1204,12 +1205,11 @@ define([
},

applyModeEditorElements: function() {
if (this.appOptions.canComments || this.appOptions.isEdit) {
/** coauthoring begin **/
this.contComments.setMode(this.appOptions);
this.contComments.setConfig({config: this.editorConfig}, this.api);
/** coauthoring end **/
}
/** coauthoring begin **/
this.contComments.setMode(this.appOptions);
this.contComments.setConfig({config: this.editorConfig}, this.api);
/** coauthoring end **/

if (this.appOptions.isEdit) {
var me = this,
application = this.getApplication(),
Expand Down
2 changes: 1 addition & 1 deletion apps/documenteditor/main/app/view/FileMenuPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ define([
/** coauthoring begin **/
$('tr.coauth', this.el)[mode.isEdit && mode.canCoAuthoring ? 'show' : 'hide']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring && (mode.isEdit || mode.canComments) ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
/** coauthoring end **/
},

Expand Down
4 changes: 2 additions & 2 deletions apps/documenteditor/main/app/view/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ define([
onCoauthOptions: function(e) {
/** coauthoring begin **/
if (this.mode.canCoAuthoring) {
if (this.mode.canComments) {
if (this.mode.canViewComments) {
if (this.btnComments.pressed && this.btnComments.$el.hasClass('notify'))
this.btnComments.$el.removeClass('notify');
this.panelComments[this.btnComments.pressed?'show':'hide']();
Expand Down Expand Up @@ -288,7 +288,7 @@ define([
this.$el.width(SCALE_MIN);
/** coauthoring begin **/
if (this.mode.canCoAuthoring) {
if (this.mode.canComments) {
if (this.mode.canViewComments) {
this.panelComments['hide']();
if (this.btnComments.pressed)
this.fireEvent('comments:hide', this);
Expand Down
6 changes: 3 additions & 3 deletions apps/presentationeditor/main/app/controller/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ define([
createDelayedElements: function() {
/** coauthoring begin **/
if ( this.mode.canCoAuthoring ) {
this.leftMenu.btnComments[(this.mode.canComments && !this.mode.isLightVersion) ? 'show' : 'hide']();
if (this.mode.canComments)
this.leftMenu.btnComments[(this.mode.canViewComments && !this.mode.isLightVersion) ? 'show' : 'hide']();
if (this.mode.canViewComments)
this.leftMenu.setOptionsPanel('comment', this.getApplication().getController('Common.Controllers.Comments').getView('Common.Views.Comments'));

this.leftMenu.btnChat[(this.mode.canChat && !this.mode.isLightVersion) ? 'show' : 'hide']();
Expand Down Expand Up @@ -631,7 +631,7 @@ define([
}
return false;
case 'comments':
if (this.mode.canCoAuthoring && this.mode.canComments && !this.mode.isLightVersion && (!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) {
if (this.mode.canCoAuthoring && this.mode.canViewComments && !this.mode.isLightVersion && (!previewPanel || !previewPanel.isVisible()) && !this._state.no_slides) {
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu('comments');
this.getApplication().getController('Common.Controllers.Comments').onAfterShow();
Expand Down
15 changes: 7 additions & 8 deletions apps/presentationeditor/main/app/controller/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ define([
this.appOptions.canAnalytics = params.asc_getIsAnalyticsEnable();
this.appOptions.canComments = this.appOptions.canLicense && (this.permissions.comment===undefined ? this.appOptions.isEdit : this.permissions.comment) && (this.editorConfig.mode !== 'view');
this.appOptions.canComments = this.appOptions.canComments && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);
this.appOptions.canViewComments = this.appOptions.canComments || !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.comments===false);
this.appOptions.canChat = this.appOptions.canLicense && !this.appOptions.isOffline && !((typeof (this.editorConfig.customization) == 'object') && this.editorConfig.customization.chat===false);
this.appOptions.canPrint = (this.permissions.print !== false);
this.appOptions.canRename = this.editorConfig.canRename && !!this.permissions.rename;
Expand Down Expand Up @@ -940,15 +941,13 @@ define([
},

applyModeEditorElements: function(prevmode) {
if (this.appOptions.canComments || this.appOptions.isEdit) {
/** coauthoring begin **/
var commentsController = this.getApplication().getController('Common.Controllers.Comments');
if (commentsController) {
commentsController.setMode(this.appOptions);
commentsController.setConfig({config: this.editorConfig, sdkviewname: '#id_main_parent'}, this.api);
}
/** coauthoring end **/
/** coauthoring begin **/
var commentsController = this.getApplication().getController('Common.Controllers.Comments');
if (commentsController) {
commentsController.setMode(this.appOptions);
commentsController.setConfig({config: this.editorConfig, sdkviewname: '#id_main_parent'}, this.api);
}
/** coauthoring end **/
if (this.appOptions.isEdit) {
var me = this,
application = this.getApplication(),
Expand Down
4 changes: 2 additions & 2 deletions apps/presentationeditor/main/app/view/LeftMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ define([
onCoauthOptions: function(e) {
/** coauthoring begin **/
if (this.mode.canCoAuthoring) {
if (this.mode.canComments) {
if (this.mode.canViewComments) {
if (this.btnComments.pressed && this.btnComments.$el.hasClass('notify'))
this.btnComments.$el.removeClass('notify');
this.panelComments[this.btnComments.pressed?'show':'hide']();
Expand Down Expand Up @@ -274,7 +274,7 @@ define([
this.$el.width(SCALE_MIN);
/** coauthoring begin **/
if (this.mode.canCoAuthoring) {
if (this.mode.canComments) {
if (this.mode.canViewComments) {
this.panelComments['hide']();
if (this.btnComments.pressed)
this.fireEvent('comments:hide', this);
Expand Down
4 changes: 2 additions & 2 deletions apps/spreadsheeteditor/main/app/controller/DocumentHolder.js
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ define([
}
}

if (me.permissions.isEdit || me.permissions.canComments) {
if (me.permissions.isEdit || me.permissions.canViewComments) {
if (index_comments && !this.popupmenu) {
data = dataarray[index_comments - 1];
if (!commentTip.editCommentId && commentTip.moveCommentId != data.asc_getCommentIndexes()[0]) {
Expand Down Expand Up @@ -1015,7 +1015,7 @@ define([

var commentsController = this.getApplication().getController('Common.Controllers.Comments');
if (commentsController) {
if (this.permissions.canCoAuthoring && this.permissions.canComments)
if (this.permissions.canCoAuthoring && this.permissions.canViewComments)
setTimeout(function() {commentsController.onApiHideComment(true);}, 200);
else
commentsController.onApiHideComment(true);
Expand Down
Loading

0 comments on commit f621e67

Please sign in to comment.