From 351c2a07dc85a553a976fa37928cc57d4fd631a8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 1 Aug 2024 09:15:35 +0200 Subject: [PATCH 01/23] chore: refs #4074 wip replace useRole for useAcl --- src/components/ui/VnPaginate.vue | 4 ++-- src/pages/Account/AccountList.vue | 4 ++-- src/pages/Customer/Card/CustomerBalance.vue | 6 +++--- src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue | 15 +++++++-------- src/pages/Worker/Card/WorkerLocker.vue | 6 +++--- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index c27111df4..42fa4f766 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -115,8 +115,8 @@ watch( ); watch( - () => [props.url, props.filter], - ([url, filter]) => fetch({ url, filter }) + () => [props.url, props.filter, props.userParams], + ([url, filter, userParams]) => fetch({ url, filter, userParams }) ); const addFilter = async (filter, params) => { diff --git a/src/pages/Account/AccountList.vue b/src/pages/Account/AccountList.vue index dee019fed..79c77a3c1 100644 --- a/src/pages/Account/AccountList.vue +++ b/src/pages/Account/AccountList.vue @@ -13,7 +13,7 @@ import AccountCreate from './AccountCreate.vue'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useStateStore } from 'stores/useStateStore'; -import { useRole } from 'src/composables/useRole'; +import { useAcl } from 'src/composables/useAcl'; import { QDialog } from 'quasar'; const stateStore = useStateStore(); @@ -21,7 +21,7 @@ const router = useRouter(); const { t } = useI18n(); const { viewSummary } = useSummaryDialog(); const accountCreateDialogRef = ref(null); -const showNewUserBtn = computed(() => useRole().hasAny(['itManagement'])); +const showNewUserBtn = computed(() => useAcl().hasAny('Account', '*', 'WRITE')); const filter = { fields: ['id', 'nickname', 'name', 'role'], diff --git a/src/pages/Customer/Card/CustomerBalance.vue b/src/pages/Customer/Card/CustomerBalance.vue index 411c44ad3..2dc0c5564 100644 --- a/src/pages/Customer/Card/CustomerBalance.vue +++ b/src/pages/Customer/Card/CustomerBalance.vue @@ -2,7 +2,7 @@ import { computed, onBeforeMount, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; -import { useRole } from 'src/composables/useRole'; +import { useAcl } from 'src/composables/useAcl'; import axios from 'axios'; import { useQuasar } from 'quasar'; @@ -25,7 +25,7 @@ import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescr const { openConfirmationModal } = useVnConfirm(); const { sendEmail } = usePrintService(); const { t } = useI18n(); -const { hasAny } = useRole(); +const { hasAny } = useAcl(); const session = useSession(); const tokenMultimedia = session.getTokenMultimedia(); @@ -317,7 +317,7 @@ const showBalancePdf = ({ id }) => { > diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue index da24e50fa..17e5133ab 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue @@ -5,7 +5,7 @@ import { useI18n } from 'vue-i18n'; import { useQuasar } from 'quasar'; import axios from 'axios'; import { toCurrency, toDate } from 'src/filters'; -import { useRole } from 'src/composables/useRole'; +import { useAcl } from 'src/composables/useAcl'; import { downloadFile } from 'src/composables/downloadFile'; import { useArrayData } from 'src/composables/useArrayData'; import { usePrintService } from 'composables/usePrintService'; @@ -24,7 +24,7 @@ const $props = defineProps({ id: { type: Number, default: null } }); const { push, currentRoute } = useRouter(); const quasar = useQuasar(); -const { hasAny } = useRole(); +const { hasAny } = useAcl(); const { t } = useI18n(); const { openReport, sendEmail } = usePrintService(); const arrayData = useArrayData(); @@ -195,10 +195,9 @@ async function cloneInvoice() { push({ path: `/invoice-in/${data.id}/summary` }); } -const isAdministrative = () => hasAny(['administrative']); +const canEditProp = (prop) => hasAny('InvoiceIn', prop, 'WRITE'); const isAgricultural = () => { - console.error(config); if (!config.value) return false; return ( invoiceIn.value?.supplier?.sageFarmerWithholdingFk === @@ -284,7 +283,7 @@ const createInvoiceInCorrection = async () => { { { {{ t('Delete invoice') }} { option-label="code" option-value="id" hide-selected - :readonly="!hasAny(['productionBoss', 'hr'])" + :readonly="!hasAny('Worker','__get__locker','READ')" /> From c766110bd90016c3de35ff3d1d33067b0247b940 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 1 Aug 2024 14:13:37 +0200 Subject: [PATCH 02/23] chore: refs #4074 wip replace useRole for useAcl --- src/components/common/VnSelectDialog.vue | 7 +++ src/pages/Item/Card/ItemSummary.vue | 55 ++++++++----------- src/pages/Supplier/Card/SupplierSummary.vue | 13 ++--- .../Travel/Card/TravelDescriptorMenuItems.vue | 9 +-- src/pages/Worker/Card/WorkerTimeControl.vue | 18 +++--- .../Worker/Card/WorkerTimeReasonForm.vue | 4 +- src/pages/Worker/WorkerList.vue | 2 +- 7 files changed, 52 insertions(+), 56 deletions(-) diff --git a/src/components/common/VnSelectDialog.vue b/src/components/common/VnSelectDialog.vue index 7f7c29f5d..6f2be4bfe 100644 --- a/src/components/common/VnSelectDialog.vue +++ b/src/components/common/VnSelectDialog.vue @@ -1,6 +1,7 @@