[DE] Refactoring document protection

This commit is contained in:
Julia Radzhabova 2022-09-28 01:01:27 +03:00
parent 9adcc64e9b
commit 6f1ee48c6d
14 changed files with 187 additions and 144 deletions

View file

@ -145,13 +145,18 @@ define([
}, this, area);
}.bind(this));
Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this));
Common.NotificationCenter.on('protect:doclock', _.bind(this.onChangeProtectDocument, this));
},
onLaunch: function () {
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
this._state = {
disableEditing: false // disable editing when disconnect/signed file/mail merge preview/review final or original/forms preview
disableEditing: false, // disable editing when disconnect/signed file/mail merge preview/review final or original/forms preview
docProtection: {
isReadOnly: false,
isReviewOnly: false,
isFormsOnly: false,
isCommentsOnly: false
}
};
this.collection = this.getApplication().getCollection('Common.Collections.Comments');
@ -1655,8 +1660,8 @@ define([
},
updatePreviewMode: function() {
var docProtection = Common.Utils.Store.get('docProtection', {});
var viewmode = this._state.disableEditing || !!docProtection.isReadOnly || !!docProtection.isFormsOnly;
var docProtection = this._state.docProtection;
var viewmode = this._state.disableEditing || docProtection.isReadOnly || docProtection.isFormsOnly;
if (this.viewmode === viewmode) return;
this.viewmode = viewmode;
@ -1740,17 +1745,19 @@ define([
accept();
})).then(function(){
me.onChangeProtectDocument();
Common.NotificationCenter.on('protect:doclock', _.bind(me.onChangeProtectDocument, me));
});
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection)
if (props) {
this._state.docProtection = props;
this.updatePreviewMode();
}
}
}, Common.Controllers.Comments || {}));

View file

