From 4188569908e57aee9b938e976b670779dd7fd733 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 25 Jul 2024 10:03:20 +0200 Subject: [PATCH 01/99] feat: refs #7500 added VnImg to show files --- src/components/common/VnDmsList.vue | 33 +++++++++++++++++++++-------- src/components/ui/VnImg.vue | 11 +++++++++- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index c42de6690..08c4e4aa4 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -5,12 +5,14 @@ import { useRoute } from 'vue-router'; import { useQuasar, QCheckbox, QBtn, QInput } from 'quasar'; import axios from 'axios'; +import VnUserLink from '../ui/VnUserLink.vue'; +import { downloadFile } from 'src/composables/downloadFile'; +import VnImg from 'components/ui/VnImg.vue'; import VnPaginate from 'components/ui/VnPaginate.vue'; import VnDms from 'src/components/common/VnDms.vue'; import VnConfirm from 'components/ui/VnConfirm.vue'; import VnInputDate from 'components/common/VnInputDate.vue'; -import VnUserLink from '../ui/VnUserLink.vue'; -import { downloadFile } from 'src/composables/downloadFile'; +import { useSession } from 'src/composables/useSession'; const route = useRoute(); const quasar = useQuasar(); @@ -18,6 +20,7 @@ const { t } = useI18n(); const rows = ref(); const dmsRef = ref(); const formDialog = ref({}); +const token = useSession().getTokenMultimedia(); const $props = defineProps({ model: { @@ -89,6 +92,25 @@ const dmsFilter = { }; const columns = computed(() => [ + { + align: 'left', + field: 'file', + label: t('globals.file'), + name: 'file', + component: VnImg, + props: (prop) => ({ + storage: 'dms', + collection: null, + size: null, + token: prop.token, + url: + 'api/dms/' + + prop.row.file.split('.')[0] + + '/downloadFile?access_token=' + + token, + class: 'rounded', + }), + }, { align: 'left', field: 'id', @@ -141,13 +163,6 @@ const columns = computed(() => [ 'model-value': Boolean(prop.value), }), }, - { - align: 'left', - field: 'file', - label: t('globals.file'), - name: 'file', - component: 'span', - }, { align: 'left', field: 'worker', diff --git a/src/components/ui/VnImg.vue b/src/components/ui/VnImg.vue index 985c9cc53..fc54bddf5 100644 --- a/src/components/ui/VnImg.vue +++ b/src/components/ui/VnImg.vue @@ -24,6 +24,11 @@ const $props = defineProps({ type: Number, required: true, }, + url: { + type: String, + required: false, + default: null, + }, }); const show = ref(false); const token = useSession().getTokenMultimedia(); @@ -31,9 +36,13 @@ const timeStamp = ref(`timestamp=${Date.now()}`); import noImage from '/no-user.png'; import { useRole } from 'src/composables/useRole'; const url = computed(() => { + if ($props.url) return $props.url; const isEmployee = useRole().isEmployee(); + const _url = [$props.storage, $props.collection, $props.size, $props.id] + .filter((prop) => prop) + .join('/'); return isEmployee - ? `/api/${$props.storage}/${$props.collection}/${$props.size}/${$props.id}/download?access_token=${token}&${timeStamp.value}` + ? `/api/${_url}/download?access_token=${token}&${timeStamp.value}` : noImage; }); const reload = () => { From 351c2a07dc85a553a976fa37928cc57d4fd631a8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 1 Aug 2024 09:15:35 +0200 Subject: [PATCH 02/99] 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 03/99] 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 @@