From f17b8d1c7687df90f832b2686226303bd38f9470 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 5 Feb 2021 13:51:37 +0300 Subject: [PATCH] Change review permissions: deprecate customization.reviewPermissions parameter. Use permissions.reviewGroup instead: list of groups, that current user can accept/reject. --- apps/api/documents/api.js | 3 ++- apps/common/main/lib/util/utils.js | 21 ++++++++++++------- .../main/app/controller/Main.js | 5 +++-- .../mobile/app/controller/Main.js | 5 +++-- .../main/app/controller/Main.js | 5 +++-- .../mobile/app/controller/Main.js | 5 +++-- .../main/app/controller/Main.js | 5 +++-- .../mobile/app/controller/Main.js | 5 +++-- 8 files changed, 33 insertions(+), 21 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 58173633d..e0d4e1b90 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -49,7 +49,8 @@ fillForms: // default = edit || review, copy: // default = true, editCommentAuthorOnly: // default = false - deleteCommentAuthorOnly: // default = false + deleteCommentAuthorOnly: // default = false, + reviewGroup: ["Group1", ""] // current user can accept/reject review changes made by users from Group1 and users without a group. [] - use groups, but can't change any group's changes } }, editorConfig: { diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js index 81c4755f2..9ad6bb999 100644 --- a/apps/common/main/lib/util/utils.js +++ b/apps/common/main/lib/util/utils.js @@ -972,7 +972,8 @@ Common.Utils.UserInfoParser = new(function() { separator = String.fromCharCode(160), username = '', usergroups, - permissions; + reviewPermissions, + reviewGroups; return { setParser: function(value) { parse = !!value; @@ -1002,23 +1003,27 @@ Common.Utils.UserInfoParser = new(function() { setCurrentName: function(name) { username = name; - this.setReviewPermissions(permissions); + this.setReviewPermissions(reviewGroups, reviewPermissions); }, getCurrentName: function() { return username; }, - setReviewPermissions: function(reviewPermissions) { - if (reviewPermissions) { + setReviewPermissions: function(groups, permissions) { + if (groups) { + if (typeof groups == 'object' && groups.length>0) + usergroups = groups; + reviewGroups = groups; + } else if (permissions) { var arr = [], - groups = this.getParsedGroups(username); - groups && groups.forEach(function(group) { - var item = reviewPermissions[group.trim()]; + arrgroups = this.getParsedGroups(username); + arrgroups && arrgroups.forEach(function(group) { + var item = permissions[group.trim()]; item && (arr = arr.concat(item)); }); usergroups = arr; - permissions = reviewPermissions; + reviewPermissions = permissions; } }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 748c97bad..5ba5f335a 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1319,10 +1319,11 @@ define([ this.appOptions.canFavorite = this.document.info && (this.document.info.favorite!==undefined && this.document.info.favorite!==null) && !this.appOptions.isOffline; this.appOptions.canFavorite && appHeader.setFavorite(this.document.info.favorite); - this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); + this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && (!!this.permissions.reviewGroup || + this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object')); Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); - this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); + this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.permissions.reviewGroup, this.editorConfig.customization.reviewPermissions); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(Common.Utils.UserInfoParser.getCurrentName())); this.appOptions.canRename && appHeader.setCanRename(true); diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index c474fa7d9..2e35aca21 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -837,10 +837,11 @@ define([ me.appOptions.canUseHistory = me.appOptions.canReview = me.appOptions.isReviewOnly = false; } - me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object'); + me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && (!!me.permissions.reviewGroup || + me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object')); Common.Utils.UserInfoParser.setParser(me.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(me.appOptions.user.fullname); - me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); + me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.permissions.reviewGroup, me.editorConfig.customization.reviewPermissions); me.applyModeCommonElements(); me.applyModeEditorElements(); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 172de55ea..db3d44ef0 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1025,10 +1025,11 @@ define([ this.appOptions.canFavorite = this.document.info && (this.document.info.favorite!==undefined && this.document.info.favorite!==null) && !this.appOptions.isOffline; this.appOptions.canFavorite && appHeader.setFavorite(this.document.info.favorite); - this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); + this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && (!!this.permissions.reviewGroup || + this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object')); Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); - this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); + this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.permissions.reviewGroup, this.editorConfig.customization.reviewPermissions); appHeader.setUserName(Common.Utils.UserInfoParser.getParsedName(Common.Utils.UserInfoParser.getCurrentName())); this.appOptions.canRename && appHeader.setCanRename(true); diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 7af7b96d9..12d1f9fa6 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -755,10 +755,11 @@ define([ me.appOptions.canBranding = params.asc_getCustomization(); me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object'); - me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object'); + me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && (!!me.permissions.reviewGroup || + me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object')); Common.Utils.UserInfoParser.setParser(me.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(me.appOptions.user.fullname); - me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.editorConfig.customization.reviewPermissions); + me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.permissions.reviewGroup, me.editorConfig.customization.reviewPermissions); me.applyModeCommonElements(); me.applyModeEditorElements(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 2dec09bb3..84ea8a49d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1070,10 +1070,11 @@ define([ this.appOptions.canFavorite && this.headerView && this.headerView.setFavorite(this.appOptions.spreadsheet.info.favorite); this.appOptions.canRename && this.headerView.setCanRename(true); - this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object'); + this.appOptions.canUseReviewPermissions = this.appOptions.canLicense && (!!this.permissions.reviewGroup || + this.appOptions.canLicense && this.editorConfig.customization && this.editorConfig.customization.reviewPermissions && (typeof (this.editorConfig.customization.reviewPermissions) == 'object')); Common.Utils.UserInfoParser.setParser(this.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(this.appOptions.user.fullname); - this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.editorConfig.customization.reviewPermissions); + this.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(this.permissions.reviewGroup, this.editorConfig.customization.reviewPermissions); this.headerView.setUserName(Common.Utils.UserInfoParser.getParsedName(Common.Utils.UserInfoParser.getCurrentName())); } else this.appOptions.canModifyFilter = true; diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 22cd1b7f7..2a082c04f 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -766,10 +766,11 @@ define([ me.appOptions.canBranding = params.asc_getCustomization(); me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object'); - me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object'); + me.appOptions.canUseReviewPermissions = me.appOptions.canLicense && (!!me.permissions.reviewGroup || + me.editorConfig.customization && me.editorConfig.customization.reviewPermissions && (typeof (me.editorConfig.customization.reviewPermissions) == 'object')); Common.Utils.UserInfoParser.setParser(me.appOptions.canUseReviewPermissions); Common.Utils.UserInfoParser.setCurrentName(me.appOptions.user.fullname); - me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.editorConfig.customization.reviewPermissions); + me.appOptions.canUseReviewPermissions && Common.Utils.UserInfoParser.setReviewPermissions(me.permissions.reviewGroup, me.editorConfig.customization.reviewPermissions); } me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;