[DE] processed permissions for review

This commit is contained in:
Maxim Kadushkin 2017-04-05 12:11:15 +03:00
parent 53309aab82
commit 0cf3621991
4 changed files with 145 additions and 123 deletions

View file

@ -80,7 +80,6 @@ define([
},
onLaunch: function () {
this.collection = this.getApplication().getCollection('Common.Collections.ReviewChanges');
this.popoverChanges = new Common.Collections.ReviewChanges();
this.userCollection = this.getApplication().getCollection('Common.Collections.Users');
this._state = {posx: -1000, posy: -1000, popoverVisible: false};
@ -107,12 +106,16 @@ define([
},
setMode: function(mode) {
if ( mode.canReview || mode.isReviewOnly ) {
this.appConfig = mode;
if ( mode.canReview ) {
this.popoverChanges = new Common.Collections.ReviewChanges();
}
this.view = this.createView('Common.Views.ReviewChanges', {
// store : this.collection,
popoverChanges : this.popoverChanges
popoverChanges : this.popoverChanges,
mode : mode
});
}
return this;
},
@ -137,7 +140,7 @@ define([
this.getPopover().show(animate, lock, lockUser);
if (!this.view.appConfig.isReviewOnly && this._state.lock !== lock) {
if (!this.appConfig.isReviewOnly && this._state.lock !== lock) {
this.view.btnAccept.setDisabled(lock==true);
this.view.btnReject.setDisabled(lock==true);
this._state.lock = lock;
@ -457,10 +460,10 @@ define([
},
onTurnPreview: function(state) {
if ( this.view.appConfig.isReviewOnly ) {
if ( this.appConfig.isReviewOnly ) {
this.view.turnChanges(true);
} else
if ( this.view.appConfig.canReview ) {
if ( this.appConfig.canReview ) {
state = (state == 'on');
this.api.asc_SetTrackRevisions(state);
@ -491,7 +494,6 @@ define([
if ( config.canReview ) {
var me = this;
this.appConfig = config;
(new Promise(function (resolve) {
resolve();
})).then(function () {

View file

@ -416,11 +416,11 @@ define([
'<span id="slot-set-lang" class="btn-slot text x-huge"></span>' +
'<span id="slot-btn-spelling" class="btn-slot text x-huge"></span>' +
'</div>' +
'<div class="separator long"/>' +
'<div class="separator long comments"/>' +
'<div class="group">' +
'<span class="btn-slot text x-huge slot-comment"></span>' +
'</div>' +
'<div class="separator long"/>' +
'<div class="separator long review"/>' +
'<div class="group">' +
'<span id="btn-review-on" class="btn-slot text x-huge"></span>' +
'<span id="btn-change-prev" class="btn-slot text x-huge"></span>' +
@ -432,6 +432,8 @@ define([
function setEvents() {
var me = this;
if ( me.appConfig.canReview ) {
this.btnPrev.on('click', function (e) {
me.fireEvent('reviewchange:preview', [me.btnPrev, 'prev']);
});
@ -457,15 +459,16 @@ define([
});
function _click_turnpreview(btn, e) {
if ( me.appConfig.canReview ) {
if (me.appConfig.canReview) {
Common.NotificationCenter.trigger('reviewchanges:turn', btn.pressed ? 'on' : 'off');
}
};
this.btnsTurnReview.forEach(function(button) {
this.btnsTurnReview.forEach(function (button) {
button.on('click', _click_turnpreview.bind(me));
Common.NotificationCenter.trigger('edit:complete', me);
});
}
this.btnsSpelling.forEach(function(button) {
button.on('click', function (b, e) {
@ -480,7 +483,7 @@ define([
}
return {
el: '#review-changes-panel',
// el: '#review-changes-panel',
options: {},
@ -489,7 +492,9 @@ define([
// this.store = this.options.store;
// this.popoverChanges = this.options.popoverChanges;
this.appConfig = options.mode;
if ( this.appConfig.canReview ) {
this.btnPrev = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'review-prev',
@ -523,6 +528,7 @@ define([
enableToggle: true
});
this.btnsTurnReview = [this.btnTurnOn];
}
this.btnSetSpelling = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
@ -553,13 +559,10 @@ define([
(new Promise(function (accept, reject) {
accept();
})).then(function(){
me.appConfig = config;
if ( config.canReview ) {
me.btnPrev.updateHint(me.hintPrev);
me.btnNext.updateHint(me.hintNext);
me.btnTurnOn.updateHint(me.textChangesOn);
me.btnDocLang.updateHint(me.tipSetDocLang);
me.btnSetSpelling.updateHint(me.tipSetSpelling);
me.btnAccept.setMenu(
new Common.UI.Menu({
@ -593,23 +596,40 @@ define([
me.btnAccept.setDisabled(config.isReviewOnly);
me.btnReject.setDisabled(config.isReviewOnly);
} else {
me.$el.find('.separator.review')
.hide()
.next('.group').hide();
}
if ( !config.canComments ) {
$('.separator.comments', me.$el)
.hide()
.next('.group').hide();
}
me.btnDocLang.updateHint(me.tipSetDocLang);
me.btnSetSpelling.updateHint(me.tipSetSpelling);
setEvents.call(me);
});
},
getPanel: function () {
var _html = $(_.template( template, {} ));
this.$el = $(_.template( template, {} ));
this.btnPrev.render(_html.find('#btn-change-prev'));
this.btnNext.render(_html.find('#btn-change-next'));
this.btnAccept.render(_html.find('#btn-change-accept'));
this.btnReject.render(_html.find('#btn-change-reject'));
this.btnTurnOn.render(_html.find('#btn-review-on'));
this.btnSetSpelling.render(_html.find('#slot-btn-spelling'));
this.btnDocLang.render(_html.find('#slot-set-lang'));
if ( this.appConfig.canReview ) {
this.btnPrev.render(this.$el.find('#btn-change-prev'));
this.btnNext.render(this.$el.find('#btn-change-next'));
this.btnAccept.render(this.$el.find('#btn-change-accept'));
this.btnReject.render(this.$el.find('#btn-change-reject'));
this.btnTurnOn.render(this.$el.find('#btn-review-on'));
}
return _html;
this.btnSetSpelling.render(this.$el.find('#slot-btn-spelling'));
this.btnDocLang.render(this.$el.find('#slot-set-lang'));
return this.$el;
},
show: function () {

View file

@ -43,8 +43,7 @@
define([
'core',
'documenteditor/main/app/view/Statusbar',
'common/main/lib/util/LanguageInfo',
'common/main/lib/view/ReviewChanges'
'common/main/lib/util/LanguageInfo'
], function () {
'use strict';
@ -89,18 +88,18 @@ define([
$('.statusbar #label-zoom').css('min-width', 70);
if ( cfg.canReview ) {
var review = DE.getController('Common.Controllers.ReviewChanges').getView();
if ( cfg.canReview ) {
me.btnTurnReview = review.getButton('turn', 'statusbar');
me.btnTurnReview.render( me.statusbar.$layout.find('#btn-doc-review') );
me.btnSpelling = review.getButton('spelling', 'statusbar');
me.btnSpelling.render( me.statusbar.$layout.find('#btn-doc-spell') );
} else {
me.statusbar.$el.find('.el-review').hide();
}
if ( !cfg.isEdit ) {
if ( cfg.isEdit ) {
me.btnSpelling = review.getButton('spelling', 'statusbar');
me.btnSpelling.render( me.statusbar.$layout.find('#btn-doc-spell') );
} else {
me.statusbar.$el.find('.el-edit')['hide']();
}
});

View file

@ -2742,7 +2742,8 @@ define([
onAppShowed: function (config) {
var me = this;
if ( config.canReview ) {
// if ( config.canReview )
{
var tab = {action: 'review', caption: 'Review'};
var $panel = DE.getController('Common.Controllers.ReviewChanges').createToolbarPanel();