Debug adding comment from toolbar. [SSE] Lock commenting from toolbar when cell is selected and locked or has comments. Add comment to document when object is selected.

This commit is contained in:
Julia Radzhabova 2017-06-30 14:33:31 +03:00
parent 64355cc7db
commit 10df370024
3 changed files with 25 additions and 7 deletions

View file

@ -583,8 +583,8 @@ define([
} }
} }
}, },
onAppAddComment: function () { onAppAddComment: function (sender, to_doc) {
if ( this.can_AddQuotedComment && this.api.can_AddQuotedComment() === false ) return; if ( !!this.api.can_AddQuotedComment && this.api.can_AddQuotedComment() === false || to_doc) return;
this.addDummyComment(); this.addDummyComment();
}, },

View file

@ -87,6 +87,7 @@ define([
'search:replaceall': _.bind(this.onQueryReplaceAll, this) 'search:replaceall': _.bind(this.onQueryReplaceAll, this)
} }
}); });
Common.NotificationCenter.on('app:comment:add', _.bind(this.onAppAddComment, this));
}, },
onLaunch: function() { onLaunch: function() {
@ -550,6 +551,22 @@ define([
} }
}, },
onAppAddComment: function(sender, to_doc) {
if ( to_doc ) {
var me = this;
(new Promise(function(resolve, reject) {
resolve();
})).then(function () {
Common.UI.Menu.Manager.hideAll();
me.leftMenu.showMenu('comments');
var ctrl = SSE.getController('Common.Controllers.Comments');
ctrl.getView().showEditContainer(true);
ctrl.onAfterShow();
});
}
},
commentsShowHide: function(state) { commentsShowHide: function(state) {
if (this.api) { if (this.api) {
var value = Common.localStorage.getItem("sse-settings-livecomment"), var value = Common.localStorage.getItem("sse-settings-livecomment"),

View file

@ -1600,7 +1600,7 @@ define([
toolbar.mnuitemClearFilter, toolbar.mnuitemClearFilter,
toolbar.btnNamedRange.menu.items[0], toolbar.btnNamedRange.menu.items[0],
toolbar.btnNamedRange.menu.items[1] toolbar.btnNamedRange.menu.items[1]
].concat(this.btnsComment), ],
merge: true, merge: true,
clear: [SSE.enumLock.editFormula, SSE.enumLock.editText] clear: [SSE.enumLock.editFormula, SSE.enumLock.editText]
}); });
@ -2088,7 +2088,8 @@ define([
toolbar.btnDeleteCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down); toolbar.btnDeleteCell.menu.items[1].setDisabled(this._state.controlsdisabled.cells_down);
} }
toolbar.lockToolbar(SSE.enumLock.commentLock, info.asc_getComments().length>0, { array: this.btnsComment }); toolbar.lockToolbar(SSE.enumLock.commentLock, (selectionType == Asc.c_oAscSelectionType.RangeCells) && (info.asc_getComments().length>0 || info.asc_getLocked()),
{ array: this.btnsComment });
}, },
onApiSelectionChanged_DiagramEditor: function(info) { onApiSelectionChanged_DiagramEditor: function(info) {
@ -2676,7 +2677,7 @@ define([
toolbar.mnuitemSortZA, toolbar.mnuitemSortZA,
toolbar.mnuitemAutoFilter, toolbar.mnuitemAutoFilter,
toolbar.mnuitemClearFilter toolbar.mnuitemClearFilter
].concat(this.btnsComment), ],
merge: true, merge: true,
clear: [_set.selImage, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.coAuth] clear: [_set.selImage, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.coAuth]
}); });
@ -2897,7 +2898,7 @@ define([
var button = new Common.UI.Button({ var button = new Common.UI.Button({
cls: _cls, cls: _cls,
iconCls: 'btn-menu-comments', iconCls: 'btn-menu-comments',
lock: [_set.editCell, _set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.lostConnect, _set.coAuth, _set.commentLock], lock: [_set.lostConnect, _set.commentLock],
caption: me.toolbar.capBtnComment caption: me.toolbar.capBtnComment
}).render( slots.eq(index) ); }).render( slots.eq(index) );
@ -2910,7 +2911,7 @@ define([
this.btnsComment.forEach(function (btn) { this.btnsComment.forEach(function (btn) {
btn.updateHint( _comments.textAddComment ); btn.updateHint( _comments.textAddComment );
btn.on('click', function (btn, e) { btn.on('click', function (btn, e) {
Common.NotificationCenter.trigger('app:comment:add', 'toolbar'); Common.NotificationCenter.trigger('app:comment:add', 'toolbar', me.api.asc_getCellInfo().asc_getFlags().asc_getSelectionType() != Asc.c_oAscSelectionType.RangeCells);
}); });
}, this); }, this);
} }