From 625ee91bc0ec8b08b435b5e65ddbde086e6e366c Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 25 Jul 2022 11:50:26 +0300 Subject: [PATCH] role ui fix --- client/src/views/portal-role/record/detail.js | 3 +- client/src/views/portal-role/record/edit.js | 7 ++-- client/src/views/portal-role/record/table.js | 35 +++++++++++++------ client/src/views/role/record/table.js | 6 +++- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/client/src/views/portal-role/record/detail.js b/client/src/views/portal-role/record/detail.js index 691a7b6f11..5380770172 100644 --- a/client/src/views/portal-role/record/detail.js +++ b/client/src/views/portal-role/record/detail.js @@ -26,13 +26,12 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/portal-role/record/detail', 'views/role/record/detail', function (Dep) { +define('views/portal-role/record/detail', ['views/role/record/detail'], function (Dep) { return Dep.extend({ tableView: 'views/portal-role/record/table', stickButtonsContainerAllTheWay: true, - }); }); diff --git a/client/src/views/portal-role/record/edit.js b/client/src/views/portal-role/record/edit.js index 1579779c39..53a556c521 100644 --- a/client/src/views/portal-role/record/edit.js +++ b/client/src/views/portal-role/record/edit.js @@ -26,13 +26,12 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/portal-role/record/edit', 'views/role/record/edit', function (Dep) { +define('views/portal-role/record/edit', ['views/role/record/edit'], function (Dep) { return Dep.extend({ - tableView: 'views/portal-role/record/table', - - stickButtonsContainerAllTheWay: true, + tableView: 'views/portal-role/record/table', + stickButtonsContainerAllTheWay: true, }); }); diff --git a/client/src/views/portal-role/record/table.js b/client/src/views/portal-role/record/table.js index c788e77e0e..0860512f15 100644 --- a/client/src/views/portal-role/record/table.js +++ b/client/src/views/portal-role/record/table.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/portal-role/record/table', 'views/role/record/table', function (Dep) { +define('views/portal-role/record/table', ['views/role/record/table'], function (Dep) { return Dep.extend({ @@ -42,7 +42,13 @@ define('views/portal-role/record/table', 'views/role/record/table', function (De 'record': ['all', 'own', 'no'] }, - levelList: ['all', 'account', 'contact', 'own', 'no'], + levelList: [ + 'all', + 'account', + 'contact', + 'own', + 'no', + ], type: 'aclPortal', @@ -52,22 +58,31 @@ define('views/portal-role/record/table', 'views/role/record/table', function (De this.aclTypeMap = {}; this.scopeList = []; - var scopeListAll = Object.keys(this.getMetadata().get('scopes')).sort(function (v1, v2) { - return this.translate(v1, 'scopeNamesPlural').localeCompare(this.translate(v2, 'scopeNamesPlural')); - }.bind(this)); + var scopeListAll = Object.keys(this.getMetadata().get('scopes')) + .sort((v1, v2) => { + return this.translate(v1, 'scopeNamesPlural') + .localeCompare(this.translate(v2, 'scopeNamesPlural')); + }); + + scopeListAll.forEach(scope => { + if ( + this.getMetadata().get('scopes.' + scope + '.disabled') || + this.getMetadata().get('scopes.' + scope + '.disabledPortal') + ) { + return; + } - scopeListAll.forEach(function (scope) { - if (this.getMetadata().get('scopes.' + scope + '.disabled') || this.getMetadata().get('scopes.' + scope + '.disabledPortal')) return; var acl = this.getMetadata().get('scopes.' + scope + '.aclPortal'); + if (acl) { this.scopeList.push(scope); this.aclTypeMap[scope] = acl; + if (acl === true) { this.aclTypeMap[scope] = 'record'; } } - }, this); - } - + }); + }, }); }); diff --git a/client/src/views/role/record/table.js b/client/src/views/role/record/table.js index 0a933a6a25..562027f9b9 100644 --- a/client/src/views/role/record/table.js +++ b/client/src/views/role/record/table.js @@ -706,7 +706,11 @@ define('views/role/record/table', ['view'], function (Dep) { var screenWidthXs = this.getThemeManager().getParam('screenWidthXs'); var $buttonContainer = $('.detail-button-container'); - var $table = this.$el.find('table.'+type+'-level'); + var $table = this.$el.find('table.' + type + '-level'); + + if (!$table.length) { + return; + } if (!$buttonContainer.length) { return;