From 80a7765fdd9bbcb3835a9f183a9b36c01d808b4c Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sat, 27 Jan 2024 12:26:20 +0200 Subject: [PATCH] role permissions style --- .../metadata/entityDefs/PortalRole.json | 6 ++- .../Resources/metadata/entityDefs/Role.json | 27 ++++++---- client/res/templates/user/modals/access.tpl | 4 +- client/src/views/role/fields/permission.js | 49 +++++++++++++++++++ client/src/views/user/modals/access.js | 16 +++++- 5 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 client/src/views/role/fields/permission.js diff --git a/application/Espo/Resources/metadata/entityDefs/PortalRole.json b/application/Espo/Resources/metadata/entityDefs/PortalRole.json index 2a52df4c16..c1b7c2acae 100644 --- a/application/Espo/Resources/metadata/entityDefs/PortalRole.json +++ b/application/Espo/Resources/metadata/entityDefs/PortalRole.json @@ -17,14 +17,16 @@ "options": ["not-set", "yes", "no"], "default": "not-set", "tooltip": "Role.exportPermission", - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "massUpdatePermission": { "type": "enum", "options": ["not-set", "yes", "no"], "default": "not-set", "tooltip": "Role.massUpdatePermission", - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "createdAt": { "type": "datetime", diff --git a/application/Espo/Resources/metadata/entityDefs/Role.json b/application/Espo/Resources/metadata/entityDefs/Role.json index 466f35879d..b04076608b 100644 --- a/application/Espo/Resources/metadata/entityDefs/Role.json +++ b/application/Espo/Resources/metadata/entityDefs/Role.json @@ -11,63 +11,72 @@ "options": ["not-set", "all", "team", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "userPermission": { "type": "enum", "options": ["not-set", "all", "team", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "messagePermission": { "type": "enum", "options": ["not-set", "all", "team", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "portalPermission": { "type": "enum", "options": ["not-set", "yes", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "groupEmailAccountPermission": { "type": "enum", "options": ["not-set", "all", "team", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "exportPermission": { "type": "enum", "options": ["not-set", "yes", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "massUpdatePermission": { "type": "enum", "options": ["not-set", "yes", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "dataPrivacyPermission": { "type": "enum", "options": ["not-set", "yes", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "followerManagementPermission": { "type": "enum", "options": ["not-set", "all", "team", "no"], "default": "not-set", "tooltip": true, - "translation": "Role.options.levelList" + "translation": "Role.options.levelList", + "view": "views/role/fields/permission" }, "data": { "type": "jsonObject" diff --git a/client/res/templates/user/modals/access.tpl b/client/res/templates/user/modals/access.tpl index 619f00158e..66cbd4601f 100644 --- a/client/res/templates/user/modals/access.tpl +++ b/client/res/templates/user/modals/access.tpl @@ -5,7 +5,9 @@
- {{translateOption value scope="Role" field="assignmentPermission" translatedOptions=levelListTranslation}} + + {{translateOption value scope="Role" field="assignmentPermission" translatedOptions=levelListTranslation}} +
{{/each}} diff --git a/client/src/views/role/fields/permission.js b/client/src/views/role/fields/permission.js new file mode 100644 index 0000000000..abade024da --- /dev/null +++ b/client/src/views/role/fields/permission.js @@ -0,0 +1,49 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM – Open Source CRM application. + * Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko + * Website: https://www.espocrm.com + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU Affero General Public License version 3. + * + * In accordance with Section 7(b) of the GNU Affero General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +import EnumFieldView from 'views/fields/enum'; + +export default class extends EnumFieldView { + + setup() { + this.params.style = { + yes: 'success', + all: 'success', + account: 'info', + contact: 'info', + team: 'info', + own: 'warning', + no: 'danger', + enabled: 'success', + disabled: 'danger', + 'not-set': 'default', + } + + super.setup(); + } +} diff --git a/client/src/views/user/modals/access.js b/client/src/views/user/modals/access.js index 7d8ad26407..c5530bc777 100644 --- a/client/src/views/user/modals/access.js +++ b/client/src/views/user/modals/access.js @@ -35,10 +35,24 @@ define('views/user/modals/access', ['views/modal'], function (Dep) { template: 'user/modals/access', backdrop: true, + styleMap: { + yes: 'success', + all: 'success', + account: 'info', + contact: 'info', + team: 'info', + own: 'warning', + no: 'danger', + enabled: 'success', + disabled: 'danger', + 'not-set': 'default', + }, + data: function () { return { valuePermissionDataList: this.getValuePermissionList(), - levelListTranslation: this.getLanguage().get('Role', 'options', 'levelList') || {} + levelListTranslation: this.getLanguage().get('Role', 'options', 'levelList') || {}, + styleMap: this.styleMap, }; },