From f7bb67ed677d622cf9ca9fe993bc6e3cee7f24a9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 15 Dec 2022 00:33:57 +0300 Subject: [PATCH] [DE] Show warning on opening protected document --- .../main/app/controller/DocProtection.js | 47 +++++++++++++++++-- apps/documenteditor/main/locale/en.json | 4 ++ apps/documenteditor/main/locale/ru.json | 4 ++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/apps/documenteditor/main/app/controller/DocProtection.js b/apps/documenteditor/main/app/controller/DocProtection.js index bd5be8645..113b949fb 100644 --- a/apps/documenteditor/main/app/controller/DocProtection.js +++ b/apps/documenteditor/main/app/controller/DocProtection.js @@ -170,8 +170,8 @@ define([ }, onAppReady: function (config) { - if (!this.view) return; - + if (!this.api) return; + var me = this; (new Promise(function (resolve) { resolve(); @@ -180,12 +180,47 @@ define([ type = props ? props.asc_getEditType() : Asc.c_oAscEDocProtect.None, isProtected = (type === Asc.c_oAscEDocProtect.ReadOnly || type === Asc.c_oAscEDocProtect.Comments || type === Asc.c_oAscEDocProtect.TrackedChanges || type === Asc.c_oAscEDocProtect.Forms); - me.view.btnProtectDoc.toggle(!!isProtected, true); + me.view && me.view.btnProtectDoc.toggle(!!isProtected, true); + + if (isProtected) { + var str; + switch (type) { + case Asc.c_oAscEDocProtect.ReadOnly: + str = me.txtIsProtectedView; + break; + case Asc.c_oAscEDocProtect.Comments: + str = me.txtIsProtectedComment; + break; + case Asc.c_oAscEDocProtect.Forms: + str = me.txtIsProtectedForms; + break; + case Asc.c_oAscEDocProtect.TrackedChanges: + str = me.txtIsProtectedTrack; + break; + } + me._protectionTip = new Common.UI.SynchronizeTip({ + extCls: 'no-arrow', + placement: 'bottom', + target: $('.toolbar'), + text: str, + showLink: false, + style: 'max-width: 400px;' + }); + me._protectionTip.on('closeclick', function () { + this.close(); + }).show(); + } + props && me.applyRestrictions(type); }); }, onChangeProtectDocument: function(userId) { + if (this._protectionTip && this._protectionTip.isVisible()) { + this._protectionTip.close(); + this._protectionTip = undefined; + } + var props = this.getDocProps(true), isProtected = props && (props.isReadOnly || props.isCommentsOnly || props.isFormsOnly || props.isReviewOnly); this.view && this.view.btnProtectDoc.toggle(isProtected, true); @@ -275,7 +310,11 @@ define([ 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.' + txtWasUnprotected: 'Document has been unprotected.', + txtIsProtectedView: 'Document is protected. You may only view this document.', + txtIsProtectedTrack: 'Document is protected. You may edit this document, but all changes will be tracked.', + txtIsProtectedComment: 'Document is protected. You may only insert comments to this document.', + txtIsProtectedForms: 'Document is protected. You may only fill in forms in this document.' }, DE.Controllers.DocProtection || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 8bd663e4f..6894860a1 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1644,6 +1644,10 @@ "DE.Controllers.DocProtection.txtWasProtectedTrack": "Document has been protected by another user.\nYou may edit this document, but all changes will be tracked.", "DE.Controllers.DocProtection.txtWasProtectedView": "Document has been protected by another user.\nYou may only view this document.", "DE.Controllers.DocProtection.txtWasUnprotected": "Document has been unprotected.", + "DE.Controllers.DocProtection.txtIsProtectedView": "Document is protected. You may only view this document.", + "DE.Controllers.DocProtection.txtIsProtectedTrack": "Document is protected. You may edit this document, but all changes will be tracked.", + "DE.Controllers.DocProtection.txtIsProtectedComment": "Document is protected. You may only insert comments to this document.", + "DE.Controllers.DocProtection.txtIsProtectedForms": "Document is protected. You may only fill in forms in this document.", "DE.Views.DocumentHolder.aboveText": "Above", "DE.Views.DocumentHolder.addCommentText": "Add comment", "DE.Views.DocumentHolder.advancedDropCapText": "Drop Cap Settings", diff --git a/apps/documenteditor/main/locale/ru.json b/apps/documenteditor/main/locale/ru.json index 527126ad4..bfe8644f8 100644 --- a/apps/documenteditor/main/locale/ru.json +++ b/apps/documenteditor/main/locale/ru.json @@ -1639,6 +1639,10 @@ "DE.Controllers.DocProtection.txtWasProtectedTrack": "Документ защищен другим пользователем.\nВы можете редактировать этот документ, но все изменения будут отслеживаться.", "DE.Controllers.DocProtection.txtWasProtectedView": "Документ защищен другим пользователем.\nВы можете только просматривать этот документ.", "DE.Controllers.DocProtection.txtWasUnprotected": "Защита документа снята.", + "DE.Controllers.DocProtection.txtIsProtectedView": "Документ защищен. Вы можете только просматривать этот документ.", + "DE.Controllers.DocProtection.txtIsProtectedTrack": "Документ защищен. Вы можете редактировать этот документ, но все изменения будут отслеживаться.", + "DE.Controllers.DocProtection.txtIsProtectedComment": "Документ защищен. Вы можете только добавлять комментарии к этому документу.", + "DE.Controllers.DocProtection.txtIsProtectedForms": "Документ защищен. Вы можете только заполнять формы в этом документе.", "DE.Views.DocumentHolder.aboveText": "Выше", "DE.Views.DocumentHolder.addCommentText": "Добавить комментарий", "DE.Views.DocumentHolder.advancedDropCapText": "Параметры буквицы",