Show comments in view mode (hints, left panel, advanced settings in the File menu)

This commit is contained in:
Julia Radzhabova 2018-12-17 11:37:43 +03:00
parent 1153d9a803
commit f621e671eb
19 changed files with 131 additions and 66 deletions

View file

@ -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'));
},

View file

@ -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;
},
//
@ -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) {
@ -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();
}
},

View file

@ -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">
@ -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>
@ -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 { %>
@ -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>

View file

@ -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') {
@ -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() {

View file

@ -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;

View file

@ -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']();
@ -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 **/
@ -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']();
}
}
@ -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();

View file

@ -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);
@ -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(),

View file

@ -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 **/
},

View file

@ -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']();
@ -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);

View file

@ -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']();
@ -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();

View file

@ -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;
@ -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(),

View file

@ -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']();
@ -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);

View file

@ -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]) {
@ -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);

View file

@ -189,8 +189,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']();
@ -349,7 +349,7 @@ define([
var resolved = Common.localStorage.getBool("sse-settings-resolvedcomment");
Common.Utils.InternalSettings.set("sse-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();
@ -713,7 +713,7 @@ define([
if (!state && 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']();
}
}
@ -818,7 +818,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();

View file

@ -902,6 +902,7 @@ define([
/** coauthoring end **/
this.appOptions.canComments = this.appOptions.canLicense && (this.permissions.comment===undefined ? (this.permissions.edit !== false) : 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.canRename = this.editorConfig.canRename && !!this.permissions.rename;
this.appOptions.trialMode = params.asc_getLicenseMode();
@ -1001,19 +1002,17 @@ 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 : '#ws-canvas-outer',
hintmode : true},
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 : '#ws-canvas-outer',
hintmode : true},
this.api);
}
/** coauthoring end **/
if (this.appOptions.isEdit) {
var me = this,
@ -1623,7 +1622,7 @@ define([
if (!this.appOptions.isEditMailMerge && !this.appOptions.isEditDiagram && window.editor_elements_prepared) {
this.application.getController('Statusbar').selectTab(index);
if (this.appOptions.canComments && !this.dontCloseDummyComment) {
if (this.appOptions.canViewComments && !this.dontCloseDummyComment) {
Common.NotificationCenter.trigger('comments:updatefilter', ['doc', 'sheet' + this.api.asc_getWorksheetId(index)], false ); // hide popover
}
}

View file

@ -267,9 +267,9 @@ define([
me.header.mnuitemFreezePanes.hide();
menu.items[5].hide();
menu.items[7].hide();
if (!config.canComments) { // show advanced settings for editing and commenting mode
mnuitemAdvSettings.hide();
menu.items[9].hide();
if (!config.canViewComments) { // show advanced settings for editing and commenting mode
// mnuitemAdvSettings.hide();
// menu.items[9].hide();
}
}

View file

@ -255,8 +255,8 @@ define([
this.miAccess[(!this.mode.isOffline && this.document&&this.document.info&&(this.document.info.sharingSettings&&this.document.info.sharingSettings.length>0 ||
this.mode.sharingSettingsUrl&&this.mode.sharingSettingsUrl.length))?'show':'hide']();
this.miSettings[(this.mode.isEdit || this.mode.canComments)?'show':'hide']();
this.miSettings.$el.prev()[(this.mode.isEdit || this.mode.canComments)?'show':'hide']();
// this.miSettings[(this.mode.isEdit || this.mode.canViewComments)?'show':'hide']();
// this.miSettings.$el.prev()[(this.mode.isEdit || this.mode.canViewComments)?'show':'hide']();
this.mode.canBack ? this.$el.find('#fm-btn-back').show().prev().show() :
this.$el.find('#fm-btn-back').hide().prev().hide();

View file

@ -746,7 +746,7 @@ define([
this.lblAutosave.text(this.textAutoRecover);
}
$('tr.forcesave', this.el)[mode.canForcesave ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring && (mode.isEdit || mode.canComments) ? 'show' : 'hide']();
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
$('tr.coauth.changes', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring? 'show' : 'hide']();
},

View file

@ -193,7 +193,7 @@ define([
/** coauthoring begin **/
onCoauthOptions: function(e) {
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']();
@ -247,7 +247,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);