[DE] Lock controls when document is protected (review only)

This commit is contained in:
Julia Radzhabova 2022-09-26 23:34:59 +03:00
parent 7f703b6294
commit 8f1f89ee31
3 changed files with 47 additions and 20 deletions

View file

@ -167,13 +167,15 @@ define([
SetDisabled: function(state, reviewMode, fillFormMode) {
if (this.dlgChanges)
this.dlgChanges.close();
if (reviewMode)
if (reviewMode) {
this.lockToolbar(Common.enumLock.previewReviewMode, state);
else if (fillFormMode)
this.dlgChanges && Common.Utils.lockControls(Common.enumLock.previewReviewMode, state, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
} else if (fillFormMode) {
this.lockToolbar(Common.enumLock.viewFormMode, state);
else
this.dlgChanges && Common.Utils.lockControls(Common.enumLock.viewFormMode, state, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
} else {
this.lockToolbar(Common.enumLock.viewMode, state);
}
this.setPreviewMode(state);
},
@ -218,17 +220,14 @@ define([
onApiShowChange: function (sdkchange, isShow) {
var btnlock = true,
changes;
if (this.appConfig.canReview && !this.appConfig.isReviewOnly) {
if (this.appConfig.canReview && !(this.appConfig.isReviewOnly || Common.Utils.Store.get('docProtection', {}).isReviewOnly)) {
if (sdkchange && sdkchange.length>0) {
changes = this.readSDKChange(sdkchange);
btnlock = this.isSelectedChangesLocked(changes, isShow);
}
if (this._state.lock !== btnlock) {
Common.Utils.lockControls(Common.enumLock.reviewChangelock, btnlock, {array: [this.view.btnAccept, this.view.btnReject]});
if (this.dlgChanges) {
this.dlgChanges.btnAccept.setDisabled(btnlock);
this.dlgChanges.btnReject.setDisabled(btnlock);
}
this.dlgChanges && Common.Utils.lockControls(Common.enumLock.reviewChangelock, btnlock, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
this._state.lock = btnlock;
Common.Utils.InternalSettings.set(this.view.appPrefix + "accept-reject-lock", btnlock);
}
@ -496,6 +495,7 @@ define([
}
var date = (item.get_DateTime() == '') ? new Date() : new Date(item.get_DateTime()),
user = me.userCollection.findOriginalUser(item.get_UserId()),
isProtectedReview = !!Common.Utils.Store.get('docProtection', {}).isReviewOnly,
change = new Common.Models.ReviewChange({
uid : Common.UI.getId(),
userid : item.get_UserId(),
@ -511,7 +511,7 @@ define([
scope : me.view,
hint : !me.appConfig.canReview,
goto : (item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveTo || item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveFrom),
editable : me.appConfig.isReviewOnly && (item.get_UserId() == me.currentUserId) || !me.appConfig.isReviewOnly && (!me.appConfig.canUseReviewPermissions || AscCommon.UserInfoParser.canEditReview(item.get_UserName()))
editable : (me.appConfig.isReviewOnly || isProtectedReview) && (item.get_UserId() == me.currentUserId) || !(me.appConfig.isReviewOnly || isProtectedReview) && (!me.appConfig.canUseReviewPermissions || AscCommon.UserInfoParser.canEditReview(item.get_UserName()))
});
arr.push(change);
@ -600,7 +600,7 @@ define([
},
onTurnPreview: function(state, global, fromApi) {
if ( this.appConfig.isReviewOnly ) {
if ( this.appConfig.isReviewOnly) {
this.view.turnChanges(true);
} else
if ( this.appConfig.canReview ) {
@ -614,7 +614,7 @@ define([
},
onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) {
if ( this.appConfig.isReviewOnly ) {
if ( this.appConfig.isReviewOnly || Common.Utils.Store.get('docProtection', {}).isReviewOnly) {
this.view.turnChanges(true);
} else
if ( this.appConfig.canReview ) {
@ -983,7 +983,8 @@ define([
},
onCoAuthoringDisconnect: function() {
this.lockToolbar(Common.enumLock.lostConnect, true)
this.lockToolbar(Common.enumLock.lostConnect, true);
this.dlgChanges && Common.Utils.lockControls(Common.enumLock.lostConnect, true, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
},
onUpdateUsers: function() {
@ -1034,6 +1035,22 @@ define([
this.lockToolbar(Common.enumLock.docLockForms, docProtection.isFormsOnly);
this.lockToolbar(Common.enumLock.docLockReview, docProtection.isReviewOnly);
this.lockToolbar(Common.enumLock.docLockComments, docProtection.isCommentsOnly);
if (this.dlgChanges) {
Common.Utils.lockControls(Common.enumLock.docLockView, docProtection.isReadOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
Common.Utils.lockControls(Common.enumLock.docLockForms, docProtection.isFormsOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
Common.Utils.lockControls(Common.enumLock.docLockReview, docProtection.isReviewOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
Common.Utils.lockControls(Common.enumLock.docLockComments, docProtection.isCommentsOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
}
if (this.appConfig.canReview) {
if (docProtection.isReviewOnly) {
this.onTurnPreview(true);
this.onApiShowChange();
} else if (this._state.prevReviewProtected) {
this.onTurnPreview(false);
this.onApiShowChange();
}
this._state.prevReviewProtected = docProtection.isReviewOnly;
}
this.updatePreviewMode();
}
},

View file

@ -9,7 +9,7 @@
<div class="btn-goto img-commonctrl"></div>
<% } %>
<% if (!hint) { %>
<% if (scope.appConfig.isReviewOnly) { %>
<% if (scope.appConfig.isReviewOnly || Common.Utils.Store.get("docProtection", {}).isReviewOnly) { %>
<% if (editable) { %>
<div class="btn-delete img-commonctrl"></div>
<% } %>

View file

@ -259,7 +259,7 @@ define([
caption: this.txtAccept,
split: !this.appConfig.canUseReviewPermissions,
iconCls: 'toolbar__icon btn-review-save',
lock: [_set.reviewChangelock, _set.isReviewOnly, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments],
lock: [_set.reviewChangelock, _set.isReviewOnly, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.docLockReview],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
@ -271,7 +271,7 @@ define([
caption: this.txtReject,
split: !this.appConfig.canUseReviewPermissions,
iconCls: 'toolbar__icon btn-review-deny',
lock: [_set.reviewChangelock, _set.isReviewOnly, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments],
lock: [_set.reviewChangelock, _set.isReviewOnly, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.docLockReview],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
@ -294,7 +294,7 @@ define([
this.btnTurnOn = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-ic-review',
lock: [_set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments],
lock: [_set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.docLockReview],
caption: this.txtTurnon,
split: !this.appConfig.isReviewOnly,
enableToggle: true,
@ -731,7 +731,7 @@ define([
var button = new Common.UI.Button({
cls : 'btn-toolbar',
iconCls : 'toolbar__icon btn-ic-review',
lock: [Common.enumLock.viewMode, Common.enumLock.previewReviewMode, Common.enumLock.viewFormMode, Common.enumLock.lostConnect, Common.enumLock.docLockView, Common.enumLock.docLockForms, Common.enumLock.docLockComments],
lock: [Common.enumLock.viewMode, Common.enumLock.previewReviewMode, Common.enumLock.viewFormMode, Common.enumLock.lostConnect, Common.enumLock.docLockView, Common.enumLock.docLockForms, Common.enumLock.docLockComments, Common.enumLock.docLockReview],
hintAnchor : 'top',
hint : this.tipReview,
split : !this.appConfig.isReviewOnly,
@ -983,6 +983,7 @@ define([
render: function() {
Common.UI.Window.prototype.render.call(this);
var _set = Common.enumLock;
this.btnPrev = new Common.UI.Button({
cls: 'dlg-btn iconic',
iconCls: 'img-commonctrl prev',
@ -1003,7 +1004,8 @@ define([
cls : 'btn-toolbar',
caption : this.txtAccept,
split : true,
disabled : this.mode.isReviewOnly || !!Common.Utils.InternalSettings.get(this.appPrefix + "accept-reject-lock"),
disabled : this.mode.isReviewOnly || Common.Utils.Store.get('docProtection', {}).isReviewOnly || !!Common.Utils.InternalSettings.get(this.appPrefix + "accept-reject-lock"),
lock : [_set.reviewChangelock, _set.isReviewOnly, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.docLockReview],
menu : this.mode.canUseReviewPermissions ? false : new Common.UI.Menu({
items: [
this.mnuAcceptCurrent = new Common.UI.MenuItem({
@ -1023,7 +1025,7 @@ define([
cls : 'btn-toolbar',
caption : this.txtReject,
split : true,
disabled : this.mode.isReviewOnly || !!Common.Utils.InternalSettings.get(this.appPrefix + "accept-reject-lock"),
lock : [_set.reviewChangelock, _set.isReviewOnly, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.docLockReview],
menu : this.mode.canUseReviewPermissions ? false : new Common.UI.Menu({
items: [
this.mnuRejectCurrent = new Common.UI.MenuItem({
@ -1038,6 +1040,14 @@ define([
})
});
this.btnReject.render(this.$window.find('#id-review-button-reject'));
var arr = [this.btnAccept, this.btnReject];
Common.Utils.lockControls(Common.enumLock.isReviewOnly, this.mode.isReviewOnly, {array: arr});
var docProtection = Common.Utils.Store.get('docProtection', {});
Common.Utils.lockControls(Common.enumLock.docLockView, docProtection.isReadOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockForms, docProtection.isFormsOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockReview, docProtection.isReviewOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockComments, docProtection.isCommentsOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.reviewChangelock, !!Common.Utils.InternalSettings.get(this.appPrefix + "accept-reject-lock"), {array: arr});
var me = this;
this.btnPrev.on('click', function (e) {