[DE] Show warning when document has been protected by another user

This commit is contained in:
Julia Radzhabova 2022-12-08 16:48:43 +03:00
parent d9ef7a349f
commit d2b89c0737
3 changed files with 35 additions and 2 deletions

View file

@ -86,6 +86,7 @@ define([
this.setApi(api);
},
setApi: function (api) {
this.userCollection = this.getApplication().getCollection('Common.Collections.Users');
if (api) {
this.api = api;
this.api.asc_registerCallback('asc_onChangeDocumentProtection',_.bind(this.onChangeProtectDocument, this));
@ -95,6 +96,7 @@ define([
setMode: function(mode) {
this.appConfig = mode;
this.currentUserId = mode.user.id;
this.appConfig.isEdit && (this.view = this.createView('DocProtection', {
mode: mode
@ -183,7 +185,7 @@ define([
});
},
onChangeProtectDocument: function() {
onChangeProtectDocument: function(userId) {
var props = this.getDocProps(true),
isProtected = props && (props.isReadOnly || props.isCommentsOnly || props.isFormsOnly || props.isReviewOnly);
this.view && this.view.btnProtectDoc.toggle(isProtected, true);
@ -204,6 +206,27 @@ define([
if (this._docProtectDlg && this._docProtectDlg.isVisible())
this._docProtectDlg.SetDisabled(!!this._state.lockDocProtect || isProtected);
Common.NotificationCenter.trigger('protect:doclock', props);
if (userId && this.userCollection) {
var recUser = this.userCollection.findOriginalUser(userId);
if (recUser && (recUser.get('idOriginal') !== this.currentUserId)) {
var str = this.view.txtWasUnprotected;
switch (this._state.docProtection.type) {
case Asc.c_oAscEDocProtect.ReadOnly:
str = this.view.txtWasProtectedView;
break;
case Asc.c_oAscEDocProtect.Comments:
str = this.view.txtWasProtectedComment;
break;
case Asc.c_oAscEDocProtect.Forms:
str = this.view.txtWasProtectedForms;
break;
case Asc.c_oAscEDocProtect.TrackedChanges:
str = this.view.txtWasProtectedTrack;
break;
}
str && Common.NotificationCenter.trigger('showmessage', {msg: str}, {timeout: 5000, hideCloseTip: true});
}
}
},
getDocProps: function(update) {

View file

@ -142,7 +142,12 @@ define([
txtDocProtectedForms: 'Document is protected.<br>You may only fill in forms in this document.',
hintProtectDoc: 'Protect document',
txtDocUnlockDescription: 'Enter a password to unprotect document',
txtUnlockTitle: 'Unprotect Document'
txtUnlockTitle: 'Unprotect Document',
txtWasProtectedView: 'Document has been protected by another user.\nYou may only view this document.',
txtWasProtectedTrack: 'Document has been protected by another user.\nYou may edit this document, but all changes will be tracked.',
txtWasProtectedComment: 'Document has been protected by another user.\nYou may only insert comments to this document.',
txtWasProtectedForms: 'Document has been protected by another user.\nYou may only fill in forms in this document.',
txtWasUnprotected: 'Document has been unprotected.'
}
}()), DE.Views.DocProtection || {}));
});

View file

@ -1634,6 +1634,11 @@
"DE.Views.DocProtection.txtDocUnlockDescription": "Enter a password to unprotect document",
"DE.Views.DocProtection.txtUnlockTitle": "Unprotect Document",
"DE.Views.DocProtection.txtProtectDoc": "Protect Document",
"DE.Views.DocProtection.txtWasProtectedView": "Document has been protected by another user.\nYou may only view this document.",
"DE.Views.DocProtection.txtWasProtectedTrack": "Document has been protected by another user.\nYou may edit this document, but all changes will be tracked.",
"DE.Views.DocProtection.txtWasProtectedComment": "Document has been protected by another user.\nYou may only insert comments to this document.",
"DE.Views.DocProtection.txtWasProtectedForms": "Document has been protected by another user.\nYou may only fill in forms in this document.",
"DE.Views.DocProtection.txtWasUnprotected": "Document has been unprotected.",
"DE.Views.DocumentHolder.aboveText": "Above",
"DE.Views.DocumentHolder.addCommentText": "Add comment",
"DE.Views.DocumentHolder.advancedDropCapText": "Drop Cap Settings",