From 86de3af082ba6c541d9a6cb10c4db0d14f6267e8 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Mon, 5 Sep 2022 15:56:39 +0300 Subject: add method for isNotAdmin --- src/components/_sila/Global/FormFile.vue | 5 ++++- src/components/_sila/Global/TableRowAction.vue | 7 ++++--- src/components/_sila/Global/TableToolbar.vue | 10 +++++++++- 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src/components') diff --git a/src/components/_sila/Global/FormFile.vue b/src/components/_sila/Global/FormFile.vue index 874b4ebd..4d79e987 100644 --- a/src/components/_sila/Global/FormFile.vue +++ b/src/components/_sila/Global/FormFile.vue @@ -28,7 +28,7 @@ 'btn-secondary': isSecondary, 'btn-primary': !isSecondary, }" - :disabled="$store.getters['authentication/role'] === 'ReadOnly'" + :disabled="isNotAdmin" @click="$bvModal.show(`modal-${id}`)" > {{ $t('global.fileUpload.browseText') }} @@ -86,6 +86,9 @@ export default { }; }, computed: { + isNotAdmin() { + return this.$store.getters['authentication/role'] === 'ReadOnly'; + }, isSecondary() { return this.variant === 'secondary'; }, diff --git a/src/components/_sila/Global/TableRowAction.vue b/src/components/_sila/Global/TableRowAction.vue index c18b4f20..9384538e 100644 --- a/src/components/_sila/Global/TableRowAction.vue +++ b/src/components/_sila/Global/TableRowAction.vue @@ -42,9 +42,7 @@ v-else-if="showButton" variant="link" :class="{ 'btn-icon-only': btnIconOnly }" - :disabled=" - !enabled || $store.getters['authentication/role'] === 'ReadOnly' - " + :disabled="!enabled || isNotAdmin" :title="btnIconOnly ? title : !title" @click="$emit('click-table-action', value)" > @@ -100,6 +98,9 @@ export default { }, }, computed: { + isNotAdmin() { + return this.$store.getters['authentication/role'] === 'ReadOnly'; + }, dataForExport() { return JSON.stringify(omit(this.rowData, 'actions')); }, diff --git a/src/components/_sila/Global/TableToolbar.vue b/src/components/_sila/Global/TableToolbar.vue index 53d004cf..4f1dfe63 100644 --- a/src/components/_sila/Global/TableToolbar.vue +++ b/src/components/_sila/Global/TableToolbar.vue @@ -13,7 +13,7 @@ :data-test-id="`table-button-${action.value}Selected`" variant="primary" class="d-block" - :disabled="$store.getters['authentication/role'] === 'ReadOnly'" + :disabled="isNotAdmin" @click="$emit('batch-action', action.value)" > {{ action.label }} @@ -57,6 +57,14 @@ export default { isToolbarActive: false, }; }, + computed: { + isNotAdmin() { + return ( + this.$store.getters['authentication/role'] === 'ReadOnly' || + this.$store.getters['authentication/role'] === 'Operator' + ); + }, + }, watch: { selectedItemsCount: function (selectedItemsCount) { if (selectedItemsCount > 0) { -- cgit v1.2.3