@ -82,7 +82,8 @@ define([
'reviewchange:view': _.bind(this.onReviewViewClick, this),
'reviewchange:compare': _.bind(this.onCompareClick, this),
'lang:document': _.bind(this.onDocLanguage, this),
'collaboration:coauthmode': _.bind(this.onCoAuthMode, this)
'collaboration:coauthmode': _.bind(this.onCoAuthMode, this),
'protect:update': _.bind(this.onChangeProtectDocument, this)
},
'Common.Views.ReviewChangesDialog': {
'reviewchange:accept': _.bind(this.onAcceptClick, this),
@ -103,7 +104,13 @@ define([
this.viewmode = false;
this._state = { posx: -1000, posy: -1000, popoverVisible: false, previewMode: false, compareSettings: null, wsLock: false, wsProps: [],
disableEditing: false // disable editing when disconnect/signed file/mail merge preview/review final or original/forms preview
disableEditing: false, // disable editing when disconnect/signed file/mail merge preview/review final or original/forms preview
docProtection: {
isReadOnly: false,
isReviewOnly: false,
isFormsOnly: false,
isCommentsOnly: false
}
};
Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this));
@ -113,7 +120,6 @@ define([
Common.NotificationCenter.on('collaboration:sharing', this.changeAccessRights.bind(this));
Common.NotificationCenter.on('collaboration:sharingdeny', this.onLostEditRights.bind(this));
Common.NotificationCenter.on('protect:wslock', _.bind(this.onChangeProtectSheet, this));
Common.NotificationCenter.on('protect:doclock', _.bind(this.onChangeProtectDocument, this));
this.userCollection.on('reset', _.bind(this.onUpdateUsers, this));
this.userCollection.on('add', _.bind(this.onUpdateUsers, this));
@ -189,8 +195,7 @@ define([
},
updatePreviewMode: function() {
var docProtection = Common.Utils.Store.get('docProtection', {});
var viewmode = this._state.disableEditing || !!docProtection.isReadOnly || !!docProtection.isFormsOnly || !!docProtection.isCommentsOnly;
var viewmode = this._state.disableEditing || this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly || this._state.docProtection.isCommentsOnly;
if (this.viewmode === viewmode) return;
this.viewmode = viewmode;
@ -220,7 +225,7 @@ define([
onApiShowChange: function (sdkchange, isShow) {
var btnlock = true,
changes;
if (this.appConfig.canReview && !(this.appConfig.isReviewOnly || Common.Utils.Store.get('docProtection', {}).isReviewOnly)) {
if (this.appConfig.canReview && !(this.appConfig.isReviewOnly || this._state.docProtection.isReviewOnly)) {
if (sdkchange && sdkchange.length>0) {
changes = this.readSDKChange(sdkchange);
btnlock = this.isSelectedChangesLocked(changes, isShow);
@ -495,7 +500,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,
isProtectedReview = me._state.docProtection.isReviewOnly,
change = new Common.Models.ReviewChange({
uid : Common.UI.getId(),
userid : item.get_UserId(),
@ -510,6 +515,7 @@ define([
changedata : item,
scope : me.view,
hint : !me.appConfig.canReview,
docProtection: me._state.docProtection,
goto : (item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveTo || item.get_MoveType() == Asc.c_oAscRevisionsMove.MoveFrom),
editable : (me.appConfig.isReviewOnly || isProtectedReview) && (item.get_UserId() == me.currentUserId) || !(me.appConfig.isReviewOnly || isProtectedReview) && (!me.appConfig.canUseReviewPermissions || AscCommon.UserInfoParser.canEditReview(item.get_UserName()))
});
@ -614,7 +620,7 @@ define([
},
onApiTrackRevisionsChange: function(localFlag, globalFlag, userId) {
if ( this.appConfig.isReviewOnly || Common.Utils.Store.get('docProtection', {}).isReviewOnly) {
if ( this.appConfig.isReviewOnly || this._state.docProtection.isReviewOnly) {
this.view.turnChanges(true);
} else
if ( this.appConfig.canReview ) {
@ -873,7 +879,8 @@ define([
(!me.appConfig.customization.review || me.appConfig.customization.review.showReviewChanges===undefined) && me.appConfig.customization.showReviewChanges==true) ) {
me.dlgChanges = (new Common.Views.ReviewChangesDialog({
popoverChanges : me.popoverChanges,
mode : me.appConfig
mode : me.appConfig,
docProtection : me._state.docProtection
}));
var sdk = $('#editor_sdk'),
offset = sdk.offset();
@ -900,7 +907,6 @@ define([
});
}
me.onChangeProtectSheet();
me.onChangeProtectDocument();
if (me.view) {
me.lockToolbar(Common.enumLock.hideComments, !Common.localStorage.getBool(me.view.appPrefix + "settings-livecomment", true), {array: [me.view.btnCommentRemove, me.view.btnCommentResolve]});
me.lockToolbar(Common.enumLock['Objects'], !!me._state.wsProps['Objects'], {array: [me.view.btnCommentRemove, me.view.btnCommentResolve]});
@ -1026,32 +1032,32 @@ define([
this.lockToolbar(Common.enumLock['Objects'], !!this._state.wsProps['Objects'], {array: [this.view.btnCommentRemove, this.view.btnCommentResolve]});
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection) {
this.lockToolbar(Common.enumLock.docLockView, docProtection.isReadOnly);
this.lockToolbar(Common.enumLock.docLockForms, docProtection.isFormsOnly);
this.lockToolbar(Common.enumLock.docLockReview, docProtection.isReviewOnly);
this.lockToolbar(Common.enumLock.docLockComments, docProtection.isCommentsOnly);
if (props) {
this._state.docProtection = props;
this.lockToolbar(Common.enumLock.docLockView, props.isReadOnly);
this.lockToolbar(Common.enumLock.docLockForms, props.isFormsOnly);
this.lockToolbar(Common.enumLock.docLockReview, props.isReviewOnly);
this.lockToolbar(Common.enumLock.docLockComments, props.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]});
Common.Utils.lockControls(Common.enumLock.docLockView, props.isReadOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
Common.Utils.lockControls(Common.enumLock.docLockForms, props.isFormsOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
Common.Utils.lockControls(Common.enumLock.docLockReview, props.isReviewOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
Common.Utils.lockControls(Common.enumLock.docLockComments, props.isCommentsOnly, {array: [this.dlgChanges.btnAccept, this.dlgChanges.btnReject]});
}
if (this.appConfig.canReview) {
if (docProtection.isReviewOnly) {
if (props.isReviewOnly) {
this.onTurnPreview(true);
this.onApiShowChange();
} else if (this._state.prevReviewProtected) {
this.onTurnPreview(false);
this.onApiShowChange();
}
this._state.prevReviewProtected = docProtection.isReviewOnly;
this._state.prevReviewProtected = props.isReviewOnly;
}
this.updatePreviewMode();
}

View file

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

View file

@ -1096,19 +1096,3 @@ Common.Utils.getKeyByValue = function(obj, value) {
}
}
};
Common.Utils.Store = new(function() {
var settings = {};
var _get = function(name, defValue) {
return (settings[name]!==undefined) ? settings[name] : defValue;
},
_set = function(name, value) {
settings[name] = value;
};
return {
get: _get,
set: _set
}
});

View file

@ -238,6 +238,10 @@ define([
me.fireEvent('comment:resolveComments', [item.value]);
});
}
Common.NotificationCenter.on('protect:doclock', function (e) {
me.fireEvent('protect:update');
});
me.fireEvent('protect:update');
}
return {
@ -691,7 +695,6 @@ define([
me.$el.find(separator_last).hide();
Common.NotificationCenter.trigger('tab:visible', 'review', (config.isEdit || config.canViewReview || config.canCoAuthoring && config.canComments) && Common.UI.LayoutManager.isElementVisible('toolbar-collaboration'));
setEvents.call(me);
});
},
@ -971,6 +974,7 @@ define([
this.options.tpl = _.template(this.template)(this.options);
this.popoverChanges = this.options.popoverChanges;
this.mode = this.options.mode;
this.docProtection = this.options.docProtection;
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
@ -1002,7 +1006,7 @@ define([
cls : 'btn-toolbar',
caption : this.txtAccept,
split : true,
disabled : this.mode.isReviewOnly || Common.Utils.Store.get('docProtection', {}).isReviewOnly || !!Common.Utils.InternalSettings.get(this.appPrefix + "accept-reject-lock"),
disabled : this.mode.isReviewOnly || this.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: [
@ -1040,11 +1044,10 @@ 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.docLockView, this.docProtection.isReadOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockForms, this.docProtection.isFormsOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockReview, this.docProtection.isReviewOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockComments, this.docProtection.isCommentsOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.reviewChangelock, !!Common.Utils.InternalSettings.get(this.appPrefix + "accept-reject-lock"), {array: arr});
var me = this;

View file

@ -198,14 +198,13 @@ define([
// var isProtected = this.api.asc_isProtectedDocument();
var isProtected = this.view ? this.view.btnProtectDoc.isActive() : false; // test
this.view && this.view.btnProtectDoc.toggle(isProtected, true);
this.getDocProps(true);
Common.NotificationCenter.trigger('protect:doclock');
Common.NotificationCenter.trigger('protect:doclock', this.getDocProps(true));
},
getDocProps: function(update) {
if (!this.appConfig || !this.appConfig.isEdit && !this.appConfig.isRestrictedEdit) return;
if (update || !Common.Utils.Store.get('docProtection')) {
if (update || !this._state.docProtection) {
// var docProtected = !!this.api.asc_isProtectedDocument(),
// type;
//
@ -215,10 +214,10 @@ define([
// }
// test //////
// if (Common.Utils.InternalSettings.get('protect-test-type')===undefined) {
// this.view && this.view.btnProtectDoc.toggle(true, true);
// Common.Utils.InternalSettings.set('protect-test-type', Asc.c_oAscProtection.Comments);
// }
if (Common.Utils.InternalSettings.get('protect-test-type')===undefined) {
this.view && this.view.btnProtectDoc.toggle(true, true);
Common.Utils.InternalSettings.set('protect-test-type', Asc.c_oAscProtection.Forms);
}
var docProtected = this.view ? this.view.btnProtectDoc.isActive() : true,
type;
@ -226,14 +225,14 @@ define([
type = Common.Utils.InternalSettings.get('protect-test-type');
}
/////////////
Common.Utils.Store.set('docProtection', {
this._state.docProtection = {
isReadOnly: type===Asc.c_oAscProtection.View,
isCommentsOnly: type===Asc.c_oAscProtection.Comments,
isReviewOnly: type===Asc.c_oAscProtection.Review,
isFormsOnly: type===Asc.c_oAscProtection.Forms
});
};
}
return Common.Utils.Store.get('docProtection');
return this._state.docProtection;
}
}, DE.Controllers.DocProtection || {}));

View file

@ -187,6 +187,7 @@ define([
me.onDocumentHolderResize();
}
});
Common.NotificationCenter.on('protect:doclock', _.bind(me.onChangeProtectDocument, me));
},
setApi: function(o) {
@ -424,6 +425,8 @@ define([
view.menuParaTOCSettings.on('click', _.bind(me.onParaTOCSettings, me));
view.menuTableEquation.menu.on('item:click', _.bind(me.convertEquation, me));
view.menuParagraphEquation.menu.on('item:click', _.bind(me.convertEquation, me));
me.onChangeProtectDocument();
},
getView: function (name) {
@ -584,7 +587,7 @@ define([
showObjectMenu: function(event, docElement, eOpts){
var me = this;
if (me.api){
var docProtection = Common.Utils.Store.get('docProtection', {});
var docProtection = me.documentHolder._docProtection;
var obj = (me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly)) ?
me.fillMenuProps(me.api.getSelectedElements()) : me.fillViewMenuProps(me.api.getSelectedElements());
if (obj) me.showPopupMenu(obj.menu_to_show, obj.menu_props, event, docElement, eOpts);
@ -613,7 +616,7 @@ define([
var me = this,
currentMenu = me.documentHolder.currentMenu;
if (currentMenu && currentMenu.isVisible() && currentMenu !== me.documentHolder.hdrMenu){
var docProtection = Common.Utils.Store.get('docProtection', {});
var docProtection = me.documentHolder._docProtection;
var obj = (me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly)) ?
me.fillMenuProps(selectedElements) : me.fillViewMenuProps(selectedElements);
if (obj) {
@ -827,7 +830,7 @@ define([
onDialogAddHyperlink: function() {
var me = this;
var win, props, text;
var docProtection = Common.Utils.Store.get('docProtection', {});
var docProtection = me.documentHolder._docProtection;
if (me.api && me.mode.isEdit && !(me._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly) && !me.getApplication().getController('LeftMenu').leftMenu.menuFile.isVisible()){
var handlerDlg = function(dlg, result) {
if (result == 'ok') {
@ -1184,7 +1187,7 @@ define([
},
onDoubleClickOnChart: function(chart) {
var docProtection = Common.Utils.Store.get('docProtection', {});
var docProtection = this.documentHolder._docProtection;
if (this.mode.isEdit && !(this._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly)) {
var diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
if (diagramEditor && chart) {
@ -1196,7 +1199,7 @@ define([
},
onDoubleClickOnTableOleObject: function(chart) {
var docProtection = Common.Utils.Store.get('docProtection', {});
var docProtection = this.documentHolder._docProtection;
if (this.mode.isEdit && !(this._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly)) {
var oleEditor = this.getApplication().getController('Common.Controllers.ExternalOleEditor').getView('Common.Views.ExternalOleEditor');
if (oleEditor && chart) {
@ -1901,8 +1904,8 @@ define([
this.api.asc_ViewCertificate(datavalue); //certificate id
break;
case 2:
var docProtection = Common.Utils.Store.get('docProtection', {});
Common.NotificationCenter.trigger('protect:signature', 'visible', this._isDisabled || !!docProtection.isReadOnly || !!docProtection.isFormsOnly || !!docProtection.isCommentsOnly, datavalue);//guid, can edit settings for requested signature
var docProtection = this.documentHolder._docProtection;
Common.NotificationCenter.trigger('protect:signature', 'visible', this._isDisabled || docProtection.isReadOnly || docProtection.isFormsOnly || docProtection.isCommentsOnly, datavalue);//guid, can edit settings for requested signature
break;
case 3:
var me = this;
@ -2315,6 +2318,16 @@ define([
}
},
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (props && this.documentHolder) {
this.documentHolder._docProtection = props;
}
},
editComplete: function() {
this.documentHolder && this.documentHolder.fireEvent('editcomplete', this.documentHolder);
}

View file

@ -434,18 +434,20 @@ define([
}
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection && this.view) {
var arr = this.view.getButtons();
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});
if (props) {
this._state.docProtection = props;
if (this.view) {
var arr = this.view.getButtons();
Common.Utils.lockControls(Common.enumLock.docLockView, props.isReadOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockForms, props.isFormsOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockReview, props.isReviewOnly, {array: arr});
Common.Utils.lockControls(Common.enumLock.docLockComments, props.isCommentsOnly, {array: arr});
}
}
}

View file

@ -119,7 +119,15 @@ define([
onLaunch: function() {
this.leftMenu = this.createView('LeftMenu').render();
this.leftMenu.btnSearchBar.on('toggle', _.bind(this.onMenuSearchBar, this));
this._state = {disableEditing: false};
this._state = {
disableEditing: false,
docProtection: {
isReadOnly: false,
isReviewOnly: false,
isFormsOnly: false,
isCommentsOnly: false
}
};
Common.util.Shortcuts.delegateShortcuts({
shortcuts: {
'command+shift+s,ctrl+shift+s': _.bind(this.onShortcut, this, 'save'),
@ -587,8 +595,7 @@ define([
},
updatePreviewMode: function() {
var docProtection = Common.Utils.Store.get('docProtection', {});
var viewmode = this._state.disableEditing || !!docProtection.isReadOnly || !!docProtection.isFormsOnly;
var viewmode = this._state.disableEditing || this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly;
if (this.viewmode === viewmode) return;
this.viewmode = viewmode;
@ -895,14 +902,15 @@ define([
return this.leftMenu && this.leftMenu.panelComments && this.leftMenu.panelComments.isVisible();
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection)
if (props) {
this._state.docProtection = props;
this.updatePreviewMode();
}
},
textNoTextFound : 'Text not found',

View file

@ -574,17 +574,17 @@ define([
})).show();
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection) {
this.lockToolbar(Common.enumLock.docLockView, docProtection.isReadOnly);
this.lockToolbar(Common.enumLock.docLockForms, docProtection.isFormsOnly);
this.lockToolbar(Common.enumLock.docLockReview, docProtection.isReviewOnly);
this.lockToolbar(Common.enumLock.docLockComments, docProtection.isCommentsOnly);
if (props) {
this._state.docProtection = props;
this.lockToolbar(Common.enumLock.docLockView, props.isReadOnly);
this.lockToolbar(Common.enumLock.docLockForms, props.isFormsOnly);
this.lockToolbar(Common.enumLock.docLockReview, props.isReviewOnly);
this.lockToolbar(Common.enumLock.docLockComments, props.isCommentsOnly);
}
},

View file

@ -54,7 +54,14 @@ define([
initialize: function() {
this.editMode = true;
this._initSettings = true;
this._state = {};
this._state = {
docProtection: {
isReadOnly: false,
isReviewOnly: false,
isFormsOnly: false,
isCommentsOnly: false
}
};
this.addListeners({
'RightMenu': {
'rightmenuclick': this.onRightMenuClick
@ -158,8 +165,7 @@ define([
var isChart = false,
isSmartArtInternal = false,
docProtection = Common.Utils.Store.get('docProtection', {}),
isProtected = !!docProtection.isReadOnly || !!docProtection.isFormsOnly || !!docProtection.isCommentsOnly;
isProtected = this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly || this._state.docProtection.isCommentsOnly;
var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null,
control_lock = false;
@ -472,16 +478,18 @@ define([
}
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection && this.api) {
var selectedElements = this.api.getSelectedElements();
if (selectedElements.length > 0)
this.onFocusObject(selectedElements);
if (props) {
this._state.docProtection = props;
if (this.api) {
var selectedElements = this.api.getSelectedElements();
if (selectedElements.length > 0)
this.onFocusObject(selectedElements);
}
}
}
});

View file

@ -3333,17 +3333,17 @@ define([
})).show();
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = this.getApplication().getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = this.getApplication().getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection) {
this.toolbar.lockToolbar(Common.enumLock.docLockView, docProtection.isReadOnly);
this.toolbar.lockToolbar(Common.enumLock.docLockForms, docProtection.isFormsOnly);
this.toolbar.lockToolbar(Common.enumLock.docLockReview, docProtection.isReviewOnly);
this.toolbar.lockToolbar(Common.enumLock.docLockComments, docProtection.isCommentsOnly);
if (props) {
this._state.docProtection = props;
this.toolbar.lockToolbar(Common.enumLock.docLockView, props.isReadOnly);
this.toolbar.lockToolbar(Common.enumLock.docLockForms, props.isFormsOnly);
this.toolbar.lockToolbar(Common.enumLock.docLockReview, props.isReviewOnly);
this.toolbar.lockToolbar(Common.enumLock.docLockComments, props.isCommentsOnly);
}
},

View file

@ -76,6 +76,12 @@ define([
this._currentParaObjDisabled = false;
this._currLang = {};
this._isDisabled = false;
this._docProtection = {
isReadOnly: false,
isReviewOnly: false,
isFormsOnly: false,
isCommentsOnly: false
};
},
render: function () {
@ -152,7 +158,6 @@ define([
signGuid = (value.imgProps && value.imgProps.value && me.mode.isSignatureSupport) ? value.imgProps.value.asc_getSignatureId() : undefined,
signProps = (signGuid) ? me.api.asc_getSignatureSetup(signGuid) : null,
isInSign = !!signProps && me._canProtect,
docProtection = Common.Utils.Store.get('docProtection', {}),
control_lock = (value.paraProps) ? (!value.paraProps.value.can_DeleteBlockContentControl() || !value.paraProps.value.can_EditBlockContentControl() ||
!value.paraProps.value.can_DeleteInlineContentControl() || !value.paraProps.value.can_EditInlineContentControl()) : false,
canComment = !isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled && !control_lock,
@ -170,7 +175,7 @@ define([
}
me.menuViewUndo.setVisible(me.mode.canCoAuthoring && me.mode.canComments && !me._isDisabled);
me.menuViewUndo.setDisabled(!me.api.asc_getCanUndo() || !!docProtection.isReadOnly);
me.menuViewUndo.setDisabled(!me.api.asc_getCanUndo() || me._docProtection.isReadOnly);
me.menuViewCopySeparator.setVisible(isInSign);
var isRequested = (signProps) ? signProps.asc_getRequested() : false;
@ -188,15 +193,15 @@ define([
}
me.menuViewAddComment.setVisible(canComment);
me.menuViewAddComment.setDisabled(value.paraProps && value.paraProps.locked === true || !!docProtection.isReadOnly || !!docProtection.isFormsOnly);
me.menuViewAddComment.setDisabled(value.paraProps && value.paraProps.locked === true || me._docProtection.isReadOnly || me._docProtection.isFormsOnly);
var disabled = value.paraProps && value.paraProps.locked === true;
var cancopy = me.api && me.api.can_CopyCut();
me.menuViewCopy.setDisabled(!cancopy);
me.menuViewCut.setVisible(me._fillFormMode && canEditControl);
me.menuViewCut.setDisabled(disabled || !cancopy || !!docProtection.isReadOnly || !!docProtection.isCommentsOnly);
me.menuViewCut.setDisabled(disabled || !cancopy || me._docProtection.isReadOnly || me._docProtection.isCommentsOnly);
me.menuViewPaste.setVisible(me._fillFormMode && canEditControl);
me.menuViewPaste.setDisabled(disabled || !!docProtection.isReadOnly || !!docProtection.isCommentsOnly);
me.menuViewPaste.setDisabled(disabled || me._docProtection.isReadOnly || me._docProtection.isCommentsOnly);
me.menuViewPrint.setVisible(me.mode.canPrint && !me._fillFormMode);
me.menuViewPrint.setDisabled(!cancopy);

View file

@ -178,7 +178,14 @@ define([
_.extend(this, options);
this.pages = new DE.Models.Pages({current:1, count:1});
this.pages.on('change', _.bind(_updatePagesCaption,this));
this._state = {};
this._state = {
docProtection: {
isReadOnly: false,
isReviewOnly: false,
isFormsOnly: false,
isCommentsOnly: false
}
};
this._isDisabled = false;
var me = this;
@ -371,7 +378,8 @@ define([
});
this.langMenu.resetItems(arr);
if (this.langMenu.items.length>0) {
this.btnLanguage.setDisabled(!!this.mode.isDisconnected);
var isProtected = this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly || this._state.docProtection.isCommentsOnly;
this.btnLanguage.setDisabled(this._isDisabled || !!this.mode.isDisconnected || isProtected);
}
},
@ -404,20 +412,20 @@ define([
SetDisabled: function(disable) {
this._isDisabled = disable;
var docProtection = Common.Utils.Store.get('docProtection', {}),
isProtected = !!docProtection.isReadOnly || !!docProtection.isFormsOnly || !!docProtection.isCommentsOnly
var isProtected = this._state.docProtection.isReadOnly || this._state.docProtection.isFormsOnly || this._state.docProtection.isCommentsOnly;
this.btnLanguage.setDisabled(disable || this.langMenu.items.length<1 || isProtected);
this.btnTurnReview && this.btnTurnReview.setDisabled(disable || isProtected);
},
onChangeProtectDocument: function() {
var docProtection = Common.Utils.Store.get('docProtection');
if (!docProtection) {
var cntrl = DE.getController('DocProtection');
docProtection = cntrl ? cntrl.getDocProps() : null;
onChangeProtectDocument: function(props) {
if (!props) {
var docprotect = DE.getController('DocProtection');
props = docprotect ? docprotect.getDocProps() : null;
}
if (docProtection)
if (props) {
this._state.docProtection = props;
this.SetDisabled(this._isDisabled);
}
},
onApiCoAuthoringDisconnect: function() {