[Common] refacted 'ReviewChanges'

This commit is contained in:
Maxim Kadushkin 2017-03-29 12:33:20 +03:00
parent 5ed32d082c
commit ac79eacb35
2 changed files with 53 additions and 46 deletions

View file

@ -109,10 +109,6 @@ define([
var toolbar = this.getApplication().getController('Toolbar').getView('Toolbar'); var toolbar = this.getApplication().getController('Toolbar').getView('Toolbar');
toolbar.addTab(tab, $panel, 3); toolbar.addTab(tab, $panel, 3);
this.view.isReviewOnly = mode.isReviewOnly;
this.view.btnAccept.setDisabled(mode.isReviewOnly);
this.view.btnReject.setDisabled(mode.isReviewOnly);
} }
return this; return this;
@ -138,7 +134,7 @@ define([
this.getPopover().show(animate, lock, lockUser); this.getPopover().show(animate, lock, lockUser);
if (!this.view.isReviewOnly && this._state.lock !== lock) { if (!this.view.appConfig.isReviewOnly && this._state.lock !== lock) {
this.view.btnAccept.setDisabled(lock==true); this.view.btnAccept.setDisabled(lock==true);
this.view.btnReject.setDisabled(lock==true); this.view.btnReject.setDisabled(lock==true);
this._state.lock = lock; this._state.lock = lock;
@ -411,10 +407,10 @@ define([
return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date); return (date.getMonth() + 1) + '/' + (date.getDate()) + '/' + date.getFullYear() + ' ' + format(date);
}, },
onBtnPreviewClick: function(btn, eOpts){ onBtnPreviewClick: function(btn, opts){
switch (btn.options.value) { switch (opts) {
case 1: this.api.asc_GetPrevRevisionsChange(); break; case 'prev': this.api.asc_GetPrevRevisionsChange(); break;
case 2: this.api.asc_GetNextRevisionsChange(); break; case 'next': this.api.asc_GetNextRevisionsChange(); break;
} }
Common.NotificationCenter.trigger('edit:complete', this.view); Common.NotificationCenter.trigger('edit:complete', this.view);
@ -457,6 +453,11 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.view); Common.NotificationCenter.trigger('edit:complete', this.view);
}, },
getView: function(name) {
return !name && this.view ?
this.view : Backbone.Controller.prototype.getView.call(this, name);
},
textInserted: '<b>Inserted:</b>', textInserted: '<b>Inserted:</b>',
textDeleted: '<b>Deleted:</b>', textDeleted: '<b>Deleted:</b>',
textParaInserted: '<b>Paragraph Inserted</b> ', textParaInserted: '<b>Paragraph Inserted</b> ',

View file

@ -430,11 +430,11 @@ define([
function setEvents() { function setEvents() {
var me = this; var me = this;
this.btnPrev.on('click', function (e) { this.btnPrev.on('click', function (e) {
me.fireEvent('reviewchange:preview', [me.btnPrev]); me.fireEvent('reviewchange:preview', [me.btnPrev, 'prev']);
}); });
this.btnNext.on('click', function (e) { this.btnNext.on('click', function (e) {
me.fireEvent('reviewchange:preview', [me.btnNext]); me.fireEvent('reviewchange:preview', [me.btnNext, 'next']);
}); });
this.btnAccept.on('click', function (e) { this.btnAccept.on('click', function (e) {
@ -468,53 +468,27 @@ define([
this.btnPrev = new Common.UI.Button({ this.btnPrev = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'img-commonctrl review-prev', iconCls: 'img-commonctrl review-prev',
caption: this.txtPrev, caption: this.txtPrev
value: 1
}); });
this.btnNext = new Common.UI.Button({ this.btnNext = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
iconCls: 'img-commonctrl review-next', iconCls: 'img-commonctrl review-next',
caption: this.txtNext, caption: this.txtNext
value: 2
}); });
this.btnAccept = new Common.UI.Button({ this.btnAccept = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
caption: this.txtAccept, caption: this.txtAccept,
split: true, split: true,
iconCls: 'img-commonctrl review-close', iconCls: 'img-commonctrl review-close'
menu: new Common.UI.Menu({
items: [
this.mnuAcceptCurrent = new Common.UI.MenuItem({
caption: this.txtAcceptCurrent,
value: 'current'
}),
this.mnuAcceptAll = new Common.UI.MenuItem({
caption: this.txtAcceptAll,
value: 'all'
})
]
})
}); });
this.btnReject = new Common.UI.Button({ this.btnReject = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
caption: this.txtReject, caption: this.txtReject,
split: true, split: true,
iconCls: 'img-commonctrl review-close', iconCls: 'img-commonctrl review-close'
menu: new Common.UI.Menu({
items: [
this.mnuRejectCurrent = new Common.UI.MenuItem({
caption: this.txtRejectCurrent,
value: 'current'
}),
this.mnuRejectAll = new Common.UI.MenuItem({
caption: this.txtRejectAll,
value: 'all'
})
]
})
}); });
this.btnTurnOn = new Common.UI.Button({ this.btnTurnOn = new Common.UI.Button({
@ -524,15 +498,47 @@ define([
}); });
var me = this; var me = this;
(new Promise(function (resolve) { var promise = new Promise( function(resolve) { resolve(); });
Common.NotificationCenter.on('app:ready', function () { resolve(); });
})).then(function(){ Common.NotificationCenter.on('app:ready', function (cfg) {
promise.then(function(){
me.appConfig = cfg;
me.btnPrev.updateHint(me.hintPrev); me.btnPrev.updateHint(me.hintPrev);
me.btnNext.updateHint(me.hintNext); me.btnNext.updateHint(me.hintNext);
me.btnTurnOn.updateHint(me.textChangesOn); me.btnTurnOn.updateHint(me.textChangesOn);
me.btnAccept.setMenu(
new Common.UI.Menu({
items: [
{
caption: me.txtAcceptCurrent,
value: 'current'
},
{
caption: me.txtAcceptAll,
value: 'all'
}
]
})
);
me.btnReject.setMenu(
new Common.UI.Menu({
items: [
{
caption: me.txtRejectCurrent,
value: 'current'
},
{
caption: me.txtRejectAll,
value: 'all'
}
]
})
);
setEvents.call(me); setEvents.call(me);
} });
); });
}, },
render: function (el) { render: function (el) {