From 98b1168c0688dfa1cbfcc7dc81445090511cbed8 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Wed, 29 Mar 2017 19:29:04 +0300 Subject: [PATCH] [DE] processed toolbar's [Comments] button --- apps/common/main/lib/controller/Comments.js | 6 ++++ .../main/app/controller/LeftMenu.js | 17 +++++++++ .../main/app/controller/Toolbar.js | 35 ++++++++++++++++--- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/apps/common/main/lib/controller/Comments.js b/apps/common/main/lib/controller/Comments.js index 19920d4ba..435b4c1e6 100644 --- a/apps/common/main/lib/controller/Comments.js +++ b/apps/common/main/lib/controller/Comments.js @@ -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 diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 2ba7f930c..4097c9546 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -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)) { diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index b0461d6cb..3dde29338 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -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.
Please enter a numeric value between 1 and 100',