[DE] processed toolbar's [Comments] button

This commit is contained in:
Maxim Kadushkin 2017-03-29 19:29:04 +03:00
parent 55e48173ce
commit 98b1168c06
3 changed files with 53 additions and 5 deletions

View file

@ -107,6 +107,7 @@ define([
});
Common.NotificationCenter.on('comments:updatefilter', _.bind(this.onUpdateFilter, this));
Common.NotificationCenter.on('app:comment:add', _.bind(this.onAppAddComment, this));
},
onLaunch: function () {
this.collection = this.getApplication().getCollection('Common.Collections.Comments');
@ -582,6 +583,11 @@ define([
}
}
},
onAppAddComment: function () {
if ( this.api.can_AddQuotedComment() !== false ) {
this.addDummyComment();
}
},
// SDK

View file

@ -101,6 +101,7 @@ define([
});
Common.NotificationCenter.on('leftmenu:change', _.bind(this.onMenuChange, this));
Common.NotificationCenter.on('app:comment:add', _.bind(this.onAppAddComment, this));
},
onLaunch: function() {
@ -503,6 +504,22 @@ define([
}
},
onAppAddComment: function(sender) {
var me = this;
if ( this.api.can_AddQuotedComment() === false ) {
(new Promise(function(resolve, reject) {
resolve();
})).then(function () {
Common.UI.Menu.Manager.hideAll();
me.leftMenu.showMenu('comments');
var ctrl = DE.getController('Common.Controllers.Comments');
ctrl.getView().showEditContainer(true);
ctrl.onAfterShow();
});
}
},
commentsShowHide: function(mode) {
var value = Common.localStorage.getItem("de-settings-livecomment");
if (value !== null && 0 === parseInt(value)) {

View file

@ -174,12 +174,8 @@ define([
me.toolbar.on('render:before', function (cmp) {
});
Common.NotificationCenter.on('app:ready', function () {
// me.setToolbarFolding(true);
});
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me));
Common.NotificationCenter.on('app:face', function (config) {
var _btnsComment = [];
if ( config.canReview ) {
var tab = {action: 'review', caption: 'Review'};
var $panel = DE.getController('Common.Controllers.ReviewChanges').createToolbarPanel();
@ -2807,6 +2803,35 @@ define([
Common.NotificationCenter.trigger('layout:changed', 'toolbar');
},
onAppReady: function (config) {
var me = this;
// me.setToolbarFolding(true);
if (config.canComments) {
var _btnsComment = [];
var slots = me.toolbar.$el.find('.slot-comment');
slots.each(function(index, el) {
var _cls = 'btn-toolbar';
/x-huge/.test(el.className) &&
(_cls += ' x-huge icon-top');
var button = new Common.UI.Button({
cls: _cls,
iconCls: 'btn-menu-comments',
caption: 'Comment'
}).render( slots.eq(index) );
_btnsComment.push(button);
});
_btnsComment.forEach(function(btn) {
btn.on('click', function (btn, e) {
Common.NotificationCenter.trigger('app:comment:add', 'toolbar');
});
}, this);
}
},
textEmptyImgUrl : 'You need to specify image URL.',
textWarning : 'Warning',
textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100',