From 99111377256c413ed698521331be202286c2fad7 Mon Sep 17 00:00:00 2001 From: provira <provira@verdnatura.es> Date: Thu, 26 Dec 2024 10:25:22 +0100 Subject: [PATCH 1/2] refactor: refs #8322 changed ZoneList component to use VnSection/VnCardBeta --- src/pages/Zone/Card/ZoneCard.vue | 23 +--- src/pages/Zone/ZoneList.vue | 38 +++++-- src/pages/Zone/locale/en.yml | 2 +- src/router/modules/zone.js | 176 ++++++++++++++++--------------- 4 files changed, 121 insertions(+), 118 deletions(-) diff --git a/src/pages/Zone/Card/ZoneCard.vue b/src/pages/Zone/Card/ZoneCard.vue index a470cd5bd..da70a9374 100644 --- a/src/pages/Zone/Card/ZoneCard.vue +++ b/src/pages/Zone/Card/ZoneCard.vue @@ -1,13 +1,10 @@ <script setup> -import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import { computed } from 'vue'; -import VnCard from 'components/common/VnCard.vue'; +import VnCardBeta from 'src/components/common/VnCardBeta.vue'; import ZoneDescriptor from './ZoneDescriptor.vue'; -import ZoneFilterPanel from '../ZoneFilterPanel.vue'; -const { t } = useI18n(); const route = useRoute(); const routeName = computed(() => route.name); @@ -18,21 +15,5 @@ function notIsLocations(ifIsFalse, ifIsTrue) { </script> <template> - <VnCard - data-key="zone" - :base-url="notIsLocations('Zones', undefined)" - :descriptor="ZoneDescriptor" - :filter-panel="notIsLocations(ZoneFilterPanel, undefined)" - :search-data-key="notIsLocations('ZoneList', undefined)" - :searchbar-props="{ - url: notIsLocations('Zones', 'ZoneLocations'), - label: notIsLocations(t('list.searchZone'), t('list.searchLocation')), - info: t('list.searchInfo'), - whereFilter: notIsLocations((value) => { - return /^\d+$/.test(value) - ? { id: value } - : { name: { like: `%${value}%` } }; - }), - }" - /> + <VnCardBeta data-key="zone" base-url="Zones" :descriptor="ZoneDescriptor" /> </template> diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue index 2a5d290ef..dcd136383 100644 --- a/src/pages/Zone/ZoneList.vue +++ b/src/pages/Zone/ZoneList.vue @@ -14,9 +14,8 @@ import VnTable from 'src/components/VnTable/VnTable.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnInputTime from 'src/components/common/VnInputTime.vue'; -import RightMenu from 'src/components/common/RightMenu.vue'; import ZoneFilterPanel from './ZoneFilterPanel.vue'; -import ZoneSearchbar from './Card/ZoneSearchbar.vue'; +import VnSection from 'src/components/common/VnSection.vue'; const { t } = useI18n(); const router = useRouter(); @@ -25,6 +24,7 @@ const { viewSummary } = useSummaryDialog(); const { openConfirmationModal } = useVnConfirm(); const tableRef = ref(); const warehouseOptions = ref([]); +const dataKey = 'ZoneList'; const tableFilter = { include: [ @@ -132,26 +132,41 @@ const handleClone = (id) => { </script> <template> - <ZoneSearchbar /> - <RightMenu> - <template #right-panel> + <VnSection + :data-key="dataKey" + :columns="columns" + prefix="list" + :array-data-props="{ + url: 'Zones', + order: ['id'], + exprBuilder, + }" + > + <template #rightMenu> <ZoneFilterPanel data-key="ZonesList" /> </template> - </RightMenu> + <template #body> <VnTable ref="tableRef" - data-key="ZonesList" - url="Zones" + data-key="dataKey" :create="{ urlCreate: 'Zones', title: t('list.createZone'), onDataSaved: ({ id }) => tableRef.redirect(`${id}/location`), formInitialData: {}, }" - :user-filter="tableFilter" + default-mode="table" :columns="columns" - redirect="zone" + :user-filter="tableFilter" + :user-params="userParams" :right-search="false" + redirect="zone" + v-model:selected="selectedRows" + :table="{ + 'row-key': 'id', + slelection: 'multiple', + }" + data-cy="zoneListTable" > <template #more-create-dialog="{ data }"> <VnSelect @@ -196,8 +211,11 @@ const handleClone = (id) => { /> </template> </VnTable> + </template> +</VnSection> </template> + <i18n> es: Search zone: Buscar zona diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml index ba4982311..8fb5528d2 100644 --- a/src/pages/Zone/locale/en.yml +++ b/src/pages/Zone/locale/en.yml @@ -24,7 +24,7 @@ list: price: Price create: Create zone openSummary: Details - searchZone: Search zones + search: Search zones searchLocation: Search locations searchInfo: Search zone by id or name confirmCloneTitle: All it's properties will be copied diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index f400a708e..696408c76 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -1,24 +1,12 @@ import { RouterView } from 'vue-router'; -export default { - path: '/zone', +const zoneCard = { name: 'Zone', + path: '/zone', + component: () => import('src/pages/Zone/Card/ZoneCard.vue'), + redirect: { name: 'ZoneSummary' }, meta: { - title: 'zones', - icon: 'vn:zone', - moduleName: 'Zone', - keyBinding: 'z', - }, - component: RouterView, - redirect: { name: 'ZoneMain' }, - menus: { - main: [ - 'ZoneList', - 'ZoneDeliveryDays', - 'ZoneUpcomingList', - 'ZoneUpcomingDeliveries', - ], - card: [ + menu: [ 'ZoneBasicData', 'ZoneWarehouses', 'ZoneHistory', @@ -26,21 +14,99 @@ export default { 'ZoneEvents', ], }, + children: [ + { + name: 'ZoneSummary', + path: 'summary', + meta: { + title: 'summary', + icon: 'launch', + }, + component: () => import('src/pages/Zone/Card/ZoneSummary.vue'), + }, + { + name: 'ZoneBasicData', + path: 'basic-data', + meta: { + title: 'basicData', + icon: 'vn:settings', + }, + component: () => import('src/pages/Zone/Card/ZoneBasicData.vue'), + }, + { + name: 'ZoneLocations', + path: 'location', + meta: { + title: 'locations', + icon: 'my_location', + }, + component: () => import('src/pages/Zone/Card/ZoneLocations.vue'), + }, + { + name: 'ZoneWarehouses', + path: 'warehouses', + meta: { + title: 'warehouses', + icon: 'home', + }, + component: () => import('src/pages/Zone/Card/ZoneWarehouses.vue'), + }, + { + name: 'ZoneHistory', + path: 'log', + meta: { + title: 'log', + icon: 'history', + }, + component: () => import('src/pages/Zone/Card/ZoneLog.vue'), + }, + { + name: 'ZoneEvents', + path: 'events', + meta: { + title: 'calendar', + icon: 'vn:calendar', + }, + component: () => import('src/pages/Zone/Card/ZoneEvents.vue'), + }, + ], +}; + +export default { + name: 'Zone', + path: '/zone', + meta: { + title: 'zones', + icon: 'vn:zone', + moduleName: 'Zone', + keyBinding: 'z', + menu: ['ZoneList', 'ZoneDeliveryDays', 'ZoneUpcomingList', 'ZoneUpcomingDeliveries',], + }, + component: RouterView, + redirect: { name: 'ZoneMain' }, children: [ { path: '/zone', name: 'ZoneMain', component: () => import('src/components/common/VnModule.vue'), - redirect: { name: 'ZoneList' }, + redirect: { name: 'ZoneIndexMain' }, children: [ { - path: 'list', - name: 'ZoneList', - meta: { - title: 'zonesList', - icon: 'view_list', - }, + path: '', + name: 'ZoneIndexMain', + redirect: { name: 'ZoneList' }, component: () => import('src/pages/Zone/ZoneList.vue'), + children: [ + { + name: 'ZoneList', + path: 'list', + meta: { + title: 'list', + icon: 'view_list', + }, + }, + zoneCard, + ], }, { path: 'delivery-days', @@ -62,67 +128,5 @@ export default { }, ], }, - { - name: 'ZoneCard', - path: ':id', - component: () => import('src/pages/Zone/Card/ZoneCard.vue'), - redirect: { name: 'ZoneSummary' }, - children: [ - { - name: 'ZoneSummary', - path: 'summary', - meta: { - title: 'summary', - icon: 'launch', - }, - component: () => import('src/pages/Zone/Card/ZoneSummary.vue'), - }, - { - name: 'ZoneBasicData', - path: 'basic-data', - meta: { - title: 'basicData', - icon: 'vn:settings', - }, - component: () => import('src/pages/Zone/Card/ZoneBasicData.vue'), - }, - { - name: 'ZoneLocations', - path: 'location', - meta: { - title: 'locations', - icon: 'my_location', - }, - component: () => import('src/pages/Zone/Card/ZoneLocations.vue'), - }, - { - name: 'ZoneWarehouses', - path: 'warehouses', - meta: { - title: 'warehouses', - icon: 'home', - }, - component: () => import('src/pages/Zone/Card/ZoneWarehouses.vue'), - }, - { - name: 'ZoneHistory', - path: 'log', - meta: { - title: 'log', - icon: 'history', - }, - component: () => import('src/pages/Zone/Card/ZoneLog.vue'), - }, - { - name: 'ZoneEvents', - path: 'events', - meta: { - title: 'calendar', - icon: 'vn:calendar', - }, - component: () => import('src/pages/Zone/Card/ZoneEvents.vue'), - }, - ], - }, ], }; -- 2.40.1 From be2ef171bdf425c2a0c919f4d48d1a05acf14f65 Mon Sep 17 00:00:00 2001 From: provira <provira@verdnatura.es> Date: Tue, 14 Jan 2025 12:19:47 +0100 Subject: [PATCH 2/2] Merge branch 'dev' of https: refs #8322//gitea.verdnatura.es/verdnatura/salix-front into 8322-zone --- CHANGELOG.md | 243 ++++++++++ cypress.config.js | 1 + package.json | 3 +- pnpm-lock.yaml | 23 +- src/boot/qformMixin.js | 2 +- src/components/CreateNewPostcodeForm.vue | 8 +- src/components/CrudModel.vue | 8 +- src/components/FormModel.vue | 4 +- src/components/RegularizeStockForm.vue | 3 +- src/components/VnTable/VnTable.vue | 50 +-- src/components/VnTable/VnTableFilter.vue | 10 +- src/components/__tests__/CrudModel.spec.js | 134 +++++- .../__tests__/EditTableCellValueForm.spec.js | 56 +++ .../__tests__/FilterItemForm.spec.js | 82 ++++ src/components/__tests__/FormModel.spec.js | 149 ++++++ src/components/common/VnBtnSelect.vue | 1 + src/components/common/VnChangePassword.vue | 14 +- src/components/common/VnDateBadge.vue | 14 +- src/components/common/VnDmsList.vue | 2 +- src/components/common/VnInput.vue | 37 +- src/components/common/VnInputDate.vue | 2 - src/components/common/VnInputPassword.vue | 31 ++ src/components/common/VnInputTime.vue | 2 - src/components/common/VnModule.vue | 15 +- src/components/common/VnSection.vue | 21 +- src/components/common/VnSelect.vue | 30 +- src/components/common/VnSelectWorker.vue | 3 +- .../common/__tests__/VnInputDate.spec.js | 72 +++ .../common/__tests__/VnJsonValue.spec.js | 95 ++++ .../common/__tests__/VnNotes.spec.js | 107 +++++ src/components/ui/CardDescriptor.vue | 32 +- src/components/ui/CardSummary.vue | 22 +- src/components/ui/VnFilterPanel.vue | 8 +- src/components/ui/VnLinkPhone.vue | 2 +- src/components/ui/VnMoreOptions.vue | 20 + src/components/ui/VnNotes.vue | 2 +- src/components/ui/VnPaginate.vue | 1 + src/components/ui/VnSearchbar.vue | 91 +++- src/components/ui/VnSms.vue | 1 + .../ui/__tests__/FetchedTags.spec.js | 81 ++++ src/composables/useArrayData.js | 67 +-- src/composables/useHasAccount.js | 6 + src/css/app.scss | 22 +- src/filters/toDateHourMin.js | 4 +- src/filters/toDateHourMinSec.js | 4 +- src/i18n/locale/en.yml | 29 +- src/i18n/locale/es.yml | 33 ++ src/pages/Account/AccountCreate.vue | 5 +- src/pages/Account/AccountLdap.vue | 4 +- src/pages/Account/AccountList.vue | 5 +- src/pages/Account/AccountSamba.vue | 4 +- src/pages/Account/Card/AccountDescriptor.vue | 22 +- .../Account/Card/AccountDescriptorMenu.vue | 31 +- src/pages/Account/Card/AccountMailAlias.vue | 13 +- .../Account/Card/AccountMailForwarding.vue | 21 +- src/pages/Account/Card/AccountSummary.vue | 5 +- .../Account/Role/Card/RoleDescriptor.vue | 2 +- src/pages/Account/locale/en.yml | 14 + src/pages/Account/locale/es.yml | 16 + src/pages/Claim/Card/ClaimCard.vue | 18 +- src/pages/Claim/Card/ClaimDevelopment.vue | 14 +- src/pages/Claim/Card/ClaimLines.vue | 2 +- src/pages/Claim/Card/ClaimSummary.vue | 4 + src/pages/Claim/ClaimFilter.vue | 11 +- src/pages/Claim/ClaimList.vue | 76 ++-- src/pages/Claim/locale/en.yml | 2 + src/pages/Claim/locale/es.yml | 4 +- src/pages/Customer/Card/CustomerBalance.vue | 1 + .../Customer/Card/CustomerConsumption.vue | 37 +- .../Customer/Card/CustomerDescriptor.vue | 32 +- src/pages/Customer/Card/CustomerMandates.vue | 3 +- src/pages/Customer/Card/CustomerSummary.vue | 9 +- src/pages/Customer/CustomerFilter.vue | 4 + .../Defaulter/CustomerDefaulterFilter.vue | 1 + .../components/CustomerAddressEdit.vue | 10 +- src/pages/Customer/locale/en.yml | 21 + src/pages/Customer/locale/es.yml | 21 + .../Department/Card/DepartmentBasicData.vue | 2 +- src/pages/Department/Card/DepartmentCard.vue | 6 +- .../Department/Card/DepartmentDescriptor.vue | 6 +- .../Department/Card/DepartmentSummary.vue | 4 +- src/pages/Entry/Card/EntryDescriptor.vue | 12 +- src/pages/Entry/Card/EntryDescriptorMenu.vue | 22 + src/pages/Entry/Card/EntrySummary.vue | 97 ++-- src/pages/Entry/EntryBuysTableDialog.vue | 83 ++-- src/pages/Entry/EntryFilter.vue | 10 +- src/pages/Entry/EntryLatestBuysFilter.vue | 18 +- src/pages/Entry/EntryList.vue | 5 +- src/pages/Entry/EntryStockBoughtFilter.vue | 2 +- src/pages/Entry/MyEntries.vue | 2 +- src/pages/Entry/locale/en.yml | 2 + src/pages/Entry/locale/es.yml | 2 + .../InvoiceIn/Card/InvoiceInBasicData.vue | 2 +- .../InvoiceIn/Card/InvoiceInDescriptor.vue | 274 +---------- .../Card/InvoiceInDescriptorMenu.vue | 206 +++++++++ .../InvoiceIn/Card/InvoiceInIntrastat.vue | 2 +- src/pages/InvoiceIn/Card/InvoiceInSummary.vue | 72 +-- src/pages/InvoiceIn/InvoiceInCreate.vue | 6 +- src/pages/InvoiceIn/InvoiceInFilter.vue | 19 +- src/pages/InvoiceIn/InvoiceInList.vue | 39 +- src/pages/InvoiceIn/locale/en.yml | 27 +- src/pages/InvoiceIn/locale/es.yml | 25 +- .../InvoiceOut/Card/InvoiceOutSummary.vue | 4 + src/pages/InvoiceOut/InvoiceOutFilter.vue | 1 + src/pages/InvoiceOut/InvoiceOutGlobalForm.vue | 5 + src/pages/InvoiceOut/InvoiceOutList.vue | 12 +- src/pages/InvoiceOut/locale/en.yml | 13 + src/pages/InvoiceOut/locale/es.yml | 13 + src/pages/Item/Card/ItemBasicData.vue | 6 + src/pages/Item/Card/ItemBotanical.vue | 2 + src/pages/Item/Card/ItemDescriptor.vue | 42 +- src/pages/Item/Card/ItemDescriptorImage.vue | 1 - src/pages/Item/Card/ItemDescriptorMenu.vue | 44 ++ src/pages/Item/Card/ItemDiary.vue | 2 +- src/pages/Item/Card/ItemLastEntries.vue | 88 ++-- src/pages/Item/Card/ItemSummary.vue | 8 +- src/pages/Item/Card/ItemTags.vue | 4 +- src/pages/Item/ItemFixedPrice.vue | 34 +- src/pages/Item/ItemList.vue | 142 +++++- src/pages/Item/ItemListFilter.vue | 23 +- src/pages/Item/ItemRequest.vue | 26 +- src/pages/Item/ItemRequestFilter.vue | 3 +- src/pages/Item/locale/en.yml | 4 + src/pages/Item/locale/es.yml | 4 + src/pages/Login/LoginMain.vue | 7 +- src/pages/Login/ResetPassword.vue | 11 +- src/pages/Monitor/Ticket/MonitorTickets.vue | 8 +- .../Order/Card/OrderCatalogItemDialog.vue | 2 +- src/pages/Order/Card/OrderDescriptor.vue | 4 - src/pages/Order/Card/OrderFilter.vue | 3 + src/pages/Order/Card/OrderLines.vue | 4 +- src/pages/Order/Card/OrderSummary.vue | 6 +- src/pages/Route/Agency/locale/es.yml | 1 + .../Route/Card/RouteAutonomousFilter.vue | 4 +- src/pages/Route/Card/RouteDescriptorMenu.vue | 2 +- src/pages/Route/Card/RouteFilter.vue | 2 + src/pages/Route/Card/RouteSummary.vue | 4 + src/pages/Route/Roadmap/RoadmapSummary.vue | 4 + src/pages/Route/RouteAutonomous.vue | 2 + src/pages/Route/locale/en.yml | 14 + src/pages/Route/locale/es.yml | 14 + .../Shelving/Card/ShelvingDescriptorMenu.vue | 7 +- src/pages/Shelving/Card/ShelvingSummary.vue | 13 +- src/pages/Supplier/Card/SupplierBasicData.vue | 3 + .../Card/SupplierConsumptionFilter.vue | 2 + .../Supplier/Card/SupplierDescriptor.vue | 6 +- src/pages/Supplier/Card/SupplierSummary.vue | 3 +- .../Card/BasicData/TicketBasicDataForm.vue | 2 +- src/pages/Ticket/Card/TicketExpedition.vue | 15 +- .../Ticket/Card/TicketPurchaseRequest.vue | 1 + src/pages/Ticket/Card/TicketSale.vue | 7 +- src/pages/Ticket/Card/TicketSummary.vue | 18 +- src/pages/Ticket/TicketFilter.vue | 23 +- src/pages/Ticket/TicketList.vue | 1 + src/pages/Travel/Card/TravelSummary.vue | 5 +- src/pages/Travel/ExtraCommunity.vue | 27 +- src/pages/Travel/ExtraCommunityFilter.vue | 16 +- src/pages/Travel/TravelFilter.vue | 6 +- src/pages/Travel/TravelList.vue | 1 + src/pages/Wagon/WagonList.vue | 5 + src/pages/Worker/Card/WorkerCard.vue | 18 +- src/pages/Worker/Card/WorkerDescriptor.vue | 55 +-- .../Worker/Card/WorkerDescriptorMenu.vue | 65 +++ src/pages/Worker/Card/WorkerPBX.vue | 64 +-- src/pages/Worker/Card/WorkerSummary.vue | 4 + src/pages/Worker/Card/WorkerTimeControl.vue | 35 +- .../Worker/Card/WorkerTimeControlCalendar.vue | 3 +- src/pages/Worker/WorkerCreate.vue | 254 ----------- src/pages/Worker/WorkerDepartment.vue | 11 +- src/pages/Worker/WorkerDepartmentTree.vue | 8 +- src/pages/Worker/WorkerList.vue | 363 ++++++++------- src/pages/Worker/locale/en.yml | 3 + src/pages/Worker/locale/es.yml | 5 +- src/pages/Zone/Card/ZoneBasicData.vue | 13 +- .../Zone/Card/ZoneEventExclusionForm.vue | 2 +- .../Zone/Card/ZoneEventInclusionForm.vue | 10 +- src/pages/Zone/Card/ZoneSummary.vue | 4 + src/pages/Zone/ZoneDeliveryPanel.vue | 3 +- src/pages/Zone/ZoneList.vue | 98 ++-- src/pages/Zone/locale/en.yml | 2 + src/pages/Zone/locale/es.yml | 3 + src/router/modules/claim.js | 223 ++++----- src/router/modules/department.js | 47 -- src/router/modules/index.js | 2 - src/router/modules/worker.js | 425 ++++++++++-------- src/router/routes.js | 2 - src/stores/invoiceOutGlobal.js | 62 +-- src/stores/useArrayDataStore.js | 1 + test/cypress/.gitignore | 1 + .../integration/Order/orderCatalog.spec.js | 71 +-- .../integration/client/clientList.spec.js | 2 +- .../invoiceIn/invoiceInCorrective.spec.js | 4 +- .../invoiceOut/invoiceOutList.spec.js | 46 ++ .../invoiceOut/invoiceOutMakeInvoice.spec.js | 21 + .../invoiceOutNegativeBases.spec.js | 16 + .../invoiceOut/invoiceOutSummary.spec.js | 47 ++ .../invoiceOut/invvoiceOutGlobal.spec.js | 28 ++ .../integration/item/ItemFixedPrice.spec.js | 8 +- .../integration/item/itemBarcodes.spec.js | 25 ++ .../integration/item/itemBotanical.spec.js | 31 ++ .../integration/item/itemLastEntries.spec.js | 20 - .../cypress/integration/item/itemList.spec.js | 34 ++ .../integration/item/itemSummary.spec.js | 24 + test/cypress/integration/item/itemTag.spec.js | 39 ++ test/cypress/integration/item/itemTax.spec.js | 14 + .../cypress/integration/item/itemType.spec.js | 40 ++ .../integration/outLogin/login.spec.js | 1 + .../ticket/ticketExpedition.spec.js | 4 +- .../integration/ticket/ticketList.spec.js | 8 +- .../integration/ticket/ticketRequest.spec.js | 2 +- .../integration/ticket/ticketSale.spec.js | 17 +- .../vnComponent/VnLocation.spec.js | 11 +- .../integration/vnComponent/VnLog.spec.js | 4 +- .../vnComponent/VnSearchBar.spec.js | 9 +- .../integration/wagon/wagonCreate.spec.js | 41 +- .../integration/worker/workerCreate.spec.js | 7 +- .../integration/zone/zoneBasicData.spec.js | 5 +- .../integration/zone/zoneCreate.spec.js | 6 +- test/cypress/support/commands.js | 13 +- test/vitest/helper.js | 4 +- 220 files changed, 3933 insertions(+), 2193 deletions(-) create mode 100644 src/components/__tests__/EditTableCellValueForm.spec.js create mode 100644 src/components/__tests__/FilterItemForm.spec.js create mode 100644 src/components/__tests__/FormModel.spec.js create mode 100644 src/components/common/VnInputPassword.vue create mode 100644 src/components/common/__tests__/VnInputDate.spec.js create mode 100644 src/components/common/__tests__/VnJsonValue.spec.js create mode 100644 src/components/common/__tests__/VnNotes.spec.js create mode 100644 src/components/ui/VnMoreOptions.vue create mode 100644 src/components/ui/__tests__/FetchedTags.spec.js create mode 100644 src/composables/useHasAccount.js create mode 100644 src/pages/Entry/Card/EntryDescriptorMenu.vue create mode 100644 src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue create mode 100644 src/pages/Item/Card/ItemDescriptorMenu.vue create mode 100644 src/pages/Worker/Card/WorkerDescriptorMenu.vue delete mode 100644 src/pages/Worker/WorkerCreate.vue delete mode 100644 src/router/modules/department.js create mode 100644 test/cypress/integration/invoiceOut/invoiceOutList.spec.js create mode 100644 test/cypress/integration/invoiceOut/invoiceOutMakeInvoice.spec.js create mode 100644 test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js create mode 100644 test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js create mode 100644 test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js create mode 100644 test/cypress/integration/item/itemBarcodes.spec.js create mode 100644 test/cypress/integration/item/itemBotanical.spec.js delete mode 100644 test/cypress/integration/item/itemLastEntries.spec.js create mode 100644 test/cypress/integration/item/itemList.spec.js create mode 100644 test/cypress/integration/item/itemSummary.spec.js create mode 100644 test/cypress/integration/item/itemTag.spec.js create mode 100644 test/cypress/integration/item/itemTax.spec.js create mode 100644 test/cypress/integration/item/itemType.spec.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e110e4cd6..a7797f810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,246 @@ +# Version 25.00 - 2025-01-14 + +### Added 🆕 + +- chore: refs #7056 move test by:jorgep +- feat: refs #7050 7050 add object check by:Jtubau +- feat: refs #7050 7050 add test to isEmpty() by:Jtubau +- feat: refs #7056 add tests in FormModel by:jorgep +- feat: refs #7056 update route meta information and add FormModel tests by:jorgep +- feat: refs #7074 tests for fns setData(), parseDms() and showFormDialog() (7074-makeFrontTestToVnDmsList) by:Jtubau +- feat: refs #7079 created VnLocation front test by:provira +- feat: refs #7189 add Accept-Language header to axios requests by:jorgep +- feat: refs #7924 add custom inspection checkbox and localization support by:jgallego +- feat: refs #7924 update custom inspection label for clarity in English and Spanish locales by:jgallego +- feat: refs #8004 enhance FetchedTags component with column support and styling updates by:pablone +- feat: refs #8004 hide rightFilter by:pablone +- feat: refs #8246 added new field in list by:Jon +- feat: refs #8266 added descriptor to item name by:jtubau +- feat: refs #8293 add zone filter by:Jtubau +- feat: refs #8293 include zone data in each record by:Jtubau +- fix: refs #8004 more list style issues by:pablone +- fix: refs #8004 some style issues on all list by:pablone +- style: refs #8004 update layout and styling in FetchedTags and ItemList components by:pablone +- style: update CustomerBalance.vue to set label color by:jgallego + +### Changed 📦 + +- perf: order by:alexm +- perf: redirect transition list to card by:alexm +- perf: refs #8201 onDataSaved fetch by:Jon +- perf: revert processData by:alexm +- perf: simplify if by:alexm +- perf: simplify if (perf_redirectTransition) by:alexm +- refactor: item fixedPrice by:Jon +- refactor: refs #7050 refactorize by:jtubau +- refactor: refs #7050 removed blank spaces by:jtubau +- refactor: refs #7052 move EditTableCellValueForm tests to a new location and enhance test coverage by:jgallego +- refactor: refs #7052 remove unnecessary console logs from EditTableCellValueForm tests by:jgallego +- refactor: refs #7074 move dms constant to global scope by:Jtubau +- refactor: refs #7079 removed useless code by:provira +- refactor: refs #7924 simplify custom inspection icon rendering in ExtraCommunity.vue by:jgallego +- refactor: refs #8004 remove console log from CardSummary component on mount by:pablone +- refactor: refs #8004 remove consoleLogs by:pablone +- refactor: refs #8004 remove unused stateStore import in InvoiceInList.vue by:pablone +- refactor: refs #8004 remove unused travelFilterRef and chip definition in TravelList.vue by:pablone +- refactor: refs #8004 replace VnSelect with VnSelectWorker in CustomerList component by:pablone +- refactor: refs #8201 added onMounted to stablish the value to show icons by:Jon +- refactor: refs #8201 deleted condition by:Jon +- refactor: refs #8201 deleted log by:Jon +- refactor: refs #8201 deleted logs by:Jon +- refactor: refs #8266 8266 change expedition item name by:Jtubau +- refactor: refs #8266 change expedition label by:Jtubau +- refactor: refs #8293 remove redundant attributes by:Jtubau +- refactor: refs #8320 changed folder names from "specs" to "**tests**" by:provira +- refactor: refs #8320 moved front tests to their respective sections by:provira +- refactor: refs #8813 removed unused class property by:provira + +### Fixed 🛠️ + +- fix: discount class by:PAU ROVIRA ROSALENY +- fix: duplicate transalation after test to dev by:alexm +- fix: fix translations by:carlossa +- fix: redirect to sales when confirming lines by:Jon +- fix: refs #7050 delete import added by mistake by:Jtubau +- fix: refs #7133 handleSalesModelValue function to handle empty input by:jorgep +- fix: refs #7189 update user language on sessionStorage by:jorgep +- fix: refs #7935 remove unused 'companyFk' column from InvoiceInList component by:jorgep +- fix: refs #8004 more list style issues by:pablone +- fix: refs #8004 some style issues on all list by:pablone +- fix: refs #8004 update label for daysOnward in TravelFilter component and add translations by:pablone +- fix: refs #8004 vnTable card with and add permanent labels by:pablone +- fix: refs #8201 added onDataSaved emi to refetch when cahnges are made by:Jon +- fix: refs #8201 use arrayData to fix the error by:Jon +- fix: refs #8314 space between label and value by:jtubau +- fix: refs #8813 fixed ClaimLines format by:provira +- fix: update button sizes in ExtraCommunity.vue for better visibility by:jgallego +- perf: revert processData by:alexm +- refactor: item fixedPrice by:Jon + +# Version 24.52 - 2024-01-07 + +### Added 🆕 + +- chore: refs #8197 remove console log by:alexm +- chore: refs #8197 replace name by:alexm +- chore: refs #8197 unnecessary file by:alexm +- feat: #8110 apply mixin in quasar components by:Javier Segarra +- feat(Account & AccountRole): refs #8197 add VnCardMain by:alexm +- feat: addDptoLink by:Jtubau +- feat: added restore ticket function in ticket descriptor menu by:Jon +- feat: add support service wip by:jorgep +- feat: focus menu searchbar by:jorgep +- feat: make additional data object by:jorgep +- feat: message to grant access by:jorgep +- feat: refs #6583 add default param by:jorgep +- feat: refs #6583 add destination opt filter by:jorgep +- feat: refs #6583 add icon by:jorgep +- feat: refs #6583 add locale by:jorgep +- feat: refs #7072 added test to computed fn total by:Jtubau +- feat: refs #7235 update invoice out global form to fetch config based on serial type by:jgallego +- feat: refs #7301 add exclude inventory supplier from list by:pablone +- feat: refs #7301 enhance VnDateBadge styling and improve ItemLastEntries component by:pablone +- feat: refs #7882 Added distribution point by:guillermo +- feat: refs #7882 Added longitude & latitude by:guillermo +- feat: refs #7936 add autocomplete on tab fn by:jorgep +- feat: refs #7936 add company filter by:jorgep +- feat: refs #7936 add currency check before fetching by:jorgep +- feat: refs #7936 add dueDated field by:jorgep +- feat: refs #7936 add number validation to VnInputNumber & new daysAgo filter in InvoiceInFilter by:jorgep +- feat: refs #7936 add optionCaption by:jorgep +- feat: refs #7936 add row click navigation to InvoiceInSerial by:jorgep +- feat: refs #7936 add unit tests by:jorgep +- feat: refs #7936 add useAccountShortToStandard composable by:jorgep +- feat: refs #7936 calculate exchange & update taxable base by:jorgep +- feat: refs #7936 enhance downloadFile function to support opening in a new tab by:jorgep +- feat: refs #7936 enhance getTotal fn & add unit tests by:jorgep +- feat: refs #7936 enhance vn-select by:jorgep +- feat: refs #7936 improve optionLabel logic in InvoiceInVat component for better handling of numeric values by:jorgep +- feat: refs #7936 limit decimal places by:jorgep +- feat: refs #7936 make fields required by:jorgep +- feat: refs #7936 show country code & isVies fields by:jorgep +- feat: refs #7936 show id & value by:jorgep +- feat: refs #7936 simplify optionLabel wip by:jorgep +- feat: refs #7936 update 'isVies' label to use global translation key by:jorgep +- feat: refs #7936 update option labels in InvoiceIn components for better clarity by:jorgep +- feat: refs #7936 use default invoice data by:jorgep +- feat: refs #8001 change request by:robert +- feat: refs #8001 ticketExpeditionGrafana by:robert +- feat: refs #8194 created VnSelectWorker component and use it in Lilium by:Jon +- feat: refs #8197 better leftMenu and VnCardMain improvements by:alexm +- feat: refs #8197 default leftMenu by:alexm +- feat: refs #8197 default sectionName by:alexm +- feat: refs #8197 keepData in VnSection by:alexm +- feat: refs #8197 vnTableFilter by:alexm +- feat: refs #8197 working rightMenu by:alexm +- feat: remove re-fetch when add element by:Javier Segarra +- feat: remove search after category by:Javier Segarra +- feat: requested changes in item module by:Jon +- feat: update quantity by:Javier Segarra +- feat(VnPaginate): refs #8197 hold data when change to Card by:alexm + +### Changed 📦 + +- perf: #6896 REMOVE COMMENTS by:Javier Segarra +- perf: qFormMixin by:Javier Segarra +- perf: qFormMixin improvement by:Javier Segarra +- perf: refs #8194 select worker component by:Jon +- perf: refs #8197 perf by:alexm +- perf: remove comments by:Javier Segarra +- perf: remove unused variables (origin/warmfix_noUsedVars) by:Javier Segarra +- refactor: added again search emit by:Jon +- refactor: add useCau composable by:jorgep +- refactor: deleted log by:Jon +- refactor: deleted onUnmounted code by:Jon +- refactor: deleted useless hidden tag by:Jon +- refactor: deleted warnings and corrected itemTag by:Jon +- refactor: drop logic by:jorgep +- refactor: ignore params when searching by id on searchbar (origin/VnSearchbar-SearchRemoveParams) by:Jon +- refactor: log error by:Jon +- refactor: refs #7936 locale by:jorgep +- refactor: refs #7936 simplify getTotal fn by:jorgep +- refactor: refs #7936 update label capitalization and replace invoice type options by:jorgep +- refactor: refs #8194 deleted unnecessary label by:Jon +- refactor: refs #8194 modified select worker template by:Jon +- refactor: refs #8194 modified select worker to allow no one filter from monitor ticket by:Jon +- refactor: refs #8194 moved translation to the correct place by:Jon +- refactor: refs #8194 requested changes by:Jon +- refactor: refs #8194 structure changes in component and related files by:Jon +- refactor: refs #8197 adapt AccountAcls to VnCardMain by:alexm +- refactor: refs #8197 adapt AccountAlias by:alexm +- refactor: refs #8197 adapt Ticket to VnCardMain by:alexm +- refactor: refs #8197 backward compatible (8197-VnCardMain_backwardCompatibility) by:alexm +- refactor: refs #8197 rename VnSectionMain to VnModule and VnCardMain to VnSection by:alexm +- refactor: refs #8288 changed invoice out spanish translation by:provira +- refactor: use locale keys by:jorgep +- refactor: use teleport to avoid qdrawer overlapping by:Jon +- refactor: use VnSelectWorker by:Jon + +### Fixed 🛠️ + +- fix: account by:carlossa +- fix: account create by:carlossa +- fix: accountList create by:carlossa +- fix(AccountList): use $refs by:alexm +- fix: add data-key by:alexm +- fix: addLocales by:Jtubau +- fix: dated field by:Jon +- fix: e2e by:jorgep +- fix: fix department filter by:carlossa +- fix: fixed translations by:Javier Segarra +- fix: fixed translations by:provira +- fix: get total from api by:Javier Segarra +- fix: handle non-object options by:jorgep +- fix: monitorPayMethodFilter by:carlossa +- fix: orderBy priority by:Javier Segarra +- fix: prevent null by:jorgep +- fix: redirection vnTable VnTableFilter by:alexm +- fix: refs #6389 fix filter trad by:carlossa +- fix: refs #6389 fix front, filters, itp by:carlossa +- fix: refs #6389 front add packing filter by:carlossa +- fix: refs #6389 front by:carlossa +- fix: refs #6389 front filters by:carlossa +- fix: refs #6389 ipt by:carlossa +- fix: refs #6389 packing by:carlossa +- fix: refs #6583 update checkbox for filtering by destination in TicketAdvanceFilter by:jorgep +- fix: refs #7031 add test e2e by:carlossa +- fix: refs #7031 fix zoneTest by:carlossa +- fix: refs #7301 unnecessary console logs from ItemLastEntries.vue by:pablone +- fix: refs #7936 changes by:jorgep +- fix: refs #7936 decimal places & locale by:jorgep +- fix: refs #7936 descriptor & dueday by:jorgep +- fix: refs #7936 exclude disabled els on tab by:jorgep +- fix: refs #7936 format tax calculation to two decimal places by:jorgep +- fix: refs #7936 improve error handling by:jorgep +- fix: refs #7936 redirection by:jorgep +- fix: refs #7936 rollback by:jorgep +- fix: refs #7936 serial by:jorgep +- fix: refs #7936 tabulation wip by:jorgep +- fix: refs #7936 test by:jorgep +- fix: refs #8114 clean by:carlossa +- fix: refs #8114 fix agencyList by:carlossa +- fix: refs #8114 fix lifeCycle hooks by:carlossa +- fix: refs #8114 fix pr by:carlossa +- fix: refs #8114 fix removeAddress by:carlossa +- fix: refs #8114 orderList by:carlossa +- fix: refs #8114 remove logs by:carlossa +- fix: refs #8197 mapKey (origin/8197-perf_vnTableInside, 8197-perf_vnTableInside) by:alexm +- fix: refs #8197 redirection (8197-perf_redirection) by:alexm +- fix: refs #8197 staticParams and redirect by:alexm +- fix: refs #8197 vnPaginate onFetch emit by:alexm +- fix: refs #8197 vnPaginate when change :id by:alexm +- fix: refs #8197 vnTableFilter in vnTable by:alexm +- fix: refs #8315 ticketBoxing test by:alexm +- fix: remove url by:carlossa +- fix: rollback by:jorgep +- fix: test by:jorgep +- fix(VnDmsList): refs #8197 add mapKey by:alexm +- revert: refs #8197 arrayData changes by:alexm +- test: refs #8197 fix e2e by:alexm +- test: refs #8315 fix claimDevelopment fixtures by:alexm +- test: refs #8315 fix clientList by:alexm +- test: refs #8315 fix VnSelect in e2e by:alexm + # Version 24.50 - 2024-12-10 ### Added 🆕 diff --git a/cypress.config.js b/cypress.config.js index e9aeb547a..1100b59b1 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -11,6 +11,7 @@ module.exports = defineConfig({ screenshotsFolder: 'test/cypress/screenshots', supportFile: 'test/cypress/support/index.js', videosFolder: 'test/cypress/videos', + downloadsFolder: 'test/cypress/downloads', video: false, specPattern: 'test/cypress/integration/**/*.spec.js', experimentalRunAllSpecs: true, diff --git a/package.json b/package.json index b5e62af11..9d14e8727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-front", - "version": "25.02.0", + "version": "25.04.0", "description": "Salix frontend", "productName": "Salix", "author": "Verdnatura", @@ -25,6 +25,7 @@ "axios": "^1.4.0", "chromium": "^3.0.3", "croppie": "^2.6.5", + "moment": "^2.30.1", "pinia": "^2.1.3", "quasar": "^2.14.5", "validator": "^13.9.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83dfa0469..7bf640347 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ dependencies: croppie: specifier: ^2.6.5 version: 2.6.5 + moment: + specifier: ^2.30.1 + version: 2.30.1 pinia: specifier: ^2.1.3 version: 2.1.7(typescript@5.5.4)(vue@3.4.19) @@ -832,8 +835,8 @@ packages: vue-i18n: optional: true dependencies: - '@intlify/message-compiler': 10.0.0 - '@intlify/shared': 10.0.0 + '@intlify/message-compiler': 11.0.0-rc.1 + '@intlify/shared': 11.0.0-rc.1 jsonc-eslint-parser: 1.4.1 source-map: 0.6.1 vue-i18n: 9.9.1(vue@3.4.19) @@ -847,11 +850,11 @@ packages: '@intlify/message-compiler': 9.9.1 '@intlify/shared': 9.9.1 - /@intlify/message-compiler@10.0.0: - resolution: {integrity: sha512-OcaWc63NC/9p1cMdgoNKBj4d61BH8sUW1Hfs6YijTd9656ZR4rNqXAlRnBrfS5ABq0vjQjpa8VnyvH9hK49yBw==} + /@intlify/message-compiler@11.0.0-rc.1: + resolution: {integrity: sha512-TGw2uBfuTFTegZf/BHtUQBEKxl7Q/dVGLoqRIdw8lFsp9g/53sYn5iD+0HxIzdYjbWL6BTJMXCPUHp9PxDTRPw==} engines: {node: '>= 16'} dependencies: - '@intlify/shared': 10.0.0 + '@intlify/shared': 11.0.0-rc.1 source-map-js: 1.0.2 dev: true @@ -862,8 +865,8 @@ packages: '@intlify/shared': 9.9.1 source-map-js: 1.0.2 - /@intlify/shared@10.0.0: - resolution: {integrity: sha512-6ngLfI7DOTew2dcF9WMJx+NnMWghMBhIiHbGg+wRvngpzD5KZJZiJVuzMsUQE1a5YebEmtpTEfUrDp/NqVGdiw==} + /@intlify/shared@11.0.0-rc.1: + resolution: {integrity: sha512-8tR1xe7ZEbkabTuE/tNhzpolygUn9OaYp9yuYAF4MgDNZg06C3Qny80bes2/e9/Wm3aVkPUlCw6WgU7mQd0yEg==} engines: {node: '>= 16'} dev: true @@ -887,7 +890,7 @@ packages: optional: true dependencies: '@intlify/bundle-utils': 4.0.0(vue-i18n@9.9.1) - '@intlify/shared': 10.0.0 + '@intlify/shared': 11.0.0-rc.1 '@rollup/pluginutils': 4.2.1 '@vue/compiler-sfc': 3.4.19 debug: 4.3.4(supports-color@8.1.1) @@ -4960,6 +4963,10 @@ packages: uuid: 8.3.2 dev: true + /moment@2.30.1: + resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==} + dev: false + /ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} diff --git a/src/boot/qformMixin.js b/src/boot/qformMixin.js index 187ca6dbc..97d80c670 100644 --- a/src/boot/qformMixin.js +++ b/src/boot/qformMixin.js @@ -31,7 +31,7 @@ export default { console.error(error); } form.addEventListener('keyup', function (evt) { - if (evt.key === 'Enter') { + if (evt.key === 'Enter' && !that.$attrs['prevent-submit']) { const input = evt.target; if (input.type == 'textarea' && evt.shiftKey) { evt.preventDefault(); diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index c656fcb2f..39ebfe540 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -55,13 +55,6 @@ async function setCountry(countryFk, data) { } // Province - -async function handleProvinces(data) { - provincesOptions.value = data; - if (postcodeFormData.countryFk) { - await fetchTowns(); - } -} async function setProvince(id, data) { if (data.provinceFk === id) return; const newProvince = provincesOptions.value.find((province) => province.id == id); @@ -69,6 +62,7 @@ async function setProvince(id, data) { postcodeFormData.provinceFk = id; await fetchTowns(); } + async function onProvinceCreated(data) { postcodeFormData.provinceFk = data.id; } diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 7fdb54bc4..940b72ff0 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -127,7 +127,7 @@ function resetData(data) { originalData.value = JSON.parse(JSON.stringify(data)); formData.value = JSON.parse(JSON.stringify(data)); - if (watchChanges.value) watchChanges.value(); //destoy watcher + if (watchChanges.value) watchChanges.value(); //destroy watcher watchChanges.value = watch(formData, () => (hasChanges.value = true), { deep: true }); } @@ -270,10 +270,8 @@ function getChanges() { function isEmpty(obj) { if (obj == null) return true; - if (obj === undefined) return true; - if (Object.keys(obj).length === 0) return true; - - if (obj.length > 0) return false; + if (Array.isArray(obj)) return !obj.length; + return !Object.keys(obj).length; } async function reload(params) { diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index c569f2553..2e580257c 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -1,7 +1,7 @@ <script setup> import axios from 'axios'; import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue'; -import { onBeforeRouteLeave, useRouter } from 'vue-router'; +import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import { useQuasar } from 'quasar'; import { useState } from 'src/composables/useState'; @@ -12,7 +12,6 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue'; import VnConfirm from './ui/VnConfirm.vue'; import { tMobile } from 'src/composables/tMobile'; import { useArrayData } from 'src/composables/useArrayData'; -import { useRoute } from 'vue-router'; const { push } = useRouter(); const quasar = useQuasar(); @@ -199,6 +198,7 @@ async function fetch() { } catch (e) { state.set(modelValue, {}); originalData.value = {}; + throw e; } } diff --git a/src/components/RegularizeStockForm.vue b/src/components/RegularizeStockForm.vue index f34386fc4..91a2e5d39 100644 --- a/src/components/RegularizeStockForm.vue +++ b/src/components/RegularizeStockForm.vue @@ -44,7 +44,7 @@ const onDataSaved = (data) => { <FormModelPopup url-create="Items/regularize" model="Items" - :title="t('Regularize stock')" + :title="t('item.regularizeStock')" :form-initial-data="regularizeFormData" @on-data-saved="onDataSaved($event)" > @@ -55,6 +55,7 @@ const onDataSaved = (data) => { v-model.number="data.quantity" type="number" autofocus + data-cy="regularizeStockInput" /> </VnRow> <VnRow> diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 7886d0567..07992f616 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -59,8 +59,8 @@ const $props = defineProps({ default: true, }, bottom: { - type: Object, - default: null, + type: Boolean, + default: false, }, cardClass: { type: String, @@ -314,7 +314,7 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { show-if-above > <QScrollArea class="fit"> - <VnTableFilter :data-key="$attrs['data-key']" :columns="columns" /> + <VnTableFilter :data-key="$attrs['data-key']" :columns="columns" :redirect="redirect" /> </QScrollArea> </QDrawer> <CrudModel @@ -478,29 +478,6 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { /> </QTd> </template> - <template #bottom v-if="bottom"> - <slot name="bottom-table"> - <QBtn - @click=" - () => - createAsDialog - ? (showForm = !showForm) - : handleOnDataSaved(create) - " - class="cursor-pointer fill-icon" - color="primary" - icon="add_circle" - size="md" - round - flat - shortcut="+" - :disabled="!disabledAttr" - /> - <QTooltip> - {{ createForm.title }} - </QTooltip> - </slot> - </template> <template #item="{ row, colsMap }"> <component :is="$props.redirect ? 'router-link' : 'span'" @@ -625,6 +602,27 @@ function handleSelection({ evt, added, rows: selectedRows }, rows) { </QTr> </template> </QTable> + <div class="full-width bottomButton" v-if="bottom"> + <QBtn + @click=" + () => + createAsDialog + ? (showForm = !showForm) + : handleOnDataSaved(create) + " + class="cursor-pointer fill-icon" + color="primary" + icon="add_circle" + size="md" + round + flat + shortcut="+" + :disabled="!disabledAttr" + /> + <QTooltip> + {{ createForm.title }} + </QTooltip> + </div> </template> </CrudModel> <QPageSticky v-if="$props.create" :offset="[20, 20]" style="z-index: 2"> diff --git a/src/components/VnTable/VnTableFilter.vue b/src/components/VnTable/VnTableFilter.vue index f23c657cf..8632842f4 100644 --- a/src/components/VnTable/VnTableFilter.vue +++ b/src/components/VnTable/VnTableFilter.vue @@ -1,6 +1,5 @@ <script setup> import { ref } from 'vue'; -import { useI18n } from 'vue-i18n'; import VnFilterPanel from 'components/ui/VnFilterPanel.vue'; import VnFilter from 'components/VnTable/VnFilter.vue'; @@ -11,16 +10,11 @@ defineProps({ type: Array, required: true, }, - chipLocale: { - type: String, - default: null, - }, searchUrl: { type: [String, Boolean], default: 'table', }, }); -const { t } = useI18n(); const tableFilterRef = ref([]); @@ -62,9 +56,9 @@ function columnName(col) { :columns="columns" /> </template> - <template #tags="{ tag, formatFn }" v-if="chipLocale"> + <template #tags="{ tag, formatFn, getLocale }"> <div class="q-gutter-x-xs"> - <strong>{{ t(`${chipLocale}.${tag.label}`) }}: </strong> + <strong>{{ getLocale(`${tag.label}`) }}: </strong> <span>{{ formatFn(tag.value) }}</span> </div> </template> diff --git a/src/components/__tests__/CrudModel.spec.js b/src/components/__tests__/CrudModel.spec.js index 6ce93e59c..e0afd30ad 100644 --- a/src/components/__tests__/CrudModel.spec.js +++ b/src/components/__tests__/CrudModel.spec.js @@ -1,11 +1,13 @@ -import { createWrapper } from 'app/test/vitest/helper'; +import { createWrapper, axios } from 'app/test/vitest/helper'; import CrudModel from 'components/CrudModel.vue'; import { vi, afterEach, beforeEach, beforeAll, describe, expect, it } from 'vitest'; describe('CrudModel', () => { + let wrapper; let vm; + let data; beforeAll(() => { - vm = createWrapper(CrudModel, { + wrapper = createWrapper(CrudModel, { global: { stubs: [ 'vnPaginate', @@ -25,12 +27,16 @@ describe('CrudModel', () => { dataKey: 'crudModelKey', model: 'crudModel', url: 'crudModelUrl', + saveFn: '', }, - }).vm; + }); + wrapper=wrapper.wrapper; + vm=wrapper.vm; }); beforeEach(() => { vm.fetch([]); + vm.watchChanges = null; }); afterEach(() => { @@ -117,4 +123,126 @@ describe('CrudModel', () => { }); }); }); + + describe('isEmpty()', () => { + let dummyObj; + let dummyArray; + let result; + it('should return true if object si null', async () => { + dummyObj = null; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(true); + }); + + it('should return true if object si undefined', async () => { + dummyObj = undefined; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(true); + }); + + it('should return true if object is empty', async () => { + dummyObj ={}; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(true); + }); + + it('should return false if object is not empty', async () => { + dummyObj = {a:1, b:2, c:3}; + result = vm.isEmpty(dummyObj); + + expect(result).toBe(false); + }); + + it('should return true if array is empty', async () => { + dummyArray = []; + result = vm.isEmpty(dummyArray); + + expect(result).toBe(true); + }); + + it('should return false if array is not empty', async () => { + dummyArray = [1,2,3]; + result = vm.isEmpty(dummyArray); + + expect(result).toBe(false); + }) + }); + + describe('resetData()', () => { + it('should add $index to elements in data[] and sets originalData and formData with data', async () => { + data = [{ + name: 'Tony', + lastName: 'Stark', + age: 42, + }]; + + vm.resetData(data); + + expect(vm.originalData).toEqual(data); + expect(vm.originalData[0].$index).toEqual(0); + expect(vm.formData).toEqual(data); + expect(vm.formData[0].$index).toEqual(0); + expect(vm.watchChanges).not.toBeNull(); + }); + + it('should dont do nothing if data is null', async () => { + vm.resetData(null); + + expect(vm.watchChanges).toBeNull(); + }); + + it('should set originalData and formatData with data and generate watchChanges', async () => { + data = { + name: 'Tony', + lastName: 'Stark', + age: 42, + }; + + vm.resetData(data); + + expect(vm.originalData).toEqual(data); + expect(vm.formData).toEqual(data); + expect(vm.watchChanges).not.toBeNull(); + }); + }); + + describe('saveChanges()', () => { + data = [{ + name: 'Tony', + lastName: 'Stark', + age: 42, + }]; + + it('should call saveFn if exists', async () => { + await wrapper.setProps({ saveFn: vi.fn() }); + + vm.saveChanges(data); + + expect(vm.saveFn).toHaveBeenCalledOnce(); + expect(vm.isLoading).toBe(false); + expect(vm.hasChanges).toBe(false); + + await wrapper.setProps({ saveFn: '' }); + }); + + it("should use default url if there's not saveFn", async () => { + const postMock =vi.spyOn(axios, 'post'); + + vm.formData = [{ + name: 'Bruce', + lastName: 'Wayne', + age: 45, + }] + + await vm.saveChanges(data); + + expect(postMock).toHaveBeenCalledWith(vm.url + '/crud', data); + expect(vm.isLoading).toBe(false); + expect(vm.hasChanges).toBe(false); + expect(vm.originalData).toEqual(JSON.parse(JSON.stringify(vm.formData))); + }); + }); }); diff --git a/src/components/__tests__/EditTableCellValueForm.spec.js b/src/components/__tests__/EditTableCellValueForm.spec.js new file mode 100644 index 000000000..fa47d8f73 --- /dev/null +++ b/src/components/__tests__/EditTableCellValueForm.spec.js @@ -0,0 +1,56 @@ +import { createWrapper, axios } from 'app/test/vitest/helper'; +import EditForm from 'components/EditTableCellValueForm.vue'; +import { vi, afterEach, beforeAll, describe, expect, it } from 'vitest'; + +const fieldA = 'fieldA'; +const fieldB = 'fieldB'; + +describe('EditForm', () => { + let vm; + const mockRows = [ + { id: 1, itemFk: 101 }, + { id: 2, itemFk: 102 }, + ]; + const mockFieldsOptions = [ + { label: 'Field A', field: fieldA, component: 'input', attrs: {} }, + { label: 'Field B', field: fieldB, component: 'date', attrs: {} }, + ]; + const editUrl = '/api/edit'; + + beforeAll(() => { + vi.spyOn(axios, 'post').mockResolvedValue({ status: 200 }); + vm = createWrapper(EditForm, { + props: { + rows: mockRows, + fieldsOptions: mockFieldsOptions, + editUrl, + }, + }).vm; + }); + + afterEach(() => { + vi.clearAllMocks(); + }); + + describe('onSubmit()', () => { + it('should call axios.post with the correct parameters in the payload', async () => { + const selectedField = { field: fieldA, component: 'input', attrs: {} }; + const newValue = 'Test Value'; + + vm.selectedField = selectedField; + vm.newValue = newValue; + + await vm.onSubmit(); + + const payload = axios.post.mock.calls[0][1]; + + expect(axios.post).toHaveBeenCalledWith(editUrl, expect.any(Object)); + expect(payload.field).toEqual(fieldA); + expect(payload.newValue).toEqual(newValue); + + expect(payload.lines).toEqual(expect.arrayContaining(mockRows)); + + expect(vm.isLoading).toEqual(false); + }); + }); +}); diff --git a/src/components/__tests__/FilterItemForm.spec.js b/src/components/__tests__/FilterItemForm.spec.js new file mode 100644 index 000000000..210d6bf02 --- /dev/null +++ b/src/components/__tests__/FilterItemForm.spec.js @@ -0,0 +1,82 @@ +import { createWrapper, axios } from 'app/test/vitest/helper'; +import FilterItemForm from 'src/components/FilterItemForm.vue'; +import { vi, beforeAll, describe, expect, it } from 'vitest'; + +describe('FilterItemForm', () => { + let vm; + let wrapper; + + beforeAll(() => { + wrapper = createWrapper(FilterItemForm, { + props: { + url: 'Items/withName', + }, + }); + vm = wrapper.vm; + wrapper = wrapper.wrapper; + + vi.spyOn(axios, 'get').mockResolvedValue({ + data: [ + { + id: 999996, + name: 'bolas de madera', + size: 2, + inkFk: null, + producerFk: null, + }, + ], + }); + }); + + it('should filter data and populate tableRows for table display', async () => { + vm.itemFilterParams.name = 'bolas de madera'; + + await vm.onSubmit(); + + const expectedFilter = { + include: [ + { relation: 'producer', scope: { fields: ['name'] } }, + { relation: 'ink', scope: { fields: ['name'] } }, + ], + where: {"name":{"like":"%bolas de madera%"}}, + }; + + expect(axios.get).toHaveBeenCalledWith('Items/withName', { + params: { filter: JSON.stringify(expectedFilter) }, + }); + + expect(vm.tableRows).toEqual([ + { + id: 999996, + name: 'bolas de madera', + size: 2, + inkFk: null, + producerFk: null, + }, + ]); + }); + + it('should handle an empty itemFilterParams correctly', async () => { + vm.itemFilterParams.name = null; + vm.itemFilterParams = {}; + + await vm.onSubmit(); + + const expectedFilter = { + include: [ + { relation: 'producer', scope: { fields: ['name'] } }, + { relation: 'ink', scope: { fields: ['name'] } }, + ], + where: {}, + }; + + expect(axios.get).toHaveBeenCalledWith('Items/withName', { + params: { filter: JSON.stringify(expectedFilter) }, + }); + }); + + it('should emit "itemSelected" with the correct id and close the form', () => { + vm.selectItem({ id: 12345 }); + expect(wrapper.emitted('itemSelected')[0]).toEqual([12345]); + }); +}); \ No newline at end of file diff --git a/src/components/__tests__/FormModel.spec.js b/src/components/__tests__/FormModel.spec.js new file mode 100644 index 000000000..e35684bc3 --- /dev/null +++ b/src/components/__tests__/FormModel.spec.js @@ -0,0 +1,149 @@ +import { describe, expect, it, beforeAll, vi, afterAll } from 'vitest'; +import { createWrapper, axios } from 'app/test/vitest/helper'; +import FormModel from 'src/components/FormModel.vue'; + +describe('FormModel', () => { + const model = 'mockModel'; + const url = 'mockUrl'; + const formInitialData = { mockKey: 'mockVal' }; + + describe('modelValue', () => { + it('should use the provided model', () => { + const { vm } = mount({ propsData: { model } }); + expect(vm.modelValue).toBe(model); + }); + + it('should use the route meta title when model is not provided', () => { + const { vm } = mount({}); + expect(vm.modelValue).toBe('formModel_mockTitle'); + }); + }); + + describe('onMounted()', () => { + let mockGet; + + beforeAll(() => { + mockGet = vi.spyOn(axios, 'get').mockResolvedValue({ data: {} }); + }); + + afterAll(() => { + mockGet.mockRestore(); + }); + + it('should not fetch when has formInitialData', () => { + mount({ propsData: { url, model, autoLoad: true, formInitialData } }); + expect(mockGet).not.toHaveBeenCalled(); + }); + + it('should fetch when there is url and auto-load', () => { + mount({ propsData: { url, model, autoLoad: true } }); + expect(mockGet).toHaveBeenCalled(); + }); + + it('should not observe changes', () => { + const { vm } = mount({ + propsData: { url, model, observeFormChanges: false, formInitialData }, + }); + + expect(vm.hasChanges).toBe(true); + vm.reset(); + expect(vm.hasChanges).toBe(true); + }); + + it('should observe changes', async () => { + const { vm } = mount({ + propsData: { url, model, formInitialData }, + }); + vm.state.set(model, formInitialData); + expect(vm.hasChanges).toBe(false); + + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + expect(vm.hasChanges).toBe(true); + vm.formData.mockKey = 'mockVal'; + }); + }); + + describe('trimData()', () => { + let vm; + beforeAll(() => { + vm = mount({}).vm; + }); + + it('should trim whitespace from string values', () => { + const data = { key1: ' value1 ', key2: ' value2 ' }; + const trimmedData = vm.trimData(data); + expect(trimmedData).toEqual({ key1: 'value1', key2: 'value2' }); + }); + + it('should not modify non-string values', () => { + const data = { key1: 123, key2: true, key3: null, key4: undefined }; + const trimmedData = vm.trimData(data); + expect(trimmedData).toEqual(data); + }); + }); + + describe('save()', async () => { + it('should not call if there are not changes', async () => { + const { vm } = mount({ propsData: { url, model } }); + + await vm.save(); + expect(vm.hasChanges).toBe(false); + }); + + it('should call axios.patch with the right data', async () => { + const spy = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} }); + const { vm } = mount({ propsData: { url, model, formInitialData } }); + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + expect(spy).toHaveBeenCalled(); + vm.formData.mockKey = 'mockVal'; + }); + + it('should call axios.post with the right data', async () => { + const spy = vi.spyOn(axios, 'post').mockResolvedValue({ data: {} }); + const { vm } = mount({ + propsData: { url, model, formInitialData, urlCreate: 'mockUrlCreate' }, + }); + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + expect(spy).toHaveBeenCalled(); + vm.formData.mockKey = 'mockVal'; + }); + + it('should use the saveFn', async () => { + const { vm } = mount({ + propsData: { url, model, formInitialData, saveFn: () => {} }, + }); + const spyPatch = vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} }); + const spySaveFn = vi.spyOn(vm.$props, 'saveFn'); + + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + expect(spyPatch).not.toHaveBeenCalled(); + expect(spySaveFn).toHaveBeenCalled(); + vm.formData.mockKey = 'mockVal'; + }); + + it('should reload the data after save', async () => { + const { vm } = mount({ + propsData: { url, model, formInitialData, reload: true }, + }); + vi.spyOn(axios, 'patch').mockResolvedValue({ data: {} }); + + vm.formData.mockKey = 'newVal'; + await vm.$nextTick(); + await vm.save(); + vm.formData.mockKey = 'mockVal'; + }); + }); +}); + +function mount({ propsData = {} }) { + return createWrapper(FormModel, { + propsData, + }); +} diff --git a/src/components/common/VnBtnSelect.vue b/src/components/common/VnBtnSelect.vue index b0616a6b2..3d96a55a6 100644 --- a/src/components/common/VnBtnSelect.vue +++ b/src/components/common/VnBtnSelect.vue @@ -14,6 +14,7 @@ defineProps({ hide-dropdown-icon focus-on-mount @update:model-value="promise" + data-cy="vnBtnSelect_select" /> </QBtnDropdown> </template> diff --git a/src/components/common/VnChangePassword.vue b/src/components/common/VnChangePassword.vue index 79784f3c5..d8374498f 100644 --- a/src/components/common/VnChangePassword.vue +++ b/src/components/common/VnChangePassword.vue @@ -2,9 +2,9 @@ import { ref } from 'vue'; import { useI18n } from 'vue-i18n'; import VnRow from '../ui/VnRow.vue'; -import VnInput from './VnInput.vue'; import FetchData from '../FetchData.vue'; import useNotify from 'src/composables/useNotify'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const props = defineProps({ submitFn: { type: Function, default: () => {} }, @@ -70,19 +70,19 @@ defineExpose({ show: () => changePassDialog.value.show() }); </QCardSection> <QForm ref="form"> <QCardSection> - <VnInput + <VnInputPassword v-if="props.askOldPass" :label="t('Old password')" v-model="passwords.oldPassword" - type="password" :required="true" + :toggle-visibility="true" autofocus /> - <VnInput + <VnInputPassword :label="t('New password')" v-model="passwords.newPassword" - type="password" :required="true" + :toggle-visibility="true" :info=" t('passwordRequirements', { length: requirements.length, @@ -95,10 +95,10 @@ defineExpose({ show: () => changePassDialog.value.show() }); autofocus /> - <VnInput + <VnInputPassword :label="t('Repeat password')" v-model="passwords.repeatPassword" - type="password" + :toggle-visibility="true" /> </QCardSection> </QForm> diff --git a/src/components/common/VnDateBadge.vue b/src/components/common/VnDateBadge.vue index fd6c9e8a4..83d39937a 100644 --- a/src/components/common/VnDateBadge.vue +++ b/src/components/common/VnDateBadge.vue @@ -11,9 +11,9 @@ function getBadgeAttrs(date) { let timeDiff = today - timeTicket; - if (timeDiff == 0) return { color: 'warning', 'text-color': 'black' }; - if (timeDiff < 0) return { color: 'success', 'text-color': 'black' }; - return { color: 'transparent', 'text-color': 'white' }; + if (timeDiff == 0) return { color: 'warning', class: 'black-text-color' }; + if (timeDiff < 0) return { color: 'success', class: 'black-text-color' }; + return { color: 'transparent', class: 'normal-text-color' }; } function formatShippedDate(date) { @@ -29,3 +29,11 @@ function formatShippedDate(date) { {{ formatShippedDate(date) }} </QBadge> </template> +<style lang="scss"> +.black-text-color { + color: var(--vn-black-text-color); +} +.normal-text-color { + color: var(--vn-text-color); +} +</style> diff --git a/src/components/common/VnDmsList.vue b/src/components/common/VnDmsList.vue index 52dd6ef79..ed3cadc6b 100644 --- a/src/components/common/VnDmsList.vue +++ b/src/components/common/VnDmsList.vue @@ -297,7 +297,7 @@ defineExpose({ ref="dmsRef" :data-key="$props.model" :url="$props.model" - :filter="dmsFilter" + :user-filter="dmsFilter" :order="['dmsFk DESC']" :auto-load="true" @on-fetch="setData" diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 57a495ac3..4c7445aab 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -45,6 +45,7 @@ const $props = defineProps({ }); const vnInputRef = ref(null); +const showPassword = ref(false); const value = computed({ get() { return $props.modelValue; @@ -134,20 +135,23 @@ const handleInsertMode = (e) => { hide-bottom-space :data-cy="$attrs.dataCy ?? $attrs.label + '_input'" > - <template v-if="$slots.prepend" #prepend> + <template #prepend> <slot name="prepend" /> </template> <template #append> <QIcon name="close" size="xs" - v-if=" - hover && - value && - !$attrs.disabled && - !$attrs.readonly && - $props.clearable - " + :style="{ + visibility: + hover && + value && + !$attrs.disabled && + !$attrs.readonly && + $props.clearable + ? 'visible' + : 'hidden', + }" @click=" () => { value = null; @@ -155,7 +159,7 @@ const handleInsertMode = (e) => { emit('remove'); } " - ></QIcon> + /> <slot name="append" v-if="$slots.append && !$attrs.disabled" /> <QIcon v-if="info" name="info"> <QTooltip max-width="350px"> @@ -166,18 +170,3 @@ const handleInsertMode = (e) => { </QInput> </div> </template> -<i18n> - en: - inputMin: Must be more than {value} - maxLength: The value exceeds {value} characters - inputMax: Must be less than {value} - es: - inputMin: Debe ser mayor a {value} - maxLength: El valor excede los {value} carácteres - inputMax: Debe ser menor a {value} -</i18n> -<style lang="scss"> -.q-field__append { - padding-inline: 0; -} -</style> diff --git a/src/components/common/VnInputDate.vue b/src/components/common/VnInputDate.vue index fdef6a9a8..952a843e3 100644 --- a/src/components/common/VnInputDate.vue +++ b/src/components/common/VnInputDate.vue @@ -1,14 +1,12 @@ <script setup> import { onMounted, watch, computed, ref, useAttrs } from 'vue'; import { date } from 'quasar'; -import { useI18n } from 'vue-i18n'; import VnDate from './VnDate.vue'; import { useRequired } from 'src/composables/useRequired'; const $attrs = useAttrs(); const { isRequired, requiredFieldRule } = useRequired($attrs); const model = defineModel({ type: [String, Date] }); -const { t } = useI18n(); const $props = defineProps({ isOutlined: { diff --git a/src/components/common/VnInputPassword.vue b/src/components/common/VnInputPassword.vue new file mode 100644 index 000000000..56981c0c3 --- /dev/null +++ b/src/components/common/VnInputPassword.vue @@ -0,0 +1,31 @@ +<script setup> +import VnInput from 'src/components/common/VnInput.vue'; +import { ref } from 'vue'; + +const model = defineModel({ type: [Number, String] }); +const $props = defineProps({ + toggleVisibility: { + type: Boolean, + default: false, + }, +}); + +const showPassword = ref(false); +</script> +<template> + <VnInput + v-bind="{ ...$attrs }" + v-model="model" + :type=" + $props.toggleVisibility ? (showPassword ? 'text' : 'password') : $attrs.type + " + > + <template #append v-if="toggleVisibility"> + <QIcon + :name="showPassword ? 'visibility_off' : 'visibility'" + class="cursor-pointer" + @click="showPassword = !showPassword" + /> + </template> + </VnInput> +</template> diff --git a/src/components/common/VnInputTime.vue b/src/components/common/VnInputTime.vue index b4b246618..4147f8976 100644 --- a/src/components/common/VnInputTime.vue +++ b/src/components/common/VnInputTime.vue @@ -1,13 +1,11 @@ <script setup> import { computed, ref, useAttrs } from 'vue'; -import { useI18n } from 'vue-i18n'; import { date } from 'quasar'; import VnTime from './VnTime.vue'; import { useRequired } from 'src/composables/useRequired'; const $attrs = useAttrs(); const { isRequired, requiredFieldRule } = useRequired($attrs); -const { t } = useI18n(); const model = defineModel({ type: String }); const props = defineProps({ timeOnly: { diff --git a/src/components/common/VnModule.vue b/src/components/common/VnModule.vue index 505b3a8b5..038ee1d60 100644 --- a/src/components/common/VnModule.vue +++ b/src/components/common/VnModule.vue @@ -20,16 +20,15 @@ const hasContent = ref(); let observer; onMounted(() => { - if (teleportRef.value) { - const checkContent = () => { - hasContent.value = teleportRef.value.innerHTML.trim() !== ''; - }; + if (!teleportRef.value) return; + const checkContent = () => { + hasContent.value = teleportRef.value?.innerHTML?.trim() !== ''; + }; - observer = new MutationObserver(checkContent); - observer.observe(teleportRef.value, { childList: true, subtree: true }); + observer = new MutationObserver(checkContent); + observer.observe(teleportRef.value, { childList: true, subtree: true }); - checkContent(); - } + checkContent(); }); </script> diff --git a/src/components/common/VnSection.vue b/src/components/common/VnSection.vue index e69e586b5..edd8d3dfa 100644 --- a/src/components/common/VnSection.vue +++ b/src/components/common/VnSection.vue @@ -4,11 +4,12 @@ import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnTableFilter from '../VnTable/VnTableFilter.vue'; import { onBeforeMount, computed } from 'vue'; import { useArrayData } from 'src/composables/useArrayData'; +import { useRoute } from 'vue-router'; const $props = defineProps({ section: { type: String, - required: true, + default: null, }, dataKey: { type: String, @@ -38,14 +39,28 @@ const $props = defineProps({ type: Boolean, default: true, }, + keepData: { + type: Boolean, + default: true, + }, }); -const sectionValue = computed(() => $props.section ?? $props.dataKey); +const route = useRoute(); let arrayData; +const sectionValue = computed(() => $props.section ?? $props.dataKey); +const isMainSection = computed(() => { + const isSame = sectionValue.value == route.name; + if (!isSame && arrayData) { + arrayData.reset(['userParams', 'userFilter']); + } + return isSame; +}); + onBeforeMount(() => { if ($props.dataKey) arrayData = useArrayData($props.dataKey, { searchUrl: 'table', + keepData: $props.keepData, ...$props.arrayDataProps, navigate: $props.redirect, }); @@ -74,6 +89,6 @@ onBeforeMount(() => { </slot> </template> </RightMenu> - <slot name="body" v-if="sectionValue == $route.name" /> + <slot name="body" v-if="isMainSection" /> <RouterView v-else /> </template> diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 8aa725b4a..ee94a1d81 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -113,8 +113,15 @@ const $props = defineProps({ }); const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])]; -const { optionLabel, optionValue, optionFilter, optionFilterValue, options, modelValue } = - toRefs($props); +const { + optionLabel, + optionValue, + optionCaption, + optionFilter, + optionFilterValue, + options, + modelValue, +} = toRefs($props); const myOptions = ref([]); const myOptionsOriginal = ref([]); const vnSelectRef = ref(); @@ -166,7 +173,11 @@ onMounted(() => { const arrayDataKey = $props.dataKey ?? ($props.url?.length > 0 ? $props.url : $attrs.name ?? $attrs.label); -const arrayData = useArrayData(arrayDataKey, { url: $props.url, searchUrl: false }); +const arrayData = useArrayData(arrayDataKey, { + url: $props.url, + searchUrl: false, + mapKey: $attrs['map-key'], +}); function findKeyInOptions() { if (!$props.options) return; @@ -194,10 +205,10 @@ function filter(val, options) { } if (!row) return; - const id = row[$props.optionValue]; + const id = String(row[$props.optionValue]); const optionLabel = String(row[$props.optionLabel]).toLowerCase(); - return id == search || optionLabel.includes(search); + return id.includes(search) || optionLabel.includes(search); }); } @@ -317,6 +328,11 @@ function handleKeyDown(event) { } } } + +function getCaption(opt) { + if (optionCaption.value === false) return; + return opt[optionCaption.value] || opt[optionValue.value]; +} </script> <template> @@ -387,8 +403,8 @@ function handleKeyDown(event) { <QItemLabel> {{ opt[optionLabel] }} </QItemLabel> - <QItemLabel caption v-if="optionCaption !== false"> - {{ `#${opt[optionCaption] || opt[optionValue]}` }} + <QItemLabel caption v-if="getCaption(opt)"> + {{ `#${getCaption(opt)}` }} </QItemLabel> </QItemSection> </QItem> diff --git a/src/components/common/VnSelectWorker.vue b/src/components/common/VnSelectWorker.vue index b0fef4443..9a8151a3d 100644 --- a/src/components/common/VnSelectWorker.vue +++ b/src/components/common/VnSelectWorker.vue @@ -51,6 +51,7 @@ const url = computed(() => { option-value="id" option-label="nickname" :fields="['id', 'name', 'nickname', 'code']" + :filter-options="['id', 'name', 'nickname', 'code']" sort-by="nickname ASC" > <template #prepend v-if="$props.hasAvatar"> @@ -71,7 +72,7 @@ const url = computed(() => { {{ scope.opt.nickname }} </QItemLabel> <QItemLabel caption v-else> - {{ scope.opt.nickname }}, {{ scope.opt.code }} + #{{ scope.opt.id }}, {{ scope.opt.nickname }}, {{ scope.opt.code }} </QItemLabel> </QItemSection> </QItem> diff --git a/src/components/common/__tests__/VnInputDate.spec.js b/src/components/common/__tests__/VnInputDate.spec.js new file mode 100644 index 000000000..21ca91e96 --- /dev/null +++ b/src/components/common/__tests__/VnInputDate.spec.js @@ -0,0 +1,72 @@ +import { createWrapper } from 'app/test/vitest/helper.js'; +import { describe, it, expect } from 'vitest'; +import VnInputDate from 'components/common/VnInputDate.vue'; + +let vm; +let wrapper; + +function generateWrapper(date, outlined, required) { + wrapper = createWrapper(VnInputDate, { + props: { + modelValue: date, + }, + attrs: { + isOutlined: outlined, + required: required + }, + }); + wrapper = wrapper.wrapper; + vm = wrapper.vm; +}; + +describe('VnInputDate', () => { + + describe('formattedDate', () => { + it('formats a valid date correctly', async () => { + generateWrapper('2023-12-25', false, false); + await vm.$nextTick(); + expect(vm.formattedDate).toBe('25/12/2023'); + }); + + it('updates the model value when a new date is set', async () => { + const input = wrapper.find('input'); + await input.setValue('31/12/2023'); + expect(wrapper.emitted()['update:modelValue']).toBeTruthy(); + expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z'); + }); + + it('should not update the model value when an invalid date is set', async () => { + const input = wrapper.find('input'); + await input.setValue('invalid-date'); + expect(wrapper.emitted()['update:modelValue'][0][0]).toBe('2023-12-31T00:00:00.000Z'); + }); + }); + + describe('styleAttrs', () => { + it('should return empty styleAttrs when isOutlined is false', async () => { + generateWrapper('2023-12-25', false, false); + await vm.$nextTick(); + expect(vm.styleAttrs).toEqual({}); + }); + + it('should set styleAttrs when isOutlined is true', async () => { + generateWrapper('2023-12-25', true, false); + await vm.$nextTick(); + expect(vm.styleAttrs.outlined).toBe(true); + }); + }); + + describe('required', () => { + it('should not applies required class when isRequired is false', async () => { + generateWrapper('2023-12-25', false, false); + await vm.$nextTick(); + expect(wrapper.find('.vn-input-date').classes()).not.toContain('required'); + }); + + it('should applies required class when isRequired is true', async () => { + generateWrapper('2023-12-25', false, true); + await vm.$nextTick(); + expect(wrapper.find('.vn-input-date').classes()).toContain('required'); + }); + }); +}); \ No newline at end of file diff --git a/src/components/common/__tests__/VnJsonValue.spec.js b/src/components/common/__tests__/VnJsonValue.spec.js new file mode 100644 index 000000000..393b39f3a --- /dev/null +++ b/src/components/common/__tests__/VnJsonValue.spec.js @@ -0,0 +1,95 @@ +import { describe, it, expect } from 'vitest'; +import VnJsonValue from 'src/components/common/VnJsonValue.vue'; +import { createWrapper } from 'app/test/vitest/helper'; + +const buildComponent = (props) => { + return createWrapper(VnJsonValue, { + props, + }).wrapper; +}; + +describe('VnJsonValue', () => { + it('renders null value correctly', async () => { + const wrapper = buildComponent({ value: null }); + const span = wrapper.find('span'); + expect(span.text()).toBe('∅'); + expect(span.classes()).toContain('json-null'); + }); + + it('renders boolean true correctly', async () => { + const wrapper = buildComponent({ value: true }); + const span = wrapper.find('span'); + expect(span.text()).toBe('✓'); + expect(span.classes()).toContain('json-true'); + }); + + it('renders boolean false correctly', async () => { + const wrapper = buildComponent({ value: false }); + const span = wrapper.find('span'); + expect(span.text()).toBe('✗'); + expect(span.classes()).toContain('json-false'); + }); + + it('renders a short string correctly', async () => { + const wrapper = buildComponent({ value: 'Hello' }); + const span = wrapper.find('span'); + expect(span.text()).toBe('Hello'); + expect(span.classes()).toContain('json-string'); + }); + + it('renders a long string correctly with ellipsis', async () => { + const longString = 'a'.repeat(600); + const wrapper = buildComponent({ value: longString }); + const span = wrapper.find('span'); + expect(span.text()).toContain('...'); + expect(span.text().length).toBeLessThanOrEqual(515); + expect(span.attributes('title')).toBe(longString); + expect(span.classes()).toContain('json-string'); + }); + + it('renders a number correctly', async () => { + const wrapper = buildComponent({ value: 123.4567 }); + const span = wrapper.find('span'); + expect(span.text()).toBe('123.457'); + expect(span.classes()).toContain('json-number'); + }); + + it('renders an integer correctly', async () => { + const wrapper = buildComponent({ value: 42 }); + const span = wrapper.find('span'); + expect(span.text()).toBe('42'); + expect(span.classes()).toContain('json-number'); + }); + + it('renders a date correctly', async () => { + const date = new Date('2023-01-01'); + const wrapper = buildComponent({ value: date }); + const span = wrapper.find('span'); + expect(span.text()).toBe('2023-01-01'); + expect(span.classes()).toContain('json-object'); + }); + + it('renders an object correctly', async () => { + const obj = { key: 'value' }; + const wrapper = buildComponent({ value: obj }); + const span = wrapper.find('span'); + expect(span.text()).toBe(obj.toString()); + expect(span.classes()).toContain('json-object'); + }); + + it('renders an array correctly', async () => { + const arr = [1, 2, 3]; + const wrapper = buildComponent({ value: arr }); + const span = wrapper.find('span'); + expect(span.text()).toBe(arr.toString()); + expect(span.classes()).toContain('json-object'); + }); + + it('updates value when prop changes', async () => { + const wrapper = buildComponent({ value: true }); + await wrapper.setProps({ value: 123 }); + const span = wrapper.find('span'); + expect(span.text()).toBe('123'); + expect(span.classes()).toContain('json-number'); + }); +}); diff --git a/src/components/common/__tests__/VnNotes.spec.js b/src/components/common/__tests__/VnNotes.spec.js new file mode 100644 index 000000000..8f24a7f14 --- /dev/null +++ b/src/components/common/__tests__/VnNotes.spec.js @@ -0,0 +1,107 @@ +import { describe, it, expect, vi, beforeAll, afterEach, beforeEach } from 'vitest'; +import { createWrapper, axios } from 'app/test/vitest/helper'; +import VnNotes from 'src/components/ui/VnNotes.vue'; + +describe('VnNotes', () => { + let vm; + let wrapper; + let spyFetch; + let postMock; + let expectedBody; + const mockData= {name: 'Tony', lastName: 'Stark', text: 'Test Note', observationTypeFk: 1}; + + function generateExpectedBody() { + expectedBody = {...vm.$props.body, ...{ text: vm.newNote.text, observationTypeFk: vm.newNote.observationTypeFk }}; + } + + async function setTestParams(text, observationType, type){ + vm.newNote.text = text; + vm.newNote.observationTypeFk = observationType; + wrapper.setProps({ selectType: type }); + } + + beforeAll(async () => { + vi.spyOn(axios, 'get').mockReturnValue({ data: [] }); + + wrapper = createWrapper(VnNotes, { + propsData: { + url: '/test', + body: { name: 'Tony', lastName: 'Stark' }, + } + }); + wrapper = wrapper.wrapper; + vm = wrapper.vm; + }); + + beforeEach(() => { + postMock = vi.spyOn(axios, 'post').mockResolvedValue(mockData); + spyFetch = vi.spyOn(vm.vnPaginateRef, 'fetch').mockImplementation(() => vi.fn()); + }); + + afterEach(() => { + vi.clearAllMocks(); + expectedBody = {}; + }); + + describe('insert', () => { + it('should not call axios.post and vnPaginateRef.fetch if newNote.text is null', async () => { + await setTestParams( null, null, true ); + + await vm.insert(); + + expect(postMock).not.toHaveBeenCalled(); + expect(spyFetch).not.toHaveBeenCalled(); + }); + + it('should not call axios.post and vnPaginateRef.fetch if newNote.text is empty', async () => { + await setTestParams( "", null, false ); + + await vm.insert(); + + expect(postMock).not.toHaveBeenCalled(); + expect(spyFetch).not.toHaveBeenCalled(); + }); + + it('should not call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is true', async () => { + await setTestParams( "Test Note", null, true ); + + await vm.insert(); + + expect(postMock).not.toHaveBeenCalled(); + expect(spyFetch).not.toHaveBeenCalled(); + }); + + it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is missing and selectType is false', async () => { + await setTestParams( "Test Note", null, false ); + + generateExpectedBody(); + + await vm.insert(); + + expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody); + expect(spyFetch).toHaveBeenCalled(); + }); + + it('should call axios.post and vnPaginateRef.fetch if observationTypeFk is setted and selectType is false', async () => { + await setTestParams( "Test Note", 1, false ); + + generateExpectedBody(); + + await vm.insert(); + + expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody); + expect(spyFetch).toHaveBeenCalled(); + }); + + it('should call axios.post and vnPaginateRef.fetch when newNote is valid', async () => { + await setTestParams( "Test Note", 1, true ); + + generateExpectedBody(); + + await vm.insert(); + + expect(postMock).toHaveBeenCalledWith(vm.$props.url, expectedBody); + expect(spyFetch).toHaveBeenCalled(); + }); + }); +}); \ No newline at end of file diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index f4c0091d2..cf217555a 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -6,6 +6,7 @@ import { useArrayData } from 'composables/useArrayData'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useState } from 'src/composables/useState'; import { useRoute } from 'vue-router'; +import VnMoreOptions from './VnMoreOptions.vue'; const $props = defineProps({ url: { @@ -47,7 +48,6 @@ let store; let entity; const isLoading = ref(false); const isSameDataKey = computed(() => $props.dataKey === route.meta.moduleName); -const menuRef = ref(); defineExpose({ getData }); onBeforeMount(async () => { @@ -159,25 +159,11 @@ const toModule = computed(() => </QTooltip> </QBtn> </RouterLink> - <QBtn - v-if="$slots.menu" - color="white" - dense - flat - icon="more_vert" - round - size="md" - data-cy="descriptor-more-opts" - > - <QTooltip> - {{ t('components.cardDescriptor.moreOptions') }} - </QTooltip> - <QMenu :ref="menuRef"> - <QList> - <slot name="menu" :entity="entity" :menu-ref="menuRef" /> - </QList> - </QMenu> - </QBtn> + <VnMoreOptions v-if="$slots.menu"> + <template #menu="{ menuRef }"> + <slot name="menu" :entity="entity" :menu-ref="menuRef" /> + </template> + </VnMoreOptions> </div> <slot name="before" /> <div class="body q-py-sm"> @@ -222,8 +208,8 @@ const toModule = computed(() => /> </template> -<style lang="scss" scoped> -:deep(.body) { +<style lang="scss"> +.body { background-color: var(--vn-section-color); .text-h5 { font-size: 20px; @@ -262,7 +248,9 @@ const toModule = computed(() => } } } +</style> +<style lang="scss" scoped> .title { overflow: hidden; text-overflow: ellipsis; diff --git a/src/components/ui/CardSummary.vue b/src/components/ui/CardSummary.vue index 8395dfd73..a1de3eee3 100644 --- a/src/components/ui/CardSummary.vue +++ b/src/components/ui/CardSummary.vue @@ -1,10 +1,11 @@ <script setup> -import { ref, computed, watch, onBeforeMount, onMounted } from 'vue'; +import { ref, computed, watch, onBeforeMount } from 'vue'; import { useRoute } from 'vue-router'; import SkeletonSummary from 'components/ui/SkeletonSummary.vue'; +import VnLv from 'src/components/ui/VnLv.vue'; import { useArrayData } from 'src/composables/useArrayData'; import { isDialogOpened } from 'src/filters'; -import { useStateStore } from 'src/stores/useStateStore'; +import VnMoreOptions from './VnMoreOptions.vue'; const props = defineProps({ url: { @@ -40,7 +41,6 @@ const { store } = arrayData; const entity = computed(() => (Array.isArray(store.data) ? store.data[0] : store.data)); const isLoading = ref(false); -const stateStore = useStateStore(); defineExpose({ entity, fetch, @@ -52,9 +52,6 @@ onBeforeMount(async () => { watch(props, async () => await fetch()); }); -onMounted(() => { - stateStore.rightDrawerChangeValue(false); -}); async function fetch() { store.url = props.url; store.filter = props.filter ?? {}; @@ -64,6 +61,7 @@ async function fetch() { isLoading.value = false; } </script> + <template> <div class="summary container"> <QCard class="cardSummary"> @@ -86,9 +84,14 @@ async function fetch() { <slot name="header" :entity="entity" dense> {{ entity.id + ' - ' + entity.name }} </slot> - <slot name="header-right" :entity="entity"> - <span></span> - </slot> + <span class="row no-wrap"> + <slot name="header-right" :entity="entity" /> + <VnMoreOptions v-if="$slots.menu && isDialogOpened()"> + <template #menu="{ menuRef }"> + <slot name="menu" :entity="entity" :menu-ref="menuRef" /> + </template> + </VnMoreOptions> + </span> </div> <div class="summaryBody row q-mb-md"> <slot name="body" :entity="entity" /> @@ -97,6 +100,7 @@ async function fetch() { </QCard> </div> </template> + <style lang="scss"> .summary.container { display: flex; diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 2be508f9f..aba797678 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -190,7 +190,7 @@ const getLocale = (label) => { const globalLocale = `globals.params.${param}`; if (te(globalLocale)) return t(globalLocale); else if (te(t(`params.${param}`))); - else return t(`${route.meta.moduleName}.params.${param}`); + else return t(`${route.meta.moduleName.toLowerCase()}.params.${param}`); }; </script> @@ -202,7 +202,11 @@ const getLocale = (label) => { style="position: fixed; z-index: 1; right: 0; bottom: 0" icon="search" @click="search()" - ></QBtn> + > + <QTooltip bottom anchor="bottom right"> + {{ t('globals.search') }} + </QTooltip> + </QBtn> <QForm @submit="search" id="filterPanelForm" @keyup.enter="search()"> <QList dense> <QItem class="q-mt-xs"> diff --git a/src/components/ui/VnLinkPhone.vue b/src/components/ui/VnLinkPhone.vue index c5d5df394..a9e9bc0fc 100644 --- a/src/components/ui/VnLinkPhone.vue +++ b/src/components/ui/VnLinkPhone.vue @@ -30,7 +30,7 @@ onBeforeMount(async () => { .data; if (!channel) channel = defaultChannel; - phone.value = await parsePhone(props.phoneNumber, props.country.toLowerCase()); + phone.value = await parsePhone(props.phoneNumber, props.country?.toLowerCase()); config[ type ].url = `${url}?customerIdentity=%2B${phone.value}&channelId=${channel}`; diff --git a/src/components/ui/VnMoreOptions.vue b/src/components/ui/VnMoreOptions.vue new file mode 100644 index 000000000..39e84be2b --- /dev/null +++ b/src/components/ui/VnMoreOptions.vue @@ -0,0 +1,20 @@ +<template> + <QBtn + color="white" + dense + flat + icon="more_vert" + round + size="md" + data-cy="descriptor-more-opts" + > + <QTooltip> + {{ $t('components.cardDescriptor.moreOptions') }} + </QTooltip> + <QMenu ref="menuRef"> + <QList> + <slot name="menu" :menu-ref="$refs.menuRef" /> + </QList> + </QMenu> + </QBtn> +</template> diff --git a/src/components/ui/VnNotes.vue b/src/components/ui/VnNotes.vue index e308ea9bb..1690a94ba 100644 --- a/src/components/ui/VnNotes.vue +++ b/src/components/ui/VnNotes.vue @@ -110,7 +110,7 @@ onBeforeRouteLeave((to, from, next) => { :url="$props.url" order="created DESC" :limit="0" - :filter="$props.filter" + :user-filter="$props.filter" auto-load ref="vnPaginateRef" class="show" diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index a2ccd5d92..0111366f5 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -111,6 +111,7 @@ onMounted(async () => { }); onBeforeUnmount(() => { + if (!store.keepData) arrayData.reset(['data']); arrayData.resetPagination(); }); diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 4e284d8e4..bfaa76588 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -1,14 +1,16 @@ <script setup> -import { onMounted, ref, watch } from 'vue'; +import { onMounted, ref, computed, watch } from 'vue'; import { useQuasar } from 'quasar'; import { useArrayData } from 'composables/useArrayData'; import VnInput from 'src/components/common/VnInput.vue'; import { useI18n } from 'vue-i18n'; import { useStateStore } from 'src/stores/useStateStore'; +import { useRoute } from 'vue-router'; const quasar = useQuasar(); const { t } = useI18n(); const state = useStateStore(); +const route = useRoute(); const props = defineProps({ dataKey: { @@ -83,6 +85,17 @@ if (props.redirect) }; let arrayData = useArrayData(props.dataKey, arrayDataProps); let store = arrayData.store; +const to = computed(() => { + const url = { path: route.path, query: { ...(route.query ?? {}) } }; + const searchUrl = arrayData.store.searchUrl; + const currentFilter = { + ...arrayData.store.currentFilter, + search: searchText.value || undefined, + }; + + if (searchUrl) url.query[searchUrl] = JSON.stringify(currentFilter); + return url; +}); watch( () => props.dataKey, @@ -126,28 +139,38 @@ async function search() { delete filter.params.search; } await arrayData.applyFilter(filter); + searchText.value = undefined; } </script> <template> <Teleport to="#searchbar" v-if="state.isHeaderMounted()"> <QForm @submit="search" id="searchbarForm"> + <RouterLink + :to="to" + @click=" + !$event.shiftKey && !$event.ctrlKey && search(); + $refs.input.focus(); + " + > + <QIcon + v-if="!quasar.platform.is.mobile" + class="cursor-pointer" + name="search" + size="sm" + > + <QTooltip>{{ t('link') }}</QTooltip> + </QIcon> + </RouterLink> <VnInput id="searchbar" + ref="input" v-model.trim="searchText" :placeholder="t(props.label)" dense - standout autofocus - data-cy="vnSearchBar" + data-cy="vn-searchbar" + borderless > - <template #prepend> - <QIcon - v-if="!quasar.platform.is.mobile" - class="cursor-pointer" - name="search" - @click="search" - /> - </template> <template #append> <QIcon v-if="props.info && $q.screen.gt.xs" @@ -172,20 +195,52 @@ async function search() { .q-field { transition: width 0.36s; } -</style> -<style lang="scss"> +:deep(.q-field__native) { + padding-top: 10px; + padding-left: 5px; +} + +:deep(.q-field--dark .q-field__native:focus) { + color: black; +} + +:deep(.q-field--focused) { + .q-icon { + color: black; + } +} + .cursor-info { cursor: help; } -#searchbar { - .q-field--standout.q-field--highlighted .q-field__control { + +.q-form { + display: flex; + align-items: center; + border-radius: 4px; + padding: 0 5px; + background-color: var(--vn-search-color); + + &:hover { + background-color: var(--vn-search-color-hover); + } + &:focus-within { background-color: white; - color: black; - .q-field__native, + .q-icon { - color: black !important; + color: black; } } } + +.q-icon { + color: var(--vn-label-color); +} </style> +<i18n> +en: + link: click to search, ctrl + click to open in a new tab, shift + click to open in a new window +es: + link: clic para buscar, ctrl + clic para abrir en una nueva pestaña, shift + clic para abrir en una nueva ventana +</i18n> diff --git a/src/components/ui/VnSms.vue b/src/components/ui/VnSms.vue index bf6e0695e..8b25ba5da 100644 --- a/src/components/ui/VnSms.vue +++ b/src/components/ui/VnSms.vue @@ -54,6 +54,7 @@ function formatNumber(number) { :offset="100" :limit="5" auto-load + map-key="smsFk" > <template #body="{ rows }"> <QCard diff --git a/src/components/ui/__tests__/FetchedTags.spec.js b/src/components/ui/__tests__/FetchedTags.spec.js new file mode 100644 index 000000000..3c658a80e --- /dev/null +++ b/src/components/ui/__tests__/FetchedTags.spec.js @@ -0,0 +1,81 @@ +import { describe, expect, it } from 'vitest'; +import { createWrapper } from 'app/test/vitest/helper'; +import FetchedTags from 'src/components/ui/FetchedTags.vue'; + +describe('tags computed property', () => { + it('returns an object with the correct keys and values', () => { + const vm = createWrapper(FetchedTags, { + props: { + item: { + tag1: 'JavaScript', + value1: 'Programming Language', + tag2: 'Vue', + value2: 'Framework', + tag3: 'EmptyTag', + }, + tag: 'tag', + value: 'value', + columns: 2, + }, + }).vm; + expect(vm.tags).toEqual({ + JavaScript: 'Programming Language', + Vue: 'Framework', + EmptyTag: '', + }); + }); + + it('returns an empty object if the item prop is an empty object', () => { + const vm = createWrapper(FetchedTags, { + props: { + item: {}, + tag: 'tag', + value: 'value', + }, + }).vm; + expect(vm.tags).toEqual({}); + }); + + it('should calculate the correct columnStyle when columns prop is defined', () => { + const vm = createWrapper(FetchedTags, { + props: { + item: { + tag1: 'JavaScript', + value1: 'Programming Language', + tag2: 'Vue', + value2: 'Framework', + tag3: 'EmptyTag', + }, + tag: 'tag', + value: 'value', + columns: 2, + }, + }).vm; + + const expectedStyle = { + 'grid-template-columns': 'repeat(2, 1fr)', + 'max-width': '8rem', + }; + + expect(vm.columnStyle).toEqual(expectedStyle); + }); + + it('should return an empty object for columnStyle when columns prop is not defined', () => { + const vm = createWrapper(FetchedTags, { + props: { + item: { + tag1: 'JavaScript', + value1: 'Programming Language', + tag2: 'Vue', + value2: 'Framework', + tag3: 'EmptyTag', + }, + tag: 'tag', + value: 'value', + columns: null, + }, + }).vm; + + expect(vm.columnStyle).toEqual({}); + }); +}); diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 1a91cc50b..c13c4f9a6 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -53,6 +53,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { 'searchUrl', 'navigate', 'mapKey', + 'keepData', ]; if (typeof userOptions === 'object') { for (const option in userOptions) { @@ -75,26 +76,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { cancelRequest(); canceller = new AbortController(); - - const filter = { - limit: store.limit, - }; - let userParams = { ...store.userParams }; - - Object.assign(filter, store.userFilter); - - let where; - if (filter?.where || store.filter?.where) - where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {}); - Object.assign(filter, store.filter); - filter.where = where; - const params = { filter }; - - Object.assign(params, userParams); - if (params.filter) params.filter.skip = store.skip; - if (store?.order && typeof store?.order == 'string') store.order = [store.order]; - if (store.order?.length) params.filter.order = [...store.order]; - else delete params.filter.order; + const { params, limit } = getCurrentFilter(); store.currentFilter = JSON.parse(JSON.stringify(params)); delete store.currentFilter.filter.include; @@ -120,15 +102,16 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { params, }); - const { limit } = filter; store.hasMoreData = limit && response.data.length >= limit; - processData(response.data, { map: !!store.mapKey, append }); - if (!append && !isDialogOpened()) updateRouter && updateStateParams(); - + if (!append && !isDialogOpened() && updateRouter) { + if (updateStateParams(response.data)?.redirect) return; + } store.isLoading = false; canceller = null; + processData(response.data, { map: !!store.mapKey, append }); + return response; } @@ -258,7 +241,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { if (Object.values(store.userParams).length) await fetch({}); } - function updateStateParams() { + function updateStateParams(data) { if (!route?.path) return; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; if (store?.searchUrl) @@ -275,21 +258,46 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { const { path } = matches.at(-1); const to = - store?.data?.length === 1 - ? path.replace(/\/(list|:id)|-list/, `/${store.data[0].id}`) + data?.length === 1 + ? path.replace(/\/(list|:id)|-list/, `/${data[0].id}`) : path.replace(/:id.*/, ''); if (route.path != to) { const pushUrl = { path: to }; if (to.endsWith('/list') || to.endsWith('/')) pushUrl.query = newUrl.query; - return router.push(pushUrl); + return router.push(pushUrl) && { redirect: true }; } } router.replace(newUrl); } + function getCurrentFilter() { + const filter = { + limit: store.limit, + }; + + let userParams = { ...store.userParams }; + + Object.assign(filter, store.userFilter); + + let where; + if (filter?.where || store.filter?.where) + where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {}); + Object.assign(filter, store.filter); + filter.where = where; + const params = { filter }; + + Object.assign(params, userParams); + if (params.filter) params.filter.skip = store.skip; + if (store?.order && typeof store?.order == 'string') store.order = [store.order]; + if (store.order?.length) params.filter.order = [...store.order]; + else delete params.filter.order; + + return { filter, params, limit: filter.limit }; + } + function processData(data, { map = true, append = true }) { if (!append) { store.data = []; @@ -302,7 +310,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { for (const row of data) { const key = row[store.mapKey]; const val = { ...row, key }; - if (store.map.has(key)) { + if (key && store.map.has(key)) { const { position } = store.map.get(key); val.position = position; store.map.set(key, val); @@ -322,6 +330,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { fetch, applyFilter, addFilter, + getCurrentFilter, addFilterWhere, addOrder, deleteOrder, diff --git a/src/composables/useHasAccount.js b/src/composables/useHasAccount.js new file mode 100644 index 000000000..1014bedf3 --- /dev/null +++ b/src/composables/useHasAccount.js @@ -0,0 +1,6 @@ +import axios from 'axios'; + +export default async (id) => { + const { data } = await axios.get(`Accounts/${id}/exists`); + return data.exists; +}; diff --git a/src/css/app.scss b/src/css/app.scss index e87b37154..d4790a6b8 100644 --- a/src/css/app.scss +++ b/src/css/app.scss @@ -3,20 +3,23 @@ @import '@quasar/quasar-ui-qcalendar/src/QCalendarMonth.sass'; body.body--light { - --font-color: black; --vn-header-color: #cecece; --vn-page-color: #ffffff; --vn-section-color: #e0e0e0; --vn-section-hover-color: #b9b9b9; - --vn-text-color: var(--font-color); + --vn-text-color: black; --vn-label-color: #5f5f5f; --vn-accent-color: #e7e3e3; + --vn-search-color: #d4d4d4; + --vn-search-color-hover: #cfcfcf; --vn-empty-tag: #acacac; + --vn-black-text-color: black; + --vn-text-color-contrast: white; background-color: var(--vn-page-color); .q-header .q-toolbar { - color: var(--font-color); + color: var(--vn-text-color); } } body.body--dark { @@ -27,7 +30,11 @@ body.body--dark { --vn-text-color: white; --vn-label-color: #a8a8a8; --vn-accent-color: #424242; + --vn-search-color: #4b4b4b; + --vn-search-color-hover: #5b5b5b; --vn-empty-tag: #2d2d2d; + --vn-black-text-color: black; + --vn-text-color-contrast: black; background-color: var(--vn-page-color); } @@ -86,6 +93,10 @@ select:-webkit-autofill { background-color: var(--vn-section-hover-color); } +.bg-vn-page { + background-color: var(--vn-page-color); +} + .color-vn-label { color: var(--vn-label-color); } @@ -151,7 +162,8 @@ select:-webkit-autofill { .q-card, .q-table, .q-table__bottom, -.q-drawer { +.q-drawer, +.bottomButton { background-color: var(--vn-section-color); } @@ -188,7 +200,7 @@ select:-webkit-autofill { .q-tooltip { background-color: var(--vn-page-color); - color: var(--font-color); + color: var(--vn-text-color); font-size: medium; } diff --git a/src/filters/toDateHourMin.js b/src/filters/toDateHourMin.js index 2b6995c01..c813840cb 100644 --- a/src/filters/toDateHourMin.js +++ b/src/filters/toDateHourMin.js @@ -1,5 +1,6 @@ export default function toDateHourMin(date) { - const dateHour = new Date(date).toLocaleDateString('es-ES', { + if (!date) return date; + return new Date(date).toLocaleDateString('es-ES', { timeZone: 'Europe/Madrid', year: 'numeric', month: '2-digit', @@ -7,5 +8,4 @@ export default function toDateHourMin(date) { hour: '2-digit', minute: '2-digit', }); - return dateHour; } diff --git a/src/filters/toDateHourMinSec.js b/src/filters/toDateHourMinSec.js index cfc9506fb..51df725e4 100644 --- a/src/filters/toDateHourMinSec.js +++ b/src/filters/toDateHourMinSec.js @@ -1,5 +1,6 @@ export default function toDateHourMinSec(date) { - const dateHour = new Date(date).toLocaleDateString('es-ES', { + if (!date) return date; + return new Date(date).toLocaleDateString('es-ES', { timeZone: 'Europe/Madrid', year: 'numeric', month: '2-digit', @@ -8,5 +9,4 @@ export default function toDateHourMinSec(date) { minute: '2-digit', second: '2-digit', }); - return dateHour; } diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index 4a78811e6..bf001c9ba 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -455,7 +455,26 @@ entry: packingOut: Package out landing: Landing isExcludedFromAvailable: Es inventory + params: + toShipped: To + fromShipped: From + warehouseiNFk: Warehouse + daysOnward: Days onward + daysAgo: Days ago + warehouseInFk: Warehouse in ticket: + params: + ticketFk: Ticket ID + weekDay: Weekday + agencyModeFk: Agency + id: Worker + state: State + created: Created + externalId: External ID + counter: Counter + freightItemName: Freight item name + packageItemName: Package item name + longName: Long name card: customerId: Customer ID customerCard: Customer card @@ -506,6 +525,7 @@ invoiceOut: card: issued: Issued customerCard: Customer card + ticketList: Ticket List summary: issued: Issued dued: Due @@ -611,7 +631,7 @@ worker: fi: DNI/NIE/NIF birth: Birth isFreelance: Freelance - isSsDiscounted: Bonificación SS + isSsDiscounted: SS Bonification hasMachineryAuthorized: Machinery authorized isDisable: Disable notificationsManager: @@ -697,6 +717,11 @@ wagon: minHeightBetweenTrays: 'The minimum height between trays is ' maxWagonHeight: 'The maximum height of the wagon is ' uncompleteTrays: There are incomplete trays + params: + label: Label + plate: Plate + volume: Volume + name: Name supplier: list: @@ -857,11 +882,11 @@ components: value: Value # ItemFixedPriceFilter buyerFk: Buyer + warehouseFk: Warehouse started: From ended: To mine: For me hasMinPrice: Minimum price - warehouseFk: Warehouse # LatestBuysFilter salesPersonFk: Buyer from: From diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 2bfe7ec4b..2c95f936c 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -456,7 +456,25 @@ entry: packingOut: Embalaje envíos landing: Llegada isExcludedFromAvailable: Es inventario + params: + toShipped: Hasta + fromShipped: Desde + warehouseInFk: Alm. entrada + daysOnward: Días adelante + daysAgo: Días atras ticket: + params: + ticketFk: ID de ticket + weekDay: Salida + agencyModeFk: Agencia + id: Comercial + created: Creado + state: Estado + externalId: ID externo + counter: Contador + freightItemName: Nombre + packageItemName: Embalaje + longName: Descripción card: customerId: ID cliente customerCard: Ficha del cliente @@ -608,6 +626,15 @@ worker: role: Rol sipExtension: Extensión locker: Taquilla + fiDueDate: F. caducidad DNI + sex: Sexo + seniority: Antigüedad + fi: DNI/NIE/NIF + birth: F. nacimiento + isFreelance: Autónomo + isSsDiscounted: Bonificación SS + hasMachineryAuthorized: Autorizado para maquinaria + isDisable: Deshabilitado notificationsManager: activeNotifications: Notificaciones activas availableNotifications: Notificaciones disponibles @@ -691,6 +718,11 @@ wagon: minHeightBetweenTrays: 'La distancia mínima entre bandejas es ' maxWagonHeight: 'La altura máxima del vagón es ' uncompleteTrays: Hay bandejas sin completar + params: + label: Etiqueta + plate: Matrícula + volume: Volumen + name: Nombre supplier: list: payMethod: Método de pago @@ -849,6 +881,7 @@ components: value: Valor # ItemFixedPriceFilter buyerFk: Comprador + warehouseFk: Almacen started: Desde ended: Hasta mine: Para mi diff --git a/src/pages/Account/AccountCreate.vue b/src/pages/Account/AccountCreate.vue index 6b7c049c8..b925ff06a 100644 --- a/src/pages/Account/AccountCreate.vue +++ b/src/pages/Account/AccountCreate.vue @@ -6,6 +6,7 @@ import FormModelPopup from 'components/FormModelPopup.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import FetchData from 'components/FetchData.vue'; import VnInput from 'src/components/common/VnInput.vue'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const { t } = useI18n(); const router = useRouter(); @@ -61,10 +62,10 @@ const redirectToAccountBasicData = (_, { id }) => { hide-selected :rules="validate('VnUser.roleFk')" /> - <VnInput + <VnInputPassword v-model="data.password" :label="t('ldap.password')" - type="password" + :toggle-visibility="true" :rules="validate('VnUser.password')" /> <QCheckbox diff --git a/src/pages/Account/AccountLdap.vue b/src/pages/Account/AccountLdap.vue index bb220aa2e..4710f961b 100644 --- a/src/pages/Account/AccountLdap.vue +++ b/src/pages/Account/AccountLdap.vue @@ -8,6 +8,7 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import { useArrayData } from 'src/composables/useArrayData'; import useNotify from 'src/composables/useNotify.js'; import axios from 'axios'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const { t } = useI18n(); const { notify } = useNotify(); @@ -128,10 +129,9 @@ onMounted(async () => await getInitialLdapConfig()); :required="true" :rules="validate('LdapConfig.rdn')" /> - <VnInput + <VnInputPassword :label="t('ldap.password')" clearable - type="password" v-model="data.password" :required="true" :rules="validate('LdapConfig.password')" diff --git a/src/pages/Account/AccountList.vue b/src/pages/Account/AccountList.vue index c1c75fcee..ea8daba0d 100644 --- a/src/pages/Account/AccountList.vue +++ b/src/pages/Account/AccountList.vue @@ -4,9 +4,9 @@ import { computed, ref } from 'vue'; import VnTable from 'components/VnTable/VnTable.vue'; import AccountSummary from './Card/AccountSummary.vue'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; -import VnInput from 'src/components/common/VnInput.vue'; import VnSection from 'src/components/common/VnSection.vue'; import FetchData from 'src/components/FetchData.vue'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const { t } = useI18n(); const { viewSummary } = useSummaryDialog(); @@ -168,10 +168,9 @@ function exprBuilder(param, value) { > <template #more-create-dialog="{ data }"> <QCardSection> - <VnInput + <VnInputPassword :label="t('Password')" v-model="data.password" - type="password" :required="true" autocomplete="new-password" /> diff --git a/src/pages/Account/AccountSamba.vue b/src/pages/Account/AccountSamba.vue index 699a638eb..7b36de85f 100644 --- a/src/pages/Account/AccountSamba.vue +++ b/src/pages/Account/AccountSamba.vue @@ -8,6 +8,7 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import { useArrayData } from 'src/composables/useArrayData'; import useNotify from 'src/composables/useNotify.js'; import axios from 'axios'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const { t } = useI18n(); const { notify } = useNotify(); @@ -143,10 +144,9 @@ onMounted(async () => await getInitialSambaConfig()); v-model="data.adUser" :rules="validate('SambaConfigs.adUser')" /> - <VnInput + <VnInputPassword :label="t('samba.passwordAD')" clearable - type="password" v-model="data.adPassword" /> <VnInput diff --git a/src/pages/Account/Card/AccountDescriptor.vue b/src/pages/Account/Card/AccountDescriptor.vue index 4e10e1366..4e5328de6 100644 --- a/src/pages/Account/Card/AccountDescriptor.vue +++ b/src/pages/Account/Card/AccountDescriptor.vue @@ -1,13 +1,13 @@ <script setup> -import { ref, computed } from 'vue'; +import { ref, computed, onMounted } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import CardDescriptor from 'components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import useCardDescription from 'src/composables/useCardDescription'; import AccountDescriptorMenu from './AccountDescriptorMenu.vue'; -import FetchData from 'src/components/FetchData.vue'; import VnImg from 'src/components/ui/VnImg.vue'; +import useHasAccount from 'src/composables/useHasAccount.js'; const $props = defineProps({ id: { @@ -23,6 +23,7 @@ const entityId = computed(() => { return $props.id || route.params.id; }); const data = ref(useCardDescription()); +const hasAccount = ref(); const setData = (entity) => (data.value = useCardDescription(entity.nickname, entity.id)); const filter = { @@ -30,18 +31,16 @@ const filter = { fields: ['id', 'nickname', 'name', 'role'], include: { relation: 'role', scope: { fields: ['id', 'name'] } }, }; -const hasAccount = ref(false); + +onMounted(async () => { + hasAccount.value = await useHasAccount(entityId.value); +}); </script> <template> - <FetchData - :url="`Accounts/${entityId}/exists`" - auto-load - @on-fetch="(data) => (hasAccount = data.exists)" - /> <CardDescriptor ref="descriptor" - url="VnUsers/preview" + :url="`VnUsers/preview`" :filter="filter" module="Account" @on-fetch="setData" @@ -50,10 +49,9 @@ const hasAccount = ref(false); :subtitle="data.subtitle" > <template #menu> - <AccountDescriptorMenu :has-account="hasAccount" /> + <AccountDescriptorMenu :entity-id="entityId" /> </template> <template #before> - <!-- falla id :id="entityId.value" collection="user" size="160x160" --> <VnImg :id="entityId" collection="user" resolution="520x520" class="photo"> <template #error> <div @@ -91,7 +89,7 @@ const hasAccount = ref(false); <QIcon color="primary" name="contact_mail" - v-if="entity.hasAccount" + v-if="hasAccount" flat round size="sm" diff --git a/src/pages/Account/Card/AccountDescriptorMenu.vue b/src/pages/Account/Card/AccountDescriptorMenu.vue index 1780b4247..aa49dabe8 100644 --- a/src/pages/Account/Card/AccountDescriptorMenu.vue +++ b/src/pages/Account/Card/AccountDescriptorMenu.vue @@ -1,36 +1,37 @@ <script setup> import axios from 'axios'; -import { computed, ref, toRefs } from 'vue'; +import { computed, onMounted, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useVnConfirm } from 'composables/useVnConfirm'; -import { useRoute } from 'vue-router'; import { useAcl } from 'src/composables/useAcl'; import { useArrayData } from 'src/composables/useArrayData'; import VnConfirm from 'src/components/ui/VnConfirm.vue'; import VnChangePassword from 'src/components/common/VnChangePassword.vue'; -import { useQuasar } from 'quasar'; +import useNotify from 'src/composables/useNotify.js'; +import useHasAccount from 'src/composables/useHasAccount.js'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const $props = defineProps({ - hasAccount: { - type: Boolean, - default: false, + entityId: { + type: Number, required: true, }, }); + const { t } = useI18n(); -const { hasAccount } = toRefs($props); const { openConfirmationModal } = useVnConfirm(); -const route = useRoute(); -const { notify } = useQuasar(); +const { notify } = useNotify(); const account = computed(() => useArrayData('AccountId').store.data[0]); -account.value.hasAccount = hasAccount.value; -const entityId = computed(() => +route.params.id); + +onMounted(async () => { + account.value.hasAccount = await useHasAccount($props.entityId); +}); async function updateStatusAccount(active) { if (active) { - await axios.post(`Accounts`, { id: entityId.value }); + await axios.post(`Accounts`, { id: $props.entityId }); } else { - await axios.delete(`Accounts/${entityId.value}`); + await axios.delete(`Accounts/${$props.entityId}`); } account.value.hasAccount = active; @@ -41,7 +42,7 @@ async function updateStatusAccount(active) { }); } async function updateStatusUser(active) { - await axios.patch(`VnUsers/${entityId.value}`, { active }); + await axios.patch(`VnUsers/${$props.entityId}`, { active }); account.value.active = active; const status = active ? 'activate' : 'deactivate'; notify({ @@ -97,7 +98,7 @@ async function sync() { <QTooltip>{{ t('account.card.actions.sync.tooltip') }}</QTooltip> </QIcon></QCheckbox > - <QInput + <VnInputPassword v-if="shouldSyncPassword" :label="t('login.password')" v-model="syncPassword" diff --git a/src/pages/Account/Card/AccountMailAlias.vue b/src/pages/Account/Card/AccountMailAlias.vue index 8d3bd3b67..efd2b481b 100644 --- a/src/pages/Account/Card/AccountMailAlias.vue +++ b/src/pages/Account/Card/AccountMailAlias.vue @@ -9,6 +9,7 @@ import AccountMailAliasCreateForm from './AccountMailAliasCreateForm.vue'; import { useVnConfirm } from 'composables/useVnConfirm'; import { useArrayData } from 'composables/useArrayData'; import useNotify from 'src/composables/useNotify.js'; +import useHasAccount from 'src/composables/useHasAccount.js'; import axios from 'axios'; const { t } = useI18n(); @@ -50,16 +51,6 @@ const columns = computed(() => [ }, ]); -const fetchAccountExistence = async () => { - try { - const { data } = await axios.get(`Accounts/${route.params.id}/exists`); - return data.exists; - } catch (error) { - console.error('Error fetching account existence', error); - return false; - } -}; - const deleteMailAlias = async (row) => { await axios.delete(`${urlPath}/${row.id}`); fetchMailAliases(); @@ -79,7 +70,7 @@ const fetchMailAliases = async () => { const getAccountData = async (reload = true) => { loading.value = true; - hasAccount.value = await fetchAccountExistence(); + hasAccount.value = await useHasAccount(route.params.id); if (!hasAccount.value) { loading.value = false; store.data = []; diff --git a/src/pages/Account/Card/AccountMailForwarding.vue b/src/pages/Account/Card/AccountMailForwarding.vue index 30849d44a..0e5ae3122 100644 --- a/src/pages/Account/Card/AccountMailForwarding.vue +++ b/src/pages/Account/Card/AccountMailForwarding.vue @@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue'; import axios from 'axios'; import { useStateStore } from 'stores/useStateStore'; import useNotify from 'src/composables/useNotify.js'; +import useHasAccount from 'src/composables/useHasAccount'; const { t } = useI18n(); const route = useRoute(); @@ -30,23 +31,9 @@ const hasDataChanged = computed( initialData.value.hasData !== hasData.value ); -const fetchAccountExistence = async () => { - try { - const { data } = await axios.get(`Accounts/${route.params.id}/exists`); - return data.exists; - } catch (error) { - console.error('Error fetching account existence', error); - return false; - } -}; - const fetchMailForwards = async () => { - try { - const response = await axios.get(`MailForwards/${route.params.id}`); - return response.data; - } catch { - return null; - } + const response = await axios.get(`MailForwards/${route.params.id}`); + return response.data; }; const deleteMailForward = async () => { @@ -72,7 +59,7 @@ const setInitialData = async () => { loading.value = true; initialData.value.account = route.params.id; formData.value.account = route.params.id; - hasAccount.value = await fetchAccountExistence(route.params.id); + hasAccount.value = await useHasAccount(route.params.id); if (!hasAccount.value) { loading.value = false; return; diff --git a/src/pages/Account/Card/AccountSummary.vue b/src/pages/Account/Card/AccountSummary.vue index e6c21ed34..ca17c7975 100644 --- a/src/pages/Account/Card/AccountSummary.vue +++ b/src/pages/Account/Card/AccountSummary.vue @@ -7,6 +7,7 @@ import CardSummary from 'components/ui/CardSummary.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import { useArrayData } from 'src/composables/useArrayData'; +import AccountDescriptorMenu from './AccountDescriptorMenu.vue'; const route = useRoute(); const { t } = useI18n(); @@ -31,12 +32,14 @@ const filter = { <template> <CardSummary data-key="AccountId" - ref="AccountSummary" url="VnUsers/preview" :filter="filter" @on-fetch="(data) => (account = data)" > <template #header>{{ account.id }} - {{ account.nickname }}</template> + <template #menu=""> + <AccountDescriptorMenu :entity-id="entityId" /> + </template> <template #body> <QCard class="vn-one"> <QCardSection class="q-pa-none"> diff --git a/src/pages/Account/Role/Card/RoleDescriptor.vue b/src/pages/Account/Role/Card/RoleDescriptor.vue index b4b4fe316..0a555346d 100644 --- a/src/pages/Account/Role/Card/RoleDescriptor.vue +++ b/src/pages/Account/Role/Card/RoleDescriptor.vue @@ -50,7 +50,7 @@ const removeRole = async () => { > <template #menu> <QItem v-ripple clickable @click="removeRole()"> - <QItemSection>{{ t('Delete') }}</QItemSection> + <QItemSection>{{ t('globals.delete') }}</QItemSection> </QItem> </template> <template #body="{ entity }"> diff --git a/src/pages/Account/locale/en.yml b/src/pages/Account/locale/en.yml index 88a6b11e9..1826250fd 100644 --- a/src/pages/Account/locale/en.yml +++ b/src/pages/Account/locale/en.yml @@ -1,4 +1,18 @@ account: + params: + id: Id + name: Name + roleFk: Role + nickname: Nickname + password: Password + active: Active + search: Id + description: Description + alias: Alias + model: Model + principalId: Role + property: Property + accessType: Access card: nickname: User role: Role diff --git a/src/pages/Account/locale/es.yml b/src/pages/Account/locale/es.yml index ba559f2c3..941a9948f 100644 --- a/src/pages/Account/locale/es.yml +++ b/src/pages/Account/locale/es.yml @@ -1,4 +1,20 @@ +accessType: Acceso +property: Propiedad account: + params: + id: Id + name: Nombre + roleFk: Rol + nickname: Nickname + password: Contraseña + active: Activo + search: Id + description: Descripción + alias: Alias + model: Modelo + principalId: Rol + property: Propiedad + accessType: Acceso card: nickname: Usuario role: Rol diff --git a/src/pages/Claim/Card/ClaimCard.vue b/src/pages/Claim/Card/ClaimCard.vue index 3642dc0d0..e1e000815 100644 --- a/src/pages/Claim/Card/ClaimCard.vue +++ b/src/pages/Claim/Card/ClaimCard.vue @@ -1,21 +1,13 @@ <script setup> -import VnCard from 'components/common/VnCard.vue'; +import VnCardBeta from 'components/common/VnCardBeta.vue'; import ClaimDescriptor from './ClaimDescriptor.vue'; -import ClaimFilter from '../ClaimFilter.vue'; import filter from './ClaimFilter.js'; </script> <template> - <VnCard - data-key="Claim" - base-url="Claims" - :descriptor="ClaimDescriptor" - :filter-panel="ClaimFilter" - search-data-key="ClaimList" + <VnCardBeta + data-key="Claim" + base-url="Claims" + :descriptor="ClaimDescriptor" :filter="filter" - :searchbar-props="{ - url: 'Claims/filter', - label: 'Search claim', - info: 'You can search by claim id or customer name', - }" /> </template> diff --git a/src/pages/Claim/Card/ClaimDevelopment.vue b/src/pages/Claim/Card/ClaimDevelopment.vue index e288d8614..d17c6b4e6 100644 --- a/src/pages/Claim/Card/ClaimDevelopment.vue +++ b/src/pages/Claim/Card/ClaimDevelopment.vue @@ -164,19 +164,7 @@ const columns = computed(() => [ :autofocus="col.tabIndex == 1" input-debounce="0" hide-selected - > - <template #option="scope"> - <QItem v-bind="scope.itemProps"> - <QItemSection> - <QItemLabel>{{ scope.opt?.name }}</QItemLabel> - <QItemLabel caption> - {{ scope.opt?.nickname }} - {{ scope.opt?.code }} - </QItemLabel> - </QItemSection> - </QItem> - </template> - </VnSelectWorker> + /> <VnSelect v-else v-model="row[col.model]" diff --git a/src/pages/Claim/Card/ClaimLines.vue b/src/pages/Claim/Card/ClaimLines.vue index 90a68beae..7c545b15b 100644 --- a/src/pages/Claim/Card/ClaimLines.vue +++ b/src/pages/Claim/Card/ClaimLines.vue @@ -230,7 +230,7 @@ async function saveWhenHasChanges() { </QTd> </template> <template #body-cell-discount="{ row, value, rowIndex }"> - <QTd auto-width align="right" class="text-primary shrink"> + <QTd auto-width align="right" class="link shrink"> {{ value }} <VnDiscount :quantity="row.quantity" diff --git a/src/pages/Claim/Card/ClaimSummary.vue b/src/pages/Claim/Card/ClaimSummary.vue index 8939a0785..66fb151e5 100644 --- a/src/pages/Claim/Card/ClaimSummary.vue +++ b/src/pages/Claim/Card/ClaimSummary.vue @@ -19,6 +19,7 @@ import ClaimNotes from 'src/pages/Claim/Card/ClaimNotes.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; +import ClaimDescriptorMenu from './ClaimDescriptorMenu.vue'; const route = useRoute(); const router = useRouter(); @@ -228,6 +229,9 @@ function claimUrl(section) { </QList> </QBtnDropdown> </template> + <template #menu="{ entity }"> + <ClaimDescriptorMenu :claim="entity.claim" /> + </template> <template #body="{ entity: { claim, salesClaimed, developments } }"> <QCard class="vn-one" v-if="$route.name != 'ClaimSummary'"> <VnTitle diff --git a/src/pages/Claim/ClaimFilter.vue b/src/pages/Claim/ClaimFilter.vue index c28e95cb8..b4dd4ee1b 100644 --- a/src/pages/Claim/ClaimFilter.vue +++ b/src/pages/Claim/ClaimFilter.vue @@ -93,16 +93,7 @@ defineExpose({ states }); outlined rounded dense - > - <template #option="scope"> - <QItem v-bind="scope.itemProps"> - <QItemSection> - <QItemLabel> #{{ scope.opt?.id }} </QItemLabel> - <QItemLabel caption>{{ scope.opt?.name }}</QItemLabel> - </QItemSection> - </QItem> - </template> - </VnSelect> + /> <VnSelect :label="t('claim.responsible')" v-model="params.claimResponsibleFk" diff --git a/src/pages/Claim/ClaimList.vue b/src/pages/Claim/ClaimList.vue index bb97162d8..35b051cdc 100644 --- a/src/pages/Claim/ClaimList.vue +++ b/src/pages/Claim/ClaimList.vue @@ -2,18 +2,18 @@ import { ref, computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { toDate } from 'filters/index'; -import VnSearchbar from 'components/ui/VnSearchbar.vue'; import ClaimFilter from './ClaimFilter.vue'; import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue'; import ClaimSummary from './Card/ClaimSummary.vue'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; -import RightMenu from 'src/components/common/RightMenu.vue'; import VnTable from 'src/components/VnTable/VnTable.vue'; import ZoneDescriptorProxy from '../Zone/Card/ZoneDescriptorProxy.vue'; +import VnSection from 'src/components/common/VnSection.vue'; const { t } = useI18n(); const { viewSummary } = useSummaryDialog(); +const dataKey = 'ClaimList'; const claimFilterRef = ref(); const columns = computed(() => [ @@ -125,48 +125,50 @@ const STATE_COLOR = { </script> <template> - <VnSearchbar - data-key="ClaimList" - :label="t('Search claim')" - :info="t('You can search by claim id or customer name')" - /> - <RightMenu> - <template #right-panel> + <VnSection + :data-key="dataKey" + :columns="columns" + prefix="claim" + :array-data-props="{ + url: 'Claims/filter', + order: ['cs.priority ASC', 'created ASC'], + }" + > + <template #rightMenu> <ClaimFilter data-key="ClaimList" ref="claimFilterRef" /> </template> - </RightMenu> - <VnTable - data-key="ClaimList" - url="Claims/filter" - :order="['cs.priority ASC', 'created ASC']" - :columns="columns" - redirect="claim" - :right-search="false" - > - <template #column-clientFk="{ row }"> - <span class="link" @click.stop> - {{ row.clientName }} - <CustomerDescriptorProxy :id="row.clientFk" /> - </span> + <template #body> + <VnTable + :data-key="dataKey" + :columns="columns" + redirect="claim" + :right-search="false" + auto-load + > + <template #column-clientFk="{ row }"> + <span class="link" @click.stop> + {{ row.clientName }} + <CustomerDescriptorProxy :id="row.clientFk" /> + </span> + </template> + <template #column-attendedBy="{ row }"> + <span @click.stop> + <VnUserLink :name="row.workerName" :worker-id="row.workerFk" /> + </span> + </template> + <template #column-zoneFk="{ row }"> + <span class="link" @click.stop> + {{ row.zoneName }} + <ZoneDescriptorProxy :id="row.zoneId" /> + </span> + </template> + </VnTable> </template> - <template #column-attendedBy="{ row }"> - <span @click.stop> - <VnUserLink :name="row.workerName" :worker-id="row.workerFk" /> - </span> - </template> - <template #column-zoneFk="{ row }"> - <span class="link" @click.stop> - {{ row.zoneName }} - <ZoneDescriptorProxy :id="row.zoneId" /> - </span> - </template> - </VnTable> + </VnSection> </template> <i18n> es: - Search claim: Buscar reclamación - You can search by claim id or customer name: Puedes buscar por id de la reclamación o nombre del cliente params: stateCode: Estado en: diff --git a/src/pages/Claim/locale/en.yml b/src/pages/Claim/locale/en.yml index ffcb44df6..11b4a2ca4 100644 --- a/src/pages/Claim/locale/en.yml +++ b/src/pages/Claim/locale/en.yml @@ -44,3 +44,5 @@ claim: fileDescription: 'Claim id {claimId} from client {clientName} id {clientId}' noData: 'There are no images/videos, click here or drag and drop the file' dragDrop: Drag and drop it here + search: Search claims + searchInfo: You can search by claim id or customer name diff --git a/src/pages/Claim/locale/es.yml b/src/pages/Claim/locale/es.yml index 052416aa7..d35d2c8e7 100644 --- a/src/pages/Claim/locale/es.yml +++ b/src/pages/Claim/locale/es.yml @@ -1,5 +1,3 @@ -Search claim: Buscar reclamación -You can search by claim id or customer name: Puedes buscar por id de la reclamación o nombre del cliente claim: customer: Cliente code: Código @@ -46,3 +44,5 @@ claim: fileDescription: 'ID de reclamación {claimId} del cliente {clientName} con ID {clientId}' noData: 'No hay imágenes/videos, haz clic aquí o arrastra y suelta el archivo' dragDrop: Arrastra y suelta aquí + search: Buscar reclamación + searchInfo: Puedes buscar por ID de la reclamación o nombre del cliente diff --git a/src/pages/Customer/Card/CustomerBalance.vue b/src/pages/Customer/Card/CustomerBalance.vue index 712be5e09..04ef5f882 100644 --- a/src/pages/Customer/Card/CustomerBalance.vue +++ b/src/pages/Customer/Card/CustomerBalance.vue @@ -84,6 +84,7 @@ const columns = computed(() => [ label: t('Creation date'), format: ({ created }) => toDateHourMin(created), cardVisible: true, + style: 'color: var(--vn-label-color)', }, { align: 'left', diff --git a/src/pages/Customer/Card/CustomerConsumption.vue b/src/pages/Customer/Card/CustomerConsumption.vue index 35f366e47..640e37ed3 100644 --- a/src/pages/Customer/Card/CustomerConsumption.vue +++ b/src/pages/Customer/Card/CustomerConsumption.vue @@ -2,7 +2,7 @@ import { ref, computed, onBeforeMount } from 'vue'; import axios from 'axios'; import { useI18n } from 'vue-i18n'; -import { toDate } from 'src/filters/index'; +import { dateRange, toDate } from 'src/filters/index'; import { useRoute } from 'vue-router'; import VnTable from 'components/VnTable/VnTable.vue'; @@ -104,18 +104,12 @@ function getParams() { }; } const userParams = computed(() => { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - - return { - campaign: campaignList.value[0]?.id, - from: minDate, - to: maxDate, + const campaign = campaignList.value[0]?.id; + const userParams = { + campaign, + ...updateDateParams(campaign, { from: Date.vnNew(), to: Date.vnNew() }), }; + return userParams; }); const openReportPdf = () => { openReport(`Clients/${route.params.id}/campaign-metrics-pdf`, getParams()); @@ -134,6 +128,23 @@ const sendCampaignMetricsEmail = ({ address }) => { ...getParams(), }); }; + +const updateDateParams = (value, params) => { + if (!value) { + params.from = null; + params.to = null; + return; + } + const campaign = campaignList.value.find((c) => c.id === value); + if (!campaign) return; + + const { dated, previousDays, scopeDays } = campaign; + const _date = new Date(dated); + const [from, to] = dateRange(_date); + params.from = new Date(from.setDate(from.getDate() - previousDays)).toISOString(); + params.to = new Date(to.setDate(to.getDate() + scopeDays)).toISOString(); + return params; +}; </script> <template> @@ -144,7 +155,6 @@ const sendCampaignMetricsEmail = ({ address }) => { :order="['itemTypeFk', 'itemName', 'itemSize', 'description']" :columns="columns" search-url="consumption" - :filter="filter" :user-params="userParams" :default-remove="false" :default-reset="false" @@ -201,6 +211,7 @@ const sendCampaignMetricsEmail = ({ address }) => { class="q-px-sm q-pt-none fit" dense option-label="code" + @update:model-value="(data) => updateDateParams(data, params)" > <template #option="scope"> <QItem v-bind="scope.itemProps"> diff --git a/src/pages/Customer/Card/CustomerDescriptor.vue b/src/pages/Customer/Card/CustomerDescriptor.vue index 98e53d568..cb49109d0 100644 --- a/src/pages/Customer/Card/CustomerDescriptor.vue +++ b/src/pages/Customer/Card/CustomerDescriptor.vue @@ -11,11 +11,9 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue'; import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue'; -import { useState } from 'src/composables/useState'; -const state = useState(); - -const customer = computed(() => state.get('customer')); +const customerDebt = ref(); +const customerCredit = ref(); const $props = defineProps({ id: { type: Number, @@ -37,11 +35,12 @@ const entityId = computed(() => { const data = ref(useCardDescription()); const setData = (entity) => { + customerDebt.value = entity?.debt; + customerCredit.value = entity?.credit; data.value = useCardDescription(entity?.name, entity?.id); - if (customer.value) customer.value.webAccess = data.value?.account?.isActive; }; const debtWarning = computed(() => { - return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary'; + return customerDebt.value > customerCredit.value ? 'negative' : 'primary'; }); </script> @@ -93,26 +92,21 @@ const debtWarning = computed(() => { :value="entity.businessType.description" /> </template> - <template #icons> - <QCardActions v-if="customer" class="q-gutter-x-md"> + <template #icons="{ entity }"> + <QCardActions class="q-gutter-x-md"> <QIcon - v-if="!customer.isActive" + v-if="!entity.isActive" name="vn:disabled" size="xs" color="primary" > <QTooltip>{{ t('customer.card.isDisabled') }}</QTooltip> </QIcon> - <QIcon - v-if="customer.isFreezed" - name="vn:frozen" - size="xs" - color="primary" - > + <QIcon v-if="entity.isFreezed" name="vn:frozen" size="xs" color="primary"> <QTooltip>{{ t('customer.card.isFrozen') }}</QTooltip> </QIcon> <QIcon - v-if="!customer.account?.active" + v-if="!entity.account?.active" color="primary" name="vn:noweb" size="xs" @@ -120,7 +114,7 @@ const debtWarning = computed(() => { <QTooltip>{{ t('customer.card.webAccountInactive') }}</QTooltip> </QIcon> <QIcon - v-if="customer.debt > customer.credit" + v-if="entity.debt > entity.credit" name="vn:risk" size="xs" :color="debtWarning" @@ -128,7 +122,7 @@ const debtWarning = computed(() => { <QTooltip>{{ t('customer.card.hasDebt') }}</QTooltip> </QIcon> <QIcon - v-if="!customer.isTaxDataChecked" + v-if="!entity.isTaxDataChecked" name="vn:no036" size="xs" color="primary" @@ -136,7 +130,7 @@ const debtWarning = computed(() => { <QTooltip>{{ t('customer.card.notChecked') }}</QTooltip> </QIcon> <QBtn - v-if="customer.unpaid" + v-if="entity.unpaid" flat size="sm" icon="vn:Client_unpaid" diff --git a/src/pages/Customer/Card/CustomerMandates.vue b/src/pages/Customer/Card/CustomerMandates.vue index 248515b4a..66cb44bc2 100644 --- a/src/pages/Customer/Card/CustomerMandates.vue +++ b/src/pages/Customer/Card/CustomerMandates.vue @@ -63,9 +63,10 @@ const columns = computed(() => [ <template> <QPage class="column items-center q-pa-md"> <VnTable + data-key="Mandates" + url="Mandates" :filter="filter" auto-load - url="Mandates" :columns="columns" class="full-width q-mt-md" :right-search="false" diff --git a/src/pages/Customer/Card/CustomerSummary.vue b/src/pages/Customer/Card/CustomerSummary.vue index 6650ea395..d2eb125d7 100644 --- a/src/pages/Customer/Card/CustomerSummary.vue +++ b/src/pages/Customer/Card/CustomerSummary.vue @@ -12,6 +12,7 @@ import VnLinkMail from 'src/components/ui/VnLinkMail.vue'; import CustomerSummaryTable from 'src/pages/Customer/components/CustomerSummaryTable.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; import VnRow from 'src/components/ui/VnRow.vue'; +import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue'; const route = useRoute(); const { t } = useI18n(); const grafanaUrl = 'https://grafana.verdnatura.es'; @@ -70,6 +71,9 @@ const sumRisk = ({ clientRisks }) => { data-key="CustomerSummary" module-name="Customer" > + <template #menu="{ entity }"> + <CustomerDescriptorMenu :customer="entity" /> + </template> <template #body="{ entity }"> <QCard class="vn-one"> <VnTitle @@ -94,14 +98,13 @@ const sumRisk = ({ clientRisks }) => { :phone-number="entity.mobile" :channel="entity.country?.saySimpleCountry?.channel" class="q-ml-xs" - :country="entity.country?.code" /> </template> </VnLv> <VnLv :value="entity.email" copy ><template #label> {{ t('globals.params.email') }} - <VnLinkMail :email="entity.email"></VnLinkMail> </template + <VnLinkMail email="entity.email"></VnLinkMail> </template ></VnLv> <VnLv :label="t('customer.summary.salesPerson')" @@ -173,7 +176,7 @@ const sumRisk = ({ clientRisks }) => { :label="t('customer.summary.notifyByEmail')" :value="entity.isToBeMailed" /> - <VnLv :label="t('globals.isVies')" :value="entity.isVies" /> + <VnLv :label="t('customer.summary.vies')" :value="entity.isVies" /> </VnRow> </QCard> <QCard class="vn-one"> diff --git a/src/pages/Customer/CustomerFilter.vue b/src/pages/Customer/CustomerFilter.vue index c62ec7dbb..53a12bf43 100644 --- a/src/pages/Customer/CustomerFilter.vue +++ b/src/pages/Customer/CustomerFilter.vue @@ -173,6 +173,8 @@ en: phone: Phone email: Email zoneFk: Zone + socialName : Social name + name: Name postcode: Postcode es: params: @@ -184,6 +186,8 @@ es: phone: Teléfono email: Email zoneFk: Zona + socialName : Razón social + name: Nombre postcode: CP FI: NIF Salesperson: Comercial diff --git a/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue b/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue index 1d7f63f36..ce86c6435 100644 --- a/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue +++ b/src/pages/Customer/Defaulter/CustomerDefaulterFilter.vue @@ -240,6 +240,7 @@ es: defaulterSinced: Desde Client: Cliente Salesperson: Comercial + Departments: Departamentos Country: País P. Method: F. Pago Balance D.: Saldo V. diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue index 150ef3b84..7685c55bc 100644 --- a/src/pages/Customer/components/CustomerAddressEdit.vue +++ b/src/pages/Customer/components/CustomerAddressEdit.vue @@ -247,8 +247,16 @@ function handleLocation(data, location) { :label="t('Longitude')" clearable v-model="data.longitude" + :decimal-places="7" + :positive="false" + /> + <VnInputNumber + :label="t('Latitude')" + clearable + v-model="data.latitude" + :decimal-places="7" + :positive="false" /> - <VnInputNumber :label="t('Latitude')" clearable v-model="data.latitude" /> </VnRow> <h4 class="q-mb-xs">{{ t('Notes') }}</h4> <VnRow diff --git a/src/pages/Customer/locale/en.yml b/src/pages/Customer/locale/en.yml index 18cee7309..1918838b7 100644 --- a/src/pages/Customer/locale/en.yml +++ b/src/pages/Customer/locale/en.yml @@ -94,3 +94,24 @@ customer: hasToInvoiceByAddress: Invoice by address isToBeMailed: Mailing hasSepaVnl: VNL B2B received + params: + id: Id + isWorker: Is Worker + payMethod: Payment Method + workerFk: Author + observation: Last Observation + created: Last Update Date + creditInsurance: Credit Insurance + defaulterSinced: Defaulted Since + hasRecovery: Has Recovery + socialName: Social name + city: City + phone: Phone + postcode: Postcode + campaign: Campaign + grouped: Grouped + search: Contains + itemId: Item Id + ticketFk: Ticket Id + description: Description + quantity: Quantity diff --git a/src/pages/Customer/locale/es.yml b/src/pages/Customer/locale/es.yml index b544f8ad7..d5db3df1b 100644 --- a/src/pages/Customer/locale/es.yml +++ b/src/pages/Customer/locale/es.yml @@ -96,3 +96,24 @@ customer: hasToInvoiceByAddress: Factura por consigna isToBeMailed: Env. emails hasSepaVnl: Recibido B2B VNL + params: + id: ID + isWorker: Es trabajador + payMethod: F. Pago + workerFk: Autor + observation: Última observación + created: Fecha Ú. O. + creditInsurance: Crédito A. + defaulterSinced: Desde + hasRecovery: Tiene recobro + socialName: Razón social + campaign: Campaña + city: Ciudad + phone: Teléfono + postcode: Código postal + grouped: Agrupado + search: Contiene + itemId: Id Artículo + ticketFk: Id Ticket + description: Descripción + quantity: Cantidad diff --git a/src/pages/Department/Card/DepartmentBasicData.vue b/src/pages/Department/Card/DepartmentBasicData.vue index 22ce06821..b13aed2d3 100644 --- a/src/pages/Department/Card/DepartmentBasicData.vue +++ b/src/pages/Department/Card/DepartmentBasicData.vue @@ -52,7 +52,7 @@ const { t } = useI18n(); <VnSelectWorker :label="t('department.bossDepartment')" v-model="data.workerFk" - :rules="validate('department.workerFk')" + :rules="validate('department.bossDepartment')" /> <VnSelect :label="t('department.selfConsumptionCustomer')" diff --git a/src/pages/Department/Card/DepartmentCard.vue b/src/pages/Department/Card/DepartmentCard.vue index 21247ca5a..8597e37cf 100644 --- a/src/pages/Department/Card/DepartmentCard.vue +++ b/src/pages/Department/Card/DepartmentCard.vue @@ -1,13 +1,13 @@ <script setup> -import VnCard from 'components/common/VnCard.vue'; +import VnCardBeta from 'components/common/VnCardBeta.vue'; import DepartmentDescriptor from 'pages/Department/Card/DepartmentDescriptor.vue'; </script> <template> - <VnCard + <VnCardBeta class="q-pa-md column items-center" v-bind="{ ...$attrs }" data-key="Department" base-url="Departments" :descriptor="DepartmentDescriptor" /> -</template> +</template> \ No newline at end of file diff --git a/src/pages/Department/Card/DepartmentDescriptor.vue b/src/pages/Department/Card/DepartmentDescriptor.vue index 498a05acb..e08495faf 100644 --- a/src/pages/Department/Card/DepartmentDescriptor.vue +++ b/src/pages/Department/Card/DepartmentDescriptor.vue @@ -83,7 +83,11 @@ const { openConfirmationModal } = useVnConfirm(); </template> <template #body="{ entity }"> <VnLv :label="t('department.chat')" :value="entity.chatName" /> - <VnLv :label="t('globals.email')" :value="entity.notificationEmail" copy /> + <VnLv + :label="t('globals.params.email')" + :value="entity.notificationEmail" + copy + /> <VnLv :label="t('department.selfConsumptionCustomer')" :value="entity.client?.name" diff --git a/src/pages/Department/Card/DepartmentSummary.vue b/src/pages/Department/Card/DepartmentSummary.vue index 03f9b7860..d41f8622b 100644 --- a/src/pages/Department/Card/DepartmentSummary.vue +++ b/src/pages/Department/Card/DepartmentSummary.vue @@ -40,7 +40,7 @@ onMounted(async () => { <template #body="{ entity: department }"> <QCard class="column"> <VnTitle - :url="`#/department/department/${entityId}/basic-data`" + :url="`#/worker/department/${entityId}/basic-data`" :text="t('Basic data')" /> <div class="full-width row wrap justify-between content-between"> @@ -58,7 +58,7 @@ onMounted(async () => { dash /> <VnLv - :label="t('globals.email')" + :label="t('globals.params.email')" :value="department.notificationEmail" dash /> diff --git a/src/pages/Entry/Card/EntryDescriptor.vue b/src/pages/Entry/Card/EntryDescriptor.vue index 188e66358..c54ecc3f0 100644 --- a/src/pages/Entry/Card/EntryDescriptor.vue +++ b/src/pages/Entry/Card/EntryDescriptor.vue @@ -7,9 +7,9 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import { toDate } from 'src/filters'; -import { usePrintService } from 'composables/usePrintService'; import { getUrl } from 'src/composables/getUrl'; import filter from './EntryFilter.js'; +import EntryDescriptorMenu from './EntryDescriptorMenu.vue'; const $props = defineProps({ id: { @@ -21,7 +21,6 @@ const $props = defineProps({ const route = useRoute(); const { t } = useI18n(); -const { openReport } = usePrintService(); const entryDescriptorRef = ref(null); const url = ref(); @@ -52,10 +51,6 @@ const getEntryRedirectionFilter = (entry) => { to, }); }; - -const showEntryReport = () => { - openReport(`Entries/${route.params.id}/entry-order-pdf`); -}; </script> <template> @@ -68,9 +63,7 @@ const showEntryReport = () => { data-key="Entry" > <template #menu="{ entity }"> - <QItem v-ripple clickable @click="showEntryReport(entity)"> - <QItemSection>{{ t('Show entry report') }}</QItemSection> - </QItem> + <EntryDescriptorMenu :id="entity.id" /> </template> <template #body="{ entity }"> <VnLv :label="t('globals.agency')" :value="entity.travel?.agency?.name" /> @@ -154,7 +147,6 @@ es: Supplier card: Ficha del proveedor All travels with current agency: Todos los envíos con la agencia actual All entries with current supplier: Todas las entradas con el proveedor actual - Show entry report: Ver informe del pedido Go to module index: Ir al índice del modulo Inventory entry: Es inventario Virtual entry: Es una redada diff --git a/src/pages/Entry/Card/EntryDescriptorMenu.vue b/src/pages/Entry/Card/EntryDescriptorMenu.vue new file mode 100644 index 000000000..a357b46fe --- /dev/null +++ b/src/pages/Entry/Card/EntryDescriptorMenu.vue @@ -0,0 +1,22 @@ +<script setup> +import { usePrintService } from 'composables/usePrintService'; + +const { openReport } = usePrintService(); + +const $props = defineProps({ + id: { + type: Number, + required: true, + }, +}); + +function showEntryReport() { + openReport(`Entries/${$props.id}/entry-order-pdf`); +} +</script> + +<template> + <QItem v-ripple clickable @click="showEntryReport"> + <QItemSection>{{ $t('entryList.list.showEntryReport') }}</QItemSection> + </QItem> +</template> diff --git a/src/pages/Entry/Card/EntrySummary.vue b/src/pages/Entry/Card/EntrySummary.vue index 4fb81d18f..755e39454 100644 --- a/src/pages/Entry/Card/EntrySummary.vue +++ b/src/pages/Entry/Card/EntrySummary.vue @@ -12,6 +12,9 @@ import { getUrl } from 'src/composables/getUrl'; import axios from 'axios'; import FetchedTags from 'src/components/ui/FetchedTags.vue'; import VnToSummary from 'src/components/ui/VnToSummary.vue'; +import EntryDescriptorMenu from './EntryDescriptorMenu.vue'; +import VnRow from 'src/components/ui/VnRow.vue'; +import VnTitle from 'src/components/common/VnTitle.vue'; const route = useRoute(); const { t } = useI18n(); @@ -147,9 +150,8 @@ async function setEntryData(data) { } const fetchEntryBuys = async () => { - const { data } = await axios.get(`Entries/${entry.value.id}/getBuys`); - if (data) entryBuys.value = data; - + const { data } = await axios.get(`Entries/${entry.value.id}/getBuys`); + if (data) entryBuys.value = data; }; </script> @@ -171,15 +173,15 @@ const fetchEntryBuys = async () => { <template #header> <span>{{ entry.id }} - {{ entry.supplier.nickname }}</span> </template> + <template #menu="{ entity }"> + <EntryDescriptorMenu :id="entity.id" /> + </template> <template #body> <QCard class="vn-one"> - <router-link - :to="{ name: 'EntryBasicData', params: { id: entityId } }" - class="header header-link" - > - {{ t('globals.summary.basicData') }} - <QIcon name="open_in_new" /> - </router-link> + <VnTitle + :url="`#/entry/${entityId}/basic-data`" + :text="t('globals.summary.basicData')" + /> <VnLv :label="t('entry.summary.commission')" :value="entry.commission" /> <VnLv :label="t('entry.summary.currency')" @@ -193,13 +195,10 @@ const fetchEntryBuys = async () => { /> </QCard> <QCard class="vn-one"> - <router-link - :to="{ name: 'EntryBasicData', params: { id: entityId } }" - class="header header-link" - > - {{ t('globals.summary.basicData') }} - <QIcon name="open_in_new" /> - </router-link> + <VnTitle + :url="`#/entry/${entityId}/basic-data`" + :text="t('globals.summary.basicData')" + /> <VnLv :label="t('entry.summary.travelReference')"> <template #value> <span class="link"> @@ -212,61 +211,45 @@ const fetchEntryBuys = async () => { :label="t('entry.summary.travelAgency')" :value="entry.travel.agency?.name" /> - <VnLv :label="t('shipped')" :value="toDate(entry.travel.shipped)" /> + <VnLv + :label="t('globals.shipped')" + :value="toDate(entry.travel.shipped)" + /> <VnLv :label="t('globals.warehouseOut')" :value="entry.travel.warehouseOut?.name" /> - <QCheckbox + <VnLv :label="t('entry.summary.travelDelivered')" - v-model="entry.travel.isDelivered" - :disable="true" + :value="entry.travel.isDelivered" /> - <VnLv :label="t('landed')" :value="toDate(entry.travel.landed)" /> + <VnLv :label="t('globals.landed')" :value="toDate(entry.travel.landed)" /> <VnLv :label="t('globals.warehouseIn')" :value="entry.travel.warehouseIn?.name" /> - <QCheckbox + <VnLv :label="t('entry.summary.travelReceived')" - v-model="entry.travel.isReceived" - :disable="true" + :value="entry.travel.isReceived" /> </QCard> <QCard class="vn-one"> - <router-link - :to="{ name: 'TravelSummary', params: { id: entry.travel.id } }" - class="header header-link" - > - {{ t('Travel data') }} - <QIcon name="open_in_new" /> - </router-link> - <QCheckbox - :label="t('entry.summary.ordered')" - v-model="entry.isOrdered" - :disable="true" - /> - <QCheckbox - :label="t('globals.confirmed')" - v-model="entry.isConfirmed" - :disable="true" - /> - <QCheckbox - :label="t('entry.summary.booked')" - v-model="entry.isBooked" - :disable="true" - /> - <QCheckbox - :label="t('entry.summary.excludedFromAvailable')" - v-model="entry.isExcludedFromAvailable" - :disable="true" - /> + <VnTitle :url="`#/travel/${entityId}/summary`" :text="t('Travel data')" /> + <VnRow class="block"> + <VnLv :label="t('entry.summary.ordered')" :value="entry.isOrdered" /> + <VnLv :label="t('globals.confirmed')" :value="entry.isConfirmed" /> + <VnLv :label="t('entry.summary.booked')" :value="entry.isBooked" /> + <VnLv + :label="t('entry.summary.excludedFromAvailable')" + :value="entry.isExcludedFromAvailable" + /> + </VnRow> </QCard> - <QCard class="vn-two" style="min-width: 100%"> - <a class="header header-link"> - {{ t('entry.summary.buys') }} - <QIcon name="open_in_new" /> - </a> + <QCard class="vn-max"> + <VnTitle + :url="`#/entry/${entityId}/buys`" + :text="t('entry.summary.buys')" + /> <QTable :rows="entryBuys" :columns="entriesTableColumns" diff --git a/src/pages/Entry/EntryBuysTableDialog.vue b/src/pages/Entry/EntryBuysTableDialog.vue index 3975bff19..a2d8c9117 100644 --- a/src/pages/Entry/EntryBuysTableDialog.vue +++ b/src/pages/Entry/EntryBuysTableDialog.vue @@ -1,24 +1,24 @@ <script setup> -import { computed } from 'vue'; +import { computed, ref } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import { QBtn } from 'quasar'; import VnPaginate from 'src/components/ui/VnPaginate.vue'; import { usePrintService } from 'composables/usePrintService'; -const { openReport } = usePrintService(); +const { openReport } = usePrintService(); +const buyRows = ref([]); const route = useRoute(); const { t } = useI18n(); const $props = defineProps({ id: { - type: String, + type: Number, required: false, default: null, }, }); const entityId = computed(() => $props.id || route.params.id); - const entriesTableColumns = computed(() => [ { align: 'left', @@ -63,34 +63,39 @@ const entriesTableColumns = computed(() => [ field: 'grouping', }, ]); -</script> +function downloadCSV(rows) { + const headers = ['id', 'itemFk', 'name', 'stickers', 'packing', 'comment']; + + const csvRows = rows.map((row) => { + const buy = row; + const item = buy.item || {}; + + return [ + buy.id, + buy.itemFk, + item.name || '', + buy.stickers, + buy.packing, + item.comment || '', + ].join(','); + }); + + const csvContent = [headers.join(','), ...csvRows].join('\n'); + + const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', `${entityId.value}data.csv`); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); +} +</script> <template> <QDialog ref="dialogRef"> <QCard style="min-width: 800px"> - <QCardSection class="row items-center q-pb-none"> - <QAvatar - :icon="icon" - color="primary" - text-color="white" - size="xl" - v-if="icon" - /> - <span class="text-h6 text-grey">{{ title }}</span> - <QSpace /> - <QBtn icon="close" :disable="isLoading" flat round dense v-close-popup /> - </QCardSection> - <QCardActions align="right"> - <QBtn - :label="t('myEntries.printLabels')" - color="primary" - icon="print" - :loading="isLoading" - @click="openReport(`Entries/${entityId}/labelSupplier`)" - unelevated - autofocus - /> - </QCardActions> <QCardSection class="row items-center"> <VnPaginate ref="entryBuysPaginateRef" @@ -101,6 +106,7 @@ const entriesTableColumns = computed(() => [ > <template #body="{ rows }"> <QTable + ref="buyRows" :rows="rows" :columns="entriesTableColumns" row-key="id" @@ -110,6 +116,26 @@ const entriesTableColumns = computed(() => [ :grid="$q.screen.lt.md" :no-data-label="t('globals.noResults')" > + <template #top-left> + <QBtn + :label="t('myEntries.downloadCsv')" + color="primary" + icon="csv" + @click="downloadCSV(rows)" + unelevated + /> + </template> + <template #top-right> + <QBtn + class="q-mr-lg" + :label="t('myEntries.printLabels')" + color="primary" + icon="print" + @click=" + openReport(`Entries/${entityId}/labelSupplier`) + " + /> + </template> <template #body="props"> <QTr> <QTd v-for="col in props.cols" :key="col.name"> @@ -118,7 +144,6 @@ const entriesTableColumns = computed(() => [ <QBtn icon="visibility" v-if="props.row.stickers > 0" - :loading="isLoading" @click=" openReport( `Entries/${props.row.id}/buy-label-supplier` diff --git a/src/pages/Entry/EntryFilter.vue b/src/pages/Entry/EntryFilter.vue index f50810eb7..f91f7f128 100644 --- a/src/pages/Entry/EntryFilter.vue +++ b/src/pages/Entry/EntryFilter.vue @@ -123,6 +123,7 @@ const companiesOptions = ref([]); option-value="id" option-label="name" :fields="['id', 'name', 'nickname']" + :filter-options="['id', 'name', 'nickname']" sort-by="nickname" hide-selected dense @@ -132,9 +133,12 @@ const companiesOptions = ref([]); <template #option="scope"> <QItem v-bind="scope.itemProps"> <QItemSection> - <QItemLabel>{{ - scope.opt?.name + ': ' + scope.opt?.nickname - }}</QItemLabel> + <QItemLabel> + {{ scope.opt?.name}} + </QItemLabel> + <QItemLabel caption> + {{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }} + </QItemLabel> </QItemSection> </QItem> </template> diff --git a/src/pages/Entry/EntryLatestBuysFilter.vue b/src/pages/Entry/EntryLatestBuysFilter.vue index 83124c1bf..59dddce26 100644 --- a/src/pages/Entry/EntryLatestBuysFilter.vue +++ b/src/pages/Entry/EntryLatestBuysFilter.vue @@ -58,7 +58,7 @@ const tagValues = ref([]); <QItem class="q-my-md"> <QItemSection> <VnSelect - :label="t('components.itemsFilterPanel.supplierFk')" + :label="t('globals.params.supplierFk')" v-model="params.supplierFk" :options="suppliersOptions" option-value="id" @@ -69,12 +69,14 @@ const tagValues = ref([]); use-input @update:model-value="searchFn()" > - <template #option="{ itemProps, opt }"> - <QItem v-bind="itemProps"> + <template #option="scope"> + <QItem v-bind="scope.itemProps"> <QItemSection> - <QItemLabel>{{ opt.name }}</QItemLabel> + <QItemLabel> + {{ scope.opt?.name}} + </QItemLabel> <QItemLabel caption> - {{ opt.nickname }} + {{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }} </QItemLabel> </QItemSection> </QItem> @@ -85,7 +87,7 @@ const tagValues = ref([]); <QItem class="q-my-md"> <QItemSection> <VnInputDate - :label="t('components.itemsFilterPanel.from')" + :label="t('components.itemsFilterPanel.started')" v-model="params.from" is-outlined @update:model-value="searchFn()" @@ -95,7 +97,7 @@ const tagValues = ref([]); <QItem class="q-my-md"> <QItemSection> <VnInputDate - :label="t('components.itemsFilterPanel.to')" + :label="t('components.itemsFilterPanel.ended')" v-model="params.to" is-outlined @update:model-value="searchFn()" @@ -113,7 +115,7 @@ const tagValues = ref([]); </QItemSection> <QItemSection> <QCheckbox - :label="t('components.itemsFilterPanel.visible')" + :label="t('globals.visible')" v-model="params.visible" toggle-indeterminate @update:model-value="searchFn()" diff --git a/src/pages/Entry/EntryList.vue b/src/pages/Entry/EntryList.vue index 84ead85ad..879a50914 100644 --- a/src/pages/Entry/EntryList.vue +++ b/src/pages/Entry/EntryList.vue @@ -1,9 +1,8 @@ <script setup> -import { onMounted, ref, computed } from 'vue'; +import { ref, computed } from 'vue'; import { useI18n } from 'vue-i18n'; import EntryFilter from './EntryFilter.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; -import { useStateStore } from 'stores/useStateStore'; import VnTable from 'components/VnTable/VnTable.vue'; import RightMenu from 'src/components/common/RightMenu.vue'; import { toDate } from 'src/filters'; @@ -12,7 +11,6 @@ import EntrySummary from './Card/EntrySummary.vue'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; import TravelDescriptorProxy from 'src/pages/Travel/Card/TravelDescriptorProxy.vue'; -const stateStore = useStateStore(); const { t } = useI18n(); const tableRef = ref(); @@ -245,7 +243,6 @@ const columns = computed(() => [ <i18n> es: - Inventory entry: Es inventario Virtual entry: Es una redada Search entries: Buscar entradas You can search by entry reference: Puedes buscar por referencia de la entrada diff --git a/src/pages/Entry/EntryStockBoughtFilter.vue b/src/pages/Entry/EntryStockBoughtFilter.vue index e59332064..136881f17 100644 --- a/src/pages/Entry/EntryStockBoughtFilter.vue +++ b/src/pages/Entry/EntryStockBoughtFilter.vue @@ -65,6 +65,6 @@ onMounted(async () => { es: Date: Fecha params: - dated: Date + dated: Fecha workerFk: Trabajador </i18n> diff --git a/src/pages/Entry/MyEntries.vue b/src/pages/Entry/MyEntries.vue index 91a29b190..dbe05eb88 100644 --- a/src/pages/Entry/MyEntries.vue +++ b/src/pages/Entry/MyEntries.vue @@ -102,7 +102,7 @@ const columns = computed(() => [ actions: [ { title: t('myEntries.printLabels'), - icon: 'print', + icon: 'move_item', isPrimary: true, action: (row) => printBuys(row.id), }, diff --git a/src/pages/Entry/locale/en.yml b/src/pages/Entry/locale/en.yml index cd5113d84..59c2666a7 100644 --- a/src/pages/Entry/locale/en.yml +++ b/src/pages/Entry/locale/en.yml @@ -1,6 +1,7 @@ entryList: list: inventoryEntry: Inventory entry + showEntryReport: Show entry report entryFilter: filter: search: General search @@ -17,5 +18,6 @@ myEntries: warehouseInFk: Warehouse in daysOnward: Days onward daysAgo: Days ago + downloadCsv: Download CSV wasteRecalc: recalcOk: The wastes were successfully recalculated diff --git a/src/pages/Entry/locale/es.yml b/src/pages/Entry/locale/es.yml index 3007c5d44..4fb7bbf08 100644 --- a/src/pages/Entry/locale/es.yml +++ b/src/pages/Entry/locale/es.yml @@ -4,6 +4,7 @@ You can search by entry reference: Puedes buscar por referencia de la entrada entryList: list: inventoryEntry: Es inventario + showEntryReport: Ver informe del pedido entryFilter: filter: search: Búsqueda general @@ -20,5 +21,6 @@ myEntries: warehouseInFk: Alm. entrada daysOnward: Días adelante daysAgo: Días atras + downloadCsv: Descargar CSV wasteRecalc: recalcOk: Se han recalculado las mermas correctamente diff --git a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue index 83b1aa25e..90aa50af7 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue @@ -268,7 +268,7 @@ function deleteFile(dmsFk) { </VnRow> <VnRow> <VnSelect - :label="t('InvoiceIn.summary.sage')" + :label="t('invoicein.summary.sage')" v-model="data.withholdingSageFk" :options="sageWithholdings" option-value="id" diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue index cb8a45833..4d9e180eb 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue @@ -1,60 +1,30 @@ <script setup> -import { ref, reactive, computed, onBeforeMount, capitalize } from 'vue'; +import { ref, reactive, computed, onBeforeMount } from 'vue'; import { useRouter, onBeforeRouteUpdate } from 'vue-router'; import { useI18n } from 'vue-i18n'; -import { useQuasar } from 'quasar'; import axios from 'axios'; import { toCurrency, toDate } from 'src/filters'; -import { useAcl } from 'src/composables/useAcl'; -import { downloadFile } from 'src/composables/downloadFile'; -import { useArrayData } from 'src/composables/useArrayData'; -import { usePrintService } from 'composables/usePrintService'; import VnLv from 'src/components/ui/VnLv.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue'; import FetchData from 'src/components/FetchData.vue'; -import SendEmailDialog from 'components/common/SendEmailDialog.vue'; -import VnConfirm from 'src/components/ui/VnConfirm.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; +import { useCapitalize } from 'src/composables/useCapitalize'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; -import InvoiceInToBook from '../InvoiceInToBook.vue'; +import InvoiceInDescriptorMenu from './InvoiceInDescriptorMenu.vue'; const $props = defineProps({ id: { type: Number, default: null } }); - const { push, currentRoute } = useRouter(); - -const quasar = useQuasar(); -const { hasAny } = useAcl(); const { t } = useI18n(); -const { openReport, sendEmail } = usePrintService(); -const arrayData = useArrayData(); -const invoiceIn = computed(() => arrayData.store.data); const cardDescriptorRef = ref(); const correctionDialogRef = ref(); const entityId = computed(() => $props.id || +currentRoute.value.params.id); const totalAmount = ref(); -const currentAction = ref(); const config = ref(); const cplusRectificationTypes = ref([]); const siiTypeInvoiceIns = ref([]); const invoiceCorrectionTypes = ref([]); -const actions = { - unbook: { - title: t('assertAction', { action: t('unbook') }), - action: toUnbook, - }, - delete: { - title: t('assertAction', { action: t('delete') }), - action: deleteInvoice, - }, - clone: { - title: t('assertAction', { action: t('clone') }), - action: cloneInvoice, - }, - showPdf: { cb: showPdfInvoice }, - sendPdf: { cb: sendPdfInvoiceConfirmation }, - correct: { cb: () => correctionDialogRef.value.show() }, -}; + const filter = { include: [ { @@ -90,7 +60,7 @@ const routes = reactive({ return { name: 'InvoiceInList', query: { - table: JSON.stringify({ supplierFk: id }), + params: JSON.stringify({ supplierFk: id }), }, }; }, @@ -99,7 +69,7 @@ const routes = reactive({ return { name: 'InvoiceInList', query: { - table: JSON.stringify({ correctedFk: entityId.value }), + params: JSON.stringify({ correctedFk: entityId.value }), }, }; } @@ -118,21 +88,21 @@ const routes = reactive({ const correctionFormData = reactive({ invoiceReason: 2, invoiceType: 2, - invoiceClass: 8, + invoiceClass: 6, }); const isNotFilled = computed(() => Object.values(correctionFormData).includes(null)); onBeforeMount(async () => { await setInvoiceCorrection(entityId.value); const { data } = await axios.get(`InvoiceIns/${entityId.value}/getTotals`); - totalAmount.value = data.totalTaxableBase; + totalAmount.value = data.totalDueDay; }); onBeforeRouteUpdate(async (to, from) => { if (to.params.id !== from.params.id) { await setInvoiceCorrection(to.params.id); const { data } = await axios.get(`InvoiceIns/${to.params.id}/getTotals`); - totalAmount.value = data.totalTaxableBase; + totalAmount.value = data.totalDueDay; } }); @@ -153,94 +123,6 @@ async function setInvoiceCorrection(id) { ); } -function openDialog() { - quasar.dialog({ - component: VnConfirm, - componentProps: { - title: t(currentAction.value.title), - promise: currentAction.value.action, - }, - }); -} - -async function toUnbook() { - const { data } = await axios.post(`InvoiceIns/${entityId.value}/toUnbook`); - const { isLinked, bookEntry, accountingEntries } = data; - - const type = isLinked ? 'warning' : 'positive'; - const message = isLinked - ? t('isLinked', { bookEntry, accountingEntries }) - : t('isNotLinked', { bookEntry }); - - quasar.notify({ type, message }); - if (!isLinked) arrayData.store.data.isBooked = false; -} - -async function deleteInvoice() { - await axios.delete(`InvoiceIns/${entityId.value}`); - quasar.notify({ - type: 'positive', - message: t('Invoice deleted'), - }); - push({ path: '/invoice-in' }); -} - -async function cloneInvoice() { - const { data } = await axios.post(`InvoiceIns/${entityId.value}/clone`); - quasar.notify({ - type: 'positive', - message: t('Invoice cloned'), - }); - push({ path: `/invoice-in/${data.id}/summary` }); -} - -const canEditProp = (props) => - hasAny([{ model: 'InvoiceIn', props, accessType: 'WRITE' }]); - -const isAgricultural = () => { - if (!config.value) return false; - return ( - invoiceIn.value?.supplier?.sageFarmerWithholdingFk === - config?.value[0]?.sageWithholdingFk - ); -}; - -function showPdfInvoice() { - if (isAgricultural()) - openReport(`InvoiceIns/${entityId.value}/invoice-in-pdf`, null, '_blank'); -} - -function sendPdfInvoiceConfirmation() { - quasar.dialog({ - component: SendEmailDialog, - componentProps: { - data: { - address: invoiceIn.value.supplier.contacts[0].email, - }, - promise: sendPdfInvoice, - }, - }); -} - -function sendPdfInvoice({ address }) { - if (!address) - quasar.notify({ - type: 'negative', - message: t(`The email can't be empty`), - }); - else - return sendEmail(`InvoiceIns/${entityId.value}/invoice-in-email`, { - recipientId: invoiceIn.value.supplier.id, - recipient: address, - }); -} - -function triggerMenu(type) { - currentAction.value = actions[type]; - if (currentAction.value.cb) currentAction.value.cb(); - else openDialog(type); -} - const createInvoiceInCorrection = async () => { const { data: correctingId } = await axios.post( 'InvoiceIns/corrective', @@ -262,7 +144,7 @@ const createInvoiceInCorrection = async () => { auto-load /> <FetchData - url="siiTypeInvoiceIns" + url="SiiTypeInvoiceIns" :where="{ code: { like: 'R%' } }" @on-fetch="(data) => (siiTypeInvoiceIns = data)" auto-load @@ -281,87 +163,13 @@ const createInvoiceInCorrection = async () => { title="supplierRef" > <template #menu="{ entity }"> - <InvoiceInToBook> - <template #content="{ book }"> - <QItem - v-if="!entity?.isBooked && canEditProp('toBook')" - v-ripple - clickable - @click="book(entityId)" - > - <QItemSection>{{ t('To book') }}</QItemSection> - </QItem> - </template> - </InvoiceInToBook> - <QItem - v-if="entity?.isBooked && canEditProp('toUnbook')" - v-ripple - clickable - @click="triggerMenu('unbook')" - > - <QItemSection> - {{ t('To unbook') }} - </QItemSection> - </QItem> - <QItem - v-if="canEditProp('deleteById')" - v-ripple - clickable - @click="triggerMenu('delete')" - > - <QItemSection>{{ t('Delete invoice') }}</QItemSection> - </QItem> - <QItem - v-if="canEditProp('clone')" - v-ripple - clickable - @click="triggerMenu('clone')" - > - <QItemSection>{{ t('Clone invoice') }}</QItemSection> - </QItem> - <QItem - v-if="isAgricultural()" - v-ripple - clickable - @click="triggerMenu('showPdf')" - > - <QItemSection>{{ t('Show agricultural receipt as PDF') }}</QItemSection> - </QItem> - <QItem - v-if="isAgricultural()" - v-ripple - clickable - @click="triggerMenu('sendPdf')" - > - <QItemSection - >{{ t('Send agricultural receipt as PDF') }}...</QItemSection - > - </QItem> - <QItem - v-if="!invoiceInCorrection.corrected" - v-ripple - clickable - @click="triggerMenu('correct')" - > - <QItemSection>{{ t('Create rectificative invoice') }}...</QItemSection> - </QItem> - <QItem - v-if="entity.dmsFk" - v-ripple - clickable - @click="downloadFile(entity.dmsFk)" - > - <QItemSection>{{ t('components.smartCard.downloadFile') }}</QItemSection> - </QItem> + <InvoiceInDescriptorMenu :invoice="entity" /> </template> <template #body="{ entity }"> - <VnLv :label="t('InvoiceIn.list.issued')" :value="toDate(entity.issued)" /> - <VnLv - :label="t('InvoiceIn.summary.bookedDate')" - :value="toDate(entity.booked)" - /> - <VnLv :label="t('InvoiceIn.list.amount')" :value="toCurrency(totalAmount)" /> - <VnLv :label="t('InvoiceIn.list.supplier')"> + <VnLv :label="t('invoicein.list.issued')" :value="toDate(entity.issued)" /> + <VnLv :label="t('invoicein.summary.bookedDate')" :value="toDate(entity.booked)" /> + <VnLv :label="t('invoicein.list.amount')" :value="toCurrency(totalAmount)" /> + <VnLv :label="t('invoicein.list.supplier')"> <template #value> <span class="link"> {{ entity?.supplier?.nickname }} @@ -378,7 +186,7 @@ const createInvoiceInCorrection = async () => { color="primary" :to="routes.getSupplier(entity.supplierFk)" > - <QTooltip>{{ t('InvoiceIn.list.supplier') }}</QTooltip> + <QTooltip>{{ t('invoicein.list.supplier') }}</QTooltip> </QBtn> <QBtn size="md" @@ -394,7 +202,7 @@ const createInvoiceInCorrection = async () => { color="primary" :to="routes.getTickets(entity.supplierFk)" > - <QTooltip>{{ t('InvoiceIn.descriptor.ticketList') }}</QTooltip> + <QTooltip>{{ t('InvoiceOut.card.ticketList') }}</QTooltip> </QBtn> <QBtn v-if=" @@ -438,7 +246,7 @@ const createInvoiceInCorrection = async () => { readonly /> <VnSelect - :label="`${capitalize(t('globals.class'))}`" + :label="`${useCapitalize(t('globals.class'))}`" v-model="correctionFormData.invoiceClass" :options="siiTypeInvoiceIns" option-value="id" @@ -448,27 +256,15 @@ const createInvoiceInCorrection = async () => { </QItemSection> <QItemSection> <VnSelect - :label="`${capitalize(t('globals.type'))}`" + :label="`${useCapitalize(t('globals.type'))}`" v-model="correctionFormData.invoiceType" :options="cplusRectificationTypes" option-value="id" option-label="description" :required="true" - > - <template #option="{ opt }"> - <QItem> - <QItemSection> - <QItemLabel - >{{ opt.code }} - - {{ opt.description }}</QItemLabel - > - </QItemSection> - </QItem> - <div></div> - </template> - </VnSelect> + /> <VnSelect - :label="`${capitalize(t('globals.reason'))}`" + :label="`${useCapitalize(t('globals.reason'))}`" v-model="correctionFormData.invoiceReason" :options="invoiceCorrectionTypes" option-value="id" @@ -512,31 +308,3 @@ const createInvoiceInCorrection = async () => { } } </style> -<i18n> -en: - isNotLinked: The entry {bookEntry} has been deleted with {accountingEntries} entries - isLinked: The entry {bookEntry} has been linked to Sage. Please contact administration for further information - assertAction: Are you sure you want to {action} this invoice? -es: - book: asentar - unbook: desasentar - delete: eliminar - clone: clonar - To book: Contabilizar - To unbook: Descontabilizar - Delete invoice: Eliminar factura - Invoice deleted: Factura eliminada - Clone invoice: Clonar factura - Invoice cloned: Factura clonada - Show agricultural receipt as PDF: Ver recibo agrícola como PDF - Send agricultural receipt as PDF: Enviar recibo agrícola como PDF - Are you sure you want to send it?: Estás seguro que quieres enviarlo? - Send PDF invoice: Enviar factura a PDF - Create rectificative invoice: Crear factura rectificativa - Rectificative invoice: Factura rectificativa - Original invoice: Factura origen - Entry: entrada - isNotLinked: Se ha eliminado el asiento nº {bookEntry} con {accountingEntries} apuntes - isLinked: El asiento {bookEntry} fue enlazado a Sage, por favor contacta con administración - assertAction: Estas seguro de querer {action} esta factura? -</i18n> diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue new file mode 100644 index 000000000..647b68f88 --- /dev/null +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptorMenu.vue @@ -0,0 +1,206 @@ +<script setup> +import { ref, computed, toRefs, reactive } from 'vue'; +import { useRouter } from 'vue-router'; +import { useI18n } from 'vue-i18n'; +import { useQuasar } from 'quasar'; +import axios from 'axios'; +import { useAcl } from 'src/composables/useAcl'; +import { downloadFile } from 'src/composables/downloadFile'; +import { useArrayData } from 'src/composables/useArrayData'; +import { usePrintService } from 'composables/usePrintService'; +import VnConfirm from 'src/components/ui/VnConfirm.vue'; +import SendEmailDialog from 'components/common/SendEmailDialog.vue'; +import InvoiceInToBook from '../InvoiceInToBook.vue'; + +const { hasAny } = useAcl(); +const { t } = useI18n(); +const { openReport, sendEmail } = usePrintService(); +const { push, currentRoute } = useRouter(); +const $props = defineProps({ + invoice: { + type: Object, + required: true, + }, +}); +const { invoice } = toRefs($props); +const quasar = useQuasar(); +const arrayData = useArrayData(); +const currentAction = ref(); +const config = ref(); +const correctionDialogRef = ref(); +const invoiceInCorrection = reactive({ correcting: [], corrected: null }); +const entityId = computed(() => $props.invoice.id || +currentRoute.value.params.id); +const invoiceIn = computed(() => arrayData.store.data); +const actions = { + unbook: { + title: t('assertAction', { action: t('invoicein.descriptorMenu.unbook') }), + action: toUnbook, + }, + delete: { + title: t('assertAction', { action: t('invoicein.descriptorMenu.delete') }), + action: deleteInvoice, + }, + clone: { + title: t('assertAction', { action: t('invoicein.descriptorMenu.clone') }), + action: cloneInvoice, + }, + showPdf: { cb: showPdfInvoice }, + sendPdf: { cb: sendPdfInvoiceConfirmation }, + correct: { cb: () => correctionDialogRef.value.show() }, +}; +const canEditProp = (props) => + hasAny([{ model: 'InvoiceIn', props, accessType: 'WRITE' }]); + +function triggerMenu(type) { + currentAction.value = actions[type]; + if (currentAction.value.cb) currentAction.value.cb(); + else openDialog(type); +} + +function openDialog() { + quasar.dialog({ + component: VnConfirm, + componentProps: { + title: t(currentAction.value.title), + promise: currentAction.value.action, + }, + }); +} + +async function toUnbook() { + const { data } = await axios.post(`InvoiceIns/${entityId.value}/toUnbook`); + const { isLinked, bookEntry, accountingEntries } = data; + + const type = isLinked ? 'warning' : 'positive'; + const message = isLinked + ? t('isLinked', { bookEntry }) + : t('isNotLinked', { bookEntry, accountingEntries }); + + quasar.notify({ type, message }); + if (!isLinked) arrayData.store.data.isBooked = false; +} + +async function deleteInvoice() { + await axios.delete(`InvoiceIns/${entityId.value}`); + quasar.notify({ + type: 'positive', + message: t('invoicein.descriptorMenu.invoiceDeleted'), + }); + push({ path: '/invoice-in' }); +} + +async function cloneInvoice() { + const { data } = await axios.post(`InvoiceIns/${entityId.value}/clone`); + quasar.notify({ + type: 'positive', + message: t('invoicein.descriptorMenu.invoiceCloned'), + }); + push({ path: `/invoice-in/${data.id}/summary` }); +} + +const isAgricultural = () => { + if (!config.value) return false; + return ( + invoiceIn.value?.supplier?.sageFarmerWithholdingFk === + config?.value[0]?.sageWithholdingFk + ); +}; +function showPdfInvoice() { + if (isAgricultural()) openReport(`InvoiceIns/${entityId.value}/invoice-in-pdf`); +} + +function sendPdfInvoiceConfirmation() { + quasar.dialog({ + component: SendEmailDialog, + componentProps: { + data: { + address: invoiceIn.value.supplier.contacts[0].email, + }, + promise: sendPdfInvoice, + }, + }); +} + +function sendPdfInvoice({ address }) { + if (!address) + quasar.notify({ + type: 'negative', + message: t(`The email can't be empty`), + }); + else + return sendEmail(`InvoiceIns/${entityId.value}/invoice-in-email`, { + recipientId: invoiceIn.value.supplier.id, + recipient: address, + }); +} +</script> + +<template> + <InvoiceInToBook> + <template #content="{ book }"> + <QItem + v-if="!invoice?.isBooked && canEditProp('toBook')" + v-ripple + clickable + @click="book(entityId)" + > + <QItemSection>{{ t('invoicein.descriptorMenu.toBook') }}</QItemSection> + </QItem> + </template> + </InvoiceInToBook> + <QItem + v-if="invoice?.isBooked && canEditProp('toUnbook')" + v-ripple + clickable + @click="triggerMenu('unbook')" + > + <QItemSection> + {{ t('invoicein.descriptorMenu.toUnbook') }} + </QItemSection> + </QItem> + <QItem + v-if="canEditProp('deleteById')" + v-ripple + clickable + @click="triggerMenu('invoicein.descriptorMenu.delete')" + > + <QItemSection>{{ t('invoicein.descriptorMenu.deleteInvoice') }}</QItemSection> + </QItem> + <QItem v-if="canEditProp('clone')" v-ripple clickable @click="triggerMenu('clone')"> + <QItemSection>{{ t('invoicein.descriptorMenu.cloneInvoice') }}</QItemSection> + </QItem> + <QItem v-if="isAgricultural()" v-ripple clickable @click="triggerMenu('showPdf')"> + <QItemSection>{{ + t('invoicein.descriptorMenu.showAgriculturalPdf') + }}</QItemSection> + </QItem> + <QItem v-if="isAgricultural()" v-ripple clickable @click="triggerMenu('sendPdf')"> + <QItemSection + >{{ t('invoicein.descriptorMenu.sendAgriculturalPdf') }}...</QItemSection + > + </QItem> + <QItem + v-if="!invoiceInCorrection.corrected" + v-ripple + clickable + @click="triggerMenu('correct')" + > + <QItemSection + >{{ t('invoicein.descriptorMenu.createCorrective') }}...</QItemSection + > + </QItem> + <QItem v-if="invoice.dmsFk" v-ripple clickable @click="downloadFile(invoice.dmsFk)"> + <QItemSection>{{ t('components.smartCard.downloadFile') }}</QItemSection> + </QItem> +</template> + +<i18n> +en: + isNotLinked: The entry {bookEntry} has been deleted with {accountingEntries} entries + isLinked: The entry has been linked to Sage. Please contact administration for further information + assertAction: Are you sure you want to {action} this invoice? +es: + isNotLinked: Se ha eliminado el asiento nº {bookEntry} con {accountingEntries} apuntes + isLinked: El asiento fue enlazado a Sage, por favor contacta con administración + assertAction: Estas seguro de querer {action} esta factura? +</i18n> diff --git a/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue b/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue index 1c4091169..e529ea6cd 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInIntrastat.vue @@ -161,7 +161,7 @@ const columns = computed(() => [ <QList> <QItem> <VnSelect - :label="t('code')" + :label="t('Code')" class="full-width" v-model="props.row['intrastatFk']" :options="intrastats" diff --git a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue index 115a33208..eca0c7af1 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInSummary.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInSummary.vue @@ -10,6 +10,7 @@ import VnLv from 'src/components/ui/VnLv.vue'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; import InvoiceIntoBook from '../InvoiceInToBook.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; +import InvoiceInDescriptorMenu from './InvoiceInDescriptorMenu.vue'; const props = defineProps({ id: { type: [Number, String], default: 0 } }); const { t } = useI18n(); @@ -26,14 +27,14 @@ const intrastatTotals = ref({ amount: 0, net: 0, stems: 0 }); const vatColumns = ref([ { name: 'expense', - label: 'InvoiceIn.summary.expense', + label: 'invoicein.summary.expense', field: (row) => row.expenseFk, sortable: true, align: 'left', }, { name: 'landed', - label: 'InvoiceIn.summary.taxableBase', + label: 'invoicein.summary.taxableBase', field: (row) => row.taxableBase, format: (value) => toCurrency(value), sortable: true, @@ -41,7 +42,7 @@ const vatColumns = ref([ }, { name: 'vat', - label: 'InvoiceIn.summary.sageVat', + label: 'invoicein.summary.sageVat', field: (row) => { if (row.taxTypeSage) return `#${row.taxTypeSage.id} : ${row.taxTypeSage.vat}`; }, @@ -51,7 +52,7 @@ const vatColumns = ref([ }, { name: 'transaction', - label: 'InvoiceIn.summary.sageTransaction', + label: 'invoicein.summary.sageTransaction', field: (row) => { if (row.transactionTypeSage) return `#${row.transactionTypeSage.id} : ${row.transactionTypeSage?.transaction}`; @@ -62,7 +63,7 @@ const vatColumns = ref([ }, { name: 'rate', - label: 'InvoiceIn.summary.rate', + label: 'invoicein.summary.rate', field: (row) => taxRate(row.taxableBase, row.taxTypeSage?.rate), format: (value) => toCurrency(value), sortable: true, @@ -70,7 +71,7 @@ const vatColumns = ref([ }, { name: 'currency', - label: 'InvoiceIn.summary.currency', + label: 'invoicein.summary.currency', field: (row) => row.foreignValue, format: (val) => val && toCurrency(val, currency.value), sortable: true, @@ -81,21 +82,21 @@ const vatColumns = ref([ const dueDayColumns = ref([ { name: 'date', - label: 'InvoiceIn.summary.dueDay', + label: 'invoicein.summary.dueDay', field: (row) => toDate(row.dueDated), sortable: true, align: 'left', }, { name: 'bank', - label: 'InvoiceIn.summary.bank', + label: 'invoicein.summary.bank', field: (row) => row.bank.bank, sortable: true, align: 'left', }, { name: 'amount', - label: 'InvoiceIn.list.amount', + label: 'invoicein.list.amount', field: (row) => row.amount, format: (value) => toCurrency(value), sortable: true, @@ -103,7 +104,7 @@ const dueDayColumns = ref([ }, { name: 'landed', - label: 'InvoiceIn.summary.foreignValue', + label: 'invoicein.summary.foreignValue', field: (row) => row.foreignValue, format: (val) => val && toCurrency(val, currency.value), sortable: true, @@ -114,7 +115,7 @@ const dueDayColumns = ref([ const intrastatColumns = ref([ { name: 'code', - label: 'InvoiceIn.summary.code', + label: 'invoicein.summary.code', field: (row) => { return `${row.intrastat.id}: ${row.intrastat?.description}`; }, @@ -123,21 +124,21 @@ const intrastatColumns = ref([ }, { name: 'amount', - label: 'InvoiceIn.list.amount', + label: 'invoicein.list.amount', field: (row) => toCurrency(row.amount), sortable: true, align: 'left', }, { name: 'net', - label: 'InvoiceIn.summary.net', + label: 'invoicein.summary.net', field: (row) => row.net, sortable: true, align: 'left', }, { name: 'stems', - label: 'InvoiceIn.summary.stems', + label: 'invoicein.summary.stems', field: (row) => row.stems, format: (value) => value, sortable: true, @@ -145,7 +146,7 @@ const intrastatColumns = ref([ }, { name: 'landed', - label: 'InvoiceIn.summary.country', + label: 'invoicein.summary.country', field: (row) => row.country?.code, format: (value) => value, sortable: true, @@ -200,6 +201,9 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; </template> </InvoiceIntoBook> </template> + <template #menu="{ entity }"> + <InvoiceInDescriptorMenu :invoice="entity" /> + </template> <template #body="{ entity }"> <!--Basic Data--> <QCard class="vn-one"> @@ -210,7 +214,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; /> </QCardSection> <VnLv - :label="t('InvoiceIn.list.supplier')" + :label="t('invoicein.list.supplier')" :value="entity.supplier?.name" > <template #value> @@ -221,14 +225,14 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; </template> </VnLv> <VnLv - :label="t('InvoiceIn.list.supplierRef')" + :label="t('invoicein.list.supplierRef')" :value="entity.supplierRef" /> <VnLv - :label="t('InvoiceIn.summary.currency')" + :label="t('invoicein.summary.currency')" :value="entity.currency?.code" /> - <VnLv :label="t('InvoiceIn.serial')" :value="`${entity.serial}`" /> + <VnLv :label="t('invoicein.serial')" :value="`${entity.serial}`" /> <VnLv :label="t('globals.country')" :value="entity.supplier?.country?.code" @@ -243,19 +247,19 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; </QCardSection> <VnLv :ellipsis-value="false" - :label="t('InvoiceIn.summary.issued')" + :label="t('invoicein.summary.issued')" :value="toDate(entity.issued)" /> <VnLv - :label="t('InvoiceIn.summary.operated')" + :label="t('invoicein.summary.operated')" :value="toDate(entity.operated)" /> <VnLv - :label="t('InvoiceIn.summary.bookEntried')" + :label="t('invoicein.summary.bookEntried')" :value="toDate(entity.bookEntried)" /> <VnLv - :label="t('InvoiceIn.summary.bookedDate')" + :label="t('invoicein.summary.bookedDate')" :value="toDate(entity.booked)" /> <VnLv :label="t('globals.isVies')" :value="entity.supplier?.isVies" /> @@ -268,18 +272,18 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; /> </QCardSection> <VnLv - :label="t('InvoiceIn.summary.sage')" + :label="t('invoicein.summary.sage')" :value="entity.sageWithholding?.withholding" /> <VnLv - :label="t('InvoiceIn.summary.vat')" + :label="t('invoicein.summary.vat')" :value="entity.expenseDeductible?.name" /> <VnLv - :label="t('InvoiceIn.card.company')" + :label="t('invoicein.card.company')" :value="entity.company?.code" /> - <VnLv :label="t('InvoiceIn.isBooked')" :value="invoiceIn?.isBooked" /> + <VnLv :label="t('invoicein.isBooked')" :value="invoiceIn?.isBooked" /> </QCard> <QCard class="vn-one"> <QCardSection class="q-pa-none"> @@ -290,11 +294,11 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; </QCardSection> <QCardSection class="q-pa-none"> <VnLv - :label="t('InvoiceIn.summary.taxableBase')" + :label="t('invoicein.summary.taxableBase')" :value="toCurrency(entity.totals.totalTaxableBase)" /> <VnLv label="Total" :value="toCurrency(entity.totals.totalVat)" /> - <VnLv :label="t('InvoiceIn.summary.dueTotal')"> + <VnLv :label="t('invoicein.summary.dueTotal')"> <template #value> <QChip dense @@ -302,8 +306,8 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; :color="amountsNotMatch ? 'negative' : 'transparent'" :title=" amountsNotMatch - ? t('InvoiceIn.summary.noMatch') - : t('InvoiceIn.summary.dueTotal') + ? t('invoicein.summary.noMatch') + : t('invoicein.summary.dueTotal') " > {{ toCurrency(entity.totals.totalDueDay) }} @@ -314,7 +318,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; </QCard> <!--Vat--> <QCard v-if="entity.invoiceInTax.length" class="vat"> - <VnTitle :url="getLink('vat')" :text="t('InvoiceIn.card.vat')" /> + <VnTitle :url="getLink('vat')" :text="t('invoicein.card.vat')" /> <QTable :columns="vatColumns" :rows="entity.invoiceInTax" @@ -362,7 +366,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; </QCard> <!--Due Day--> <QCard v-if="entity.invoiceInDueDay.length" class="due-day"> - <VnTitle :url="getLink('due-day')" :text="t('InvoiceIn.card.dueDay')" /> + <VnTitle :url="getLink('due-day')" :text="t('invoicein.card.dueDay')" /> <QTable :columns="dueDayColumns" :rows="entity.invoiceInDueDay" flat> <template #header="dueDayProps"> <QTr :props="dueDayProps" class="bg"> @@ -400,7 +404,7 @@ const getLink = (param) => `#/invoice-in/${entityId.value}/${param}`; <QCard v-if="entity.invoiceInIntrastat.length"> <VnTitle :url="getLink('intrastat')" - :text="t('InvoiceIn.card.intrastat')" + :text="t('invoicein.card.intrastat')" /> <QTable :columns="intrastatColumns" diff --git a/src/pages/InvoiceIn/InvoiceInCreate.vue b/src/pages/InvoiceIn/InvoiceInCreate.vue index 200997f65..f180410aa 100644 --- a/src/pages/InvoiceIn/InvoiceInCreate.vue +++ b/src/pages/InvoiceIn/InvoiceInCreate.vue @@ -83,7 +83,7 @@ const redirectToInvoiceInBasicData = (__, { id }) => { </template> </VnSelect> <VnInput - :label="t('InvoiceIn.list.supplierRef')" + :label="t('invoicein.list.supplierRef')" v-model="data.supplierRef" /> </VnRow> @@ -97,10 +97,10 @@ const redirectToInvoiceInBasicData = (__, { id }) => { map-options hide-selected :required="true" - :rules="validate('InvoiceIn.companyFk')" + :rules="validate('invoicein.companyFk')" /> <VnInputDate - :label="t('InvoiceIn.summary.issued')" + :label="t('invoicein.summary.issued')" v-model="data.issued" /> </VnRow> diff --git a/src/pages/InvoiceIn/InvoiceInFilter.vue b/src/pages/InvoiceIn/InvoiceInFilter.vue index 653692026..31a611936 100644 --- a/src/pages/InvoiceIn/InvoiceInFilter.vue +++ b/src/pages/InvoiceIn/InvoiceInFilter.vue @@ -68,13 +68,26 @@ function handleDaysAgo(params, daysAgo) { <VnSelect v-model="params.supplierFk" url="Suppliers" - :fields="['id', 'nickname']" + :fields="['id', 'nickname', 'name']" :label="getLocale('supplierFk')" option-label="nickname" dense outlined rounded - /> + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel> + {{ scope.opt?.name}} + </QItemLabel> + <QItemLabel caption> + {{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }} + </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> </QItemSection> </QItem> <QItem> @@ -151,7 +164,7 @@ function handleDaysAgo(params, daysAgo) { <QItem> <QItemSection> <QCheckbox - :label="$t('InvoiceIn.isBooked')" + :label="$t('invoicein.isBooked')" v-model="params.isBooked" @update:model-value="searchFn()" toggle-indeterminate diff --git a/src/pages/InvoiceIn/InvoiceInList.vue b/src/pages/InvoiceIn/InvoiceInList.vue index db6e7d214..5e80ae652 100644 --- a/src/pages/InvoiceIn/InvoiceInList.vue +++ b/src/pages/InvoiceIn/InvoiceInList.vue @@ -26,7 +26,7 @@ const cols = computed(() => [ { align: 'left', name: 'isBooked', - label: t('InvoiceIn.isBooked'), + label: t('invoicein.isBooked'), columnFilter: false, }, { @@ -41,7 +41,7 @@ const cols = computed(() => [ { align: 'left', name: 'supplierFk', - label: t('InvoiceIn.list.supplier'), + label: t('invoicein.list.supplier'), columnFilter: { component: 'select', attrs: { @@ -55,16 +55,16 @@ const cols = computed(() => [ { align: 'left', name: 'supplierRef', - label: t('InvoiceIn.list.supplierRef'), + label: t('invoicein.list.supplierRef'), }, { align: 'left', name: 'serial', - label: t('InvoiceIn.serial'), + label: t('invoicein.serial'), }, { align: 'left', - label: t('InvoiceIn.list.issued'), + label: t('invoicein.list.issued'), name: 'issued', component: null, columnFilter: { @@ -74,7 +74,7 @@ const cols = computed(() => [ }, { align: 'left', - label: t('InvoiceIn.list.dueDated'), + label: t('invoicein.list.dueDated'), name: 'dueDated', component: null, columnFilter: { @@ -86,12 +86,12 @@ const cols = computed(() => [ { align: 'left', name: 'awbCode', - label: t('InvoiceIn.list.awb'), + label: t('invoicein.list.awb'), }, { align: 'left', name: 'amount', - label: t('InvoiceIn.list.amount'), + label: t('invoicein.list.amount'), format: ({ amount }) => toCurrency(amount), cardVisible: true, }, @@ -108,19 +108,6 @@ const cols = computed(() => [ }, format: (row) => row.code, }, - { - name: 'companyFk', - label: t('globals.company'), - columnFilter: { - component: 'select', - attrs: { - url: 'Companies', - fields: ['id', 'code'], - optionLabel: 'code', - }, - }, - format: (row) => row.code, - }, { align: 'right', name: 'tableActions', @@ -178,24 +165,24 @@ const cols = computed(() => [ <VnSelect v-model="data.supplierFk" url="Suppliers" - :fields="['id', 'nickname']" + :fields="['id', 'nickname', 'name']" :label="t('globals.supplier')" option-value="id" option-label="nickname" - :filter-options="['id', 'name']" + :filter-options="['id', 'name', 'nickname']" :required="true" > <template #option="scope"> <QItem v-bind="scope.itemProps"> <QItemSection> <QItemLabel>{{ scope.opt?.nickname }}</QItemLabel> - <QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel> + <QItemLabel caption> #{{ scope.opt?.id }}, {{ scope.opt?.name }} </QItemLabel> </QItemSection> </QItem> </template> </VnSelect> <VnInput - :label="t('InvoiceIn.list.supplierRef')" + :label="t('invoicein.list.supplierRef')" v-model="data.supplierRef" /> <VnSelect @@ -207,7 +194,7 @@ const cols = computed(() => [ option-label="code" :required="true" /> - <VnInputDate :label="t('InvoiceIn.summary.issued')" v-model="data.issued" /> + <VnInputDate :label="t('invoicein.summary.issued')" v-model="data.issued" /> </template> </VnTable> </template> diff --git a/src/pages/InvoiceIn/locale/en.yml b/src/pages/InvoiceIn/locale/en.yml index ef7e31ac3..94db50066 100644 --- a/src/pages/InvoiceIn/locale/en.yml +++ b/src/pages/InvoiceIn/locale/en.yml @@ -1,4 +1,4 @@ -InvoiceIn: +invoicein: serial: Serial isBooked: Is booked list: @@ -12,6 +12,26 @@ InvoiceIn: amount: Amount descriptor: ticketList: Ticket list + descriptorMenu: + book: Book + unbook: Unbook + delete: Delete + clone: Clone + toBook: To book + toUnbook: To unbook + deleteInvoice: Delete invoice + invoiceDeleted: invoice deleted + cloneInvoice: Clone invoice + invoiceCloned: Invoice cloned + showAgriculturalPdf: Show agricultural receipt as PDF + sendAgriculturalPdf: Send agricultural receipt as PDF + checkSendInvoice: Are you sure you want to send it? + sendPdfInvoice: Send PDF invoice + createCorrective: Create rectificative invoice + correctiveInvoice: Rectificative invoice + originalInvoice: Original invoice + entry: Entry + emailEmpty: The email can't be empty card: client: Client company: Company @@ -44,7 +64,8 @@ InvoiceIn: country: Country params: search: Id or supplier name - account: Ledger account - correctingFk: Rectificative correctedFk: Corrected isBooked: Is booked + account: Ledger account + correctingFk: Rectificative + \ No newline at end of file diff --git a/src/pages/InvoiceIn/locale/es.yml b/src/pages/InvoiceIn/locale/es.yml index ed5943489..bcb9c0551 100644 --- a/src/pages/InvoiceIn/locale/es.yml +++ b/src/pages/InvoiceIn/locale/es.yml @@ -1,4 +1,4 @@ -InvoiceIn: +invoicein: serial: Serie isBooked: Contabilizada list: @@ -12,6 +12,26 @@ InvoiceIn: amount: Importe descriptor: ticketList: Listado de tickets + descriptorMenu: + book: Asentar + unbook: Desasentar + delete: Eliminar + clone: Clonar + toBook: Contabilizar + toUnbook: Descontabilizar + deleteInvoice: Eliminar factura + invoiceDeleted: Factura eliminada + cloneInvoice: Clonar factura + invoiceCloned: Factura clonada + showAgriculturalPdf: Ver recibo agrícola como PDF + sendAgriculturalPdf: Enviar recibo agrícola como PDF + checkSendInvoice: ¿Estás seguro que quieres enviarlo? + sendPdfInvoice: Enviar factura a PDF + createCorrective: Crear factura rectificativa + correctiveInvoice: Factura rectificativa + originalInvoice: Factura origen + entry: Entrada + emailEmpty: El email no puede estar vacío card: client: Cliente company: Empresa @@ -42,6 +62,7 @@ InvoiceIn: country: País params: search: Id o nombre proveedor + correctedFk: Rectificada account: Cuenta contable correctingFk: Rectificativa - correctedFk: Rectificada + diff --git a/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue b/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue index 81b3e7c41..3ceb447dd 100644 --- a/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue +++ b/src/pages/InvoiceOut/Card/InvoiceOutSummary.vue @@ -10,6 +10,7 @@ import { getUrl } from 'src/composables/getUrl'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; +import InvoiceOutDescriptorMenu from './InvoiceOutDescriptorMenu.vue'; onMounted(async () => { fetch(); @@ -113,6 +114,9 @@ const ticketsColumns = ref([ <template #header="{ entity: { invoiceOut } }"> <div>{{ invoiceOut.ref }} - {{ invoiceOut.client?.socialName }}</div> </template> + <template #menu="{ entity }"> + <InvoiceOutDescriptorMenu :invoice-out-data="entity.invoiceOut" /> + </template> <template #body="{ entity: { invoiceOut } }"> <QCard class="vn-one"> <VnTitle :text="t('globals.pageTitles.basicData')" /> diff --git a/src/pages/InvoiceOut/InvoiceOutFilter.vue b/src/pages/InvoiceOut/InvoiceOutFilter.vue index dc1d833a2..cdc9f037a 100644 --- a/src/pages/InvoiceOut/InvoiceOutFilter.vue +++ b/src/pages/InvoiceOut/InvoiceOutFilter.vue @@ -47,6 +47,7 @@ const states = ref(); :label="t('Amount')" v-model="params.amount" is-outlined + data-cy="InvoiceOutFilterAmountBtn" /> </QItemSection> </QItem> diff --git a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue index e6c689523..392256473 100644 --- a/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue +++ b/src/pages/InvoiceOut/InvoiceOutGlobalForm.vue @@ -101,6 +101,7 @@ onMounted(async () => { dense outlined rounded + data-cy="InvoiceOutGlobalClientSelect" > <template #option="scope"> <QItem v-bind="scope.itemProps"> @@ -125,6 +126,7 @@ onMounted(async () => { dense outlined rounded + data-cy="InvoiceOutGlobalSerialSelect" /> <VnInputDate v-model="formData.invoiceDate" @@ -135,6 +137,7 @@ onMounted(async () => { v-model="formData.maxShipped" :label="t('maxShipped')" is-outlined + data-cy="InvoiceOutGlobalMaxShippedDate" /> <VnSelect :label="t('company')" @@ -144,6 +147,7 @@ onMounted(async () => { dense outlined rounded + data-cy="InvoiceOutGlobalCompanySelect" /> <VnSelect :label="t('printer')" @@ -152,6 +156,7 @@ onMounted(async () => { dense outlined rounded + data-cy="InvoiceOutGlobalPrinterSelect" /> </div> <QBtn diff --git a/src/pages/InvoiceOut/InvoiceOutList.vue b/src/pages/InvoiceOut/InvoiceOutList.vue index 89b109c3c..09873642d 100644 --- a/src/pages/InvoiceOut/InvoiceOutList.vue +++ b/src/pages/InvoiceOut/InvoiceOutList.vue @@ -126,6 +126,13 @@ const columns = computed(() => [ columnField: { component: null }, format: (row) => toDate(row.dued), }, + { + align: 'left', + name: 'customsAgentFk', + label: t('invoiceOutList.tableVisibleColumns.customsAgent'), + cardVisible: true, + format: (row, dashIfEmpty) => dashIfEmpty(row.customsAgentName), + }, { align: 'right', name: 'tableActions', @@ -190,6 +197,7 @@ watchEffect(selectedRows); icon-right="cloud_download" @click="downloadPdf()" :disable="!hasSelectedCards" + data-cy="InvoiceOutDownloadPdfBtn" > <QTooltip>{{ t('downloadPdf') }}</QTooltip> </QBtn> @@ -238,6 +246,7 @@ watchEffect(selectedRows); v-model="data.ticketFk" :label="t('globals.ticket')" style="flex: 1" + data-cy="InvoiceOutCreateTicketinput" /> <div @@ -346,12 +355,13 @@ watchEffect(selectedRows); <VnSelect url="InvoiceOutSerials" v-model="data.serial" - :label="t('invoiceIn.serial')" + :label="t('invoicein.serial')" :options="invoiceOutSerialsOptions" option-label="description" option-value="code" option-filter :expr-builder="exprBuilder" + data-cy="InvoiceOutCreateSerialSelect" > <template #option="scope"> <QItem v-bind="scope.itemProps"> diff --git a/src/pages/InvoiceOut/locale/en.yml b/src/pages/InvoiceOut/locale/en.yml index 8cefe8bdc..f31e5a07c 100644 --- a/src/pages/InvoiceOut/locale/en.yml +++ b/src/pages/InvoiceOut/locale/en.yml @@ -13,6 +13,7 @@ invoiceOutList: invoiceOutSerial: Serial ticket: Ticket taxArea: Tax area + customsAgent: Custom Agent DownloadPdf: Download PDF InvoiceOutSummary: Summary negativeBases: @@ -24,3 +25,15 @@ negativeBases: hasToInvoice: Has to invoice verifiedData: Verified data commercial: Commercial +invoiceout: + params: + company: Company + country: Country + clientId: Client ID + clientSocialName: Client + taxableBase: Base + ticketFk: Ticket + isActive: Active + hasToInvoice: Has to invoice + hasVerifiedData: Verified data + workerName: Worker \ No newline at end of file diff --git a/src/pages/InvoiceOut/locale/es.yml b/src/pages/InvoiceOut/locale/es.yml index 106168a5d..deca8bdea 100644 --- a/src/pages/InvoiceOut/locale/es.yml +++ b/src/pages/InvoiceOut/locale/es.yml @@ -15,6 +15,7 @@ invoiceOutList: invoiceOutSerial: Serial ticket: Ticket taxArea: Area + customsAgent: Agente de aduanas DownloadPdf: Descargar PDF InvoiceOutSummary: Resumen negativeBases: @@ -27,3 +28,15 @@ negativeBases: hasToInvoice: Debe facturar verifiedData: Datos verificados commercial: Comercial +invoiceout: + params: + company: Empresa + country: País + clientId: ID del cliente + clientSocialName: Cliente + taxableBase: Base + ticketFk: Ticket + isActive: Activo + hasToInvoice: Debe facturar + hasVerifiedData: Datos verificados + workerName: Comercial \ No newline at end of file diff --git a/src/pages/Item/Card/ItemBasicData.vue b/src/pages/Item/Card/ItemBasicData.vue index a1788617f..4c96401f3 100644 --- a/src/pages/Item/Card/ItemBasicData.vue +++ b/src/pages/Item/Card/ItemBasicData.vue @@ -203,6 +203,12 @@ const onIntrastatCreated = (response, formData) => { v-model="data.hasKgPrice" :label="t('item.basicData.hasKgPrice')" /> + <QCheckbox + v-model="data.isCustomInspectionRequired" + :label="t('item.basicData.isCustomInspectionRequired')" + /> + </VnRow> + <VnRow class="row q-gutter-md q-mb-md"> <div> <QCheckbox v-model="data.isFragile" diff --git a/src/pages/Item/Card/ItemBotanical.vue b/src/pages/Item/Card/ItemBotanical.vue index 57774f75e..4894d94fc 100644 --- a/src/pages/Item/Card/ItemBotanical.vue +++ b/src/pages/Item/Card/ItemBotanical.vue @@ -52,6 +52,7 @@ const entityId = computed(() => { :fields="['id', 'name']" sort-by="name ASC" hide-selected + data-cy="AddGenusSelectDialog" > <template #form> <CreateGenusForm @@ -68,6 +69,7 @@ const entityId = computed(() => { :fields="['id', 'name']" sort-by="name ASC" hide-selected + data-cy="AddSpeciesSelectDialog" > <template #form> <CreateSpecieForm diff --git a/src/pages/Item/Card/ItemDescriptor.vue b/src/pages/Item/Card/ItemDescriptor.vue index 4705525fb..c6fee8540 100644 --- a/src/pages/Item/Card/ItemDescriptor.vue +++ b/src/pages/Item/Card/ItemDescriptor.vue @@ -6,17 +6,16 @@ import { useI18n } from 'vue-i18n'; import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; -import RegularizeStockForm from 'components/RegularizeStockForm.vue'; import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue'; import useCardDescription from 'src/composables/useCardDescription'; import axios from 'axios'; import { dashIfEmpty } from 'src/filters'; import { useArrayData } from 'src/composables/useArrayData'; -import { cloneItem } from 'src/pages/Item/composables/cloneItem'; +import ItemDescriptorMenu from './ItemDescriptorMenu.vue'; const $props = defineProps({ id: { - type: [Number, String], + type: Number, required: false, default: null, }, @@ -29,7 +28,7 @@ const $props = defineProps({ default: null, }, saleFk: { - type: [Number, String], + type: Number, default: null, }, warehouseFk: { @@ -38,7 +37,6 @@ const $props = defineProps({ }, }); -const { openCloneDialog } = cloneItem(); const route = useRoute(); const { t } = useI18n(); const warehouseConfig = ref(null); @@ -46,7 +44,6 @@ const entityId = computed(() => { return $props.id || route.params.id; }); -const regularizeStockFormDialog = ref(null); const mounted = ref(); const arrayDataStock = useArrayData('descriptorStock', { @@ -61,14 +58,14 @@ onMounted(async () => { const data = ref(useCardDescription()); const setData = async (entity) => { if (!entity) return; - data.value = useCardDescription(entity?.name, entity?.id); + data.value = useCardDescription(entity.name, entity.id); await updateStock(); }; const getItemConfigs = async () => { const { data } = await axios.get('ItemConfigs/findOne'); if (!data) return; - return (warehouseConfig.value = data.warehouseFk); + warehouseConfig.value = data.warehouseFk; }; const updateStock = async () => { if (!mounted.value) return; @@ -89,10 +86,6 @@ const updateStock = async () => { if (storeData?.itemFk == entityId.value) return; await stock.fetch({}); }; - -const openRegularizeStockForm = () => { - regularizeStockFormDialog.value.show(); -}; </script> <template> @@ -105,24 +98,12 @@ const openRegularizeStockForm = () => { :url="`Items/${entityId}/getCard`" @on-fetch="setData" > - <template #menu="{}"> - <QItem v-ripple clickable @click="openRegularizeStockForm()"> - <QItemSection> - {{ t('Regularize stock') }} - <QDialog ref="regularizeStockFormDialog"> - <RegularizeStockForm - :item-fk="entityId" - :warehouse-fk="warehouseFk" - @on-data-saved="updateStock()" - /> - </QDialog> - </QItemSection> - </QItem> - <QItem v-ripple clickable @click="openCloneDialog(entityId)"> - <QItemSection> - {{ t('globals.clone') }} - </QItemSection> - </QItem> + <template #menu> + <ItemDescriptorMenu + :entity-id="entityId" + :warehouse-fk="warehouseFk" + @regularized="updateStock" + /> </template> <template #before> <ItemDescriptorImage @@ -191,7 +172,6 @@ const openRegularizeStockForm = () => { <i18n> es: - Regularize stock: Regularizar stock Inactive article: Artículo inactivo </i18n> diff --git a/src/pages/Item/Card/ItemDescriptorImage.vue b/src/pages/Item/Card/ItemDescriptorImage.vue index 05185c589..a887964e9 100644 --- a/src/pages/Item/Card/ItemDescriptorImage.vue +++ b/src/pages/Item/Card/ItemDescriptorImage.vue @@ -131,7 +131,6 @@ const handlePhotoUpdated = (evt = false) => { <i18n> es: - Regularize stock: Regularizar stock All it's properties will be copied: Todas sus propiedades serán copiadas Do you want to clone this item?: ¿Desea clonar este artículo? warehouseText: Calculado sobre el almacén de { warehouseName } diff --git a/src/pages/Item/Card/ItemDescriptorMenu.vue b/src/pages/Item/Card/ItemDescriptorMenu.vue new file mode 100644 index 000000000..3e9c6f2d4 --- /dev/null +++ b/src/pages/Item/Card/ItemDescriptorMenu.vue @@ -0,0 +1,44 @@ +<script setup> +import RegularizeStockForm from 'components/RegularizeStockForm.vue'; +import { cloneItem } from 'src/pages/Item/composables/cloneItem'; + +const { openCloneDialog } = cloneItem(); + +defineProps({ + entityId: { + type: Number, + default: null, + }, + warehouseFk: { + type: Number, + default: null, + }, +}); + +defineEmits(['regularized']); +</script> +<template> + <QItem v-ripple clickable @click="$refs.regularizeStockFormDialog.show()"> + <QItemSection> + {{ $t('item.regularizeStock') }} + <QDialog ref="regularizeStockFormDialog"> + <RegularizeStockForm + :item-fk="entityId" + :warehouse-fk="warehouseFk" + @on-data-saved="$emit('regularized')" + /> + </QDialog> + </QItemSection> + </QItem> + <QItem v-ripple clickable @click="openCloneDialog(entityId)"> + <QItemSection> + {{ $t('globals.clone') }} + </QItemSection> + </QItem> +</template> + +<style lang="scss" scoped> +.weekdaysBtn { + margin: 1%; +} +</style> diff --git a/src/pages/Item/Card/ItemDiary.vue b/src/pages/Item/Card/ItemDiary.vue index b94ff9255..96a003a09 100644 --- a/src/pages/Item/Card/ItemDiary.vue +++ b/src/pages/Item/Card/ItemDiary.vue @@ -233,7 +233,7 @@ async function updateWarehouse(warehouseFk) { </div> </template> </VnSubToolbar> - <QPage class="column items-center q-pa-md"> + <QPage class="column items-center"> <QTable :rows="itemBalances" :columns="columns" diff --git a/src/pages/Item/Card/ItemLastEntries.vue b/src/pages/Item/Card/ItemLastEntries.vue index 533513ff7..c2df553c3 100644 --- a/src/pages/Item/Card/ItemLastEntries.vue +++ b/src/pages/Item/Card/ItemLastEntries.vue @@ -10,21 +10,12 @@ import { dashIfEmpty } from 'src/filters'; import { toCurrency } from 'filters/index'; import { useArrayData } from 'composables/useArrayData'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; -import axios from 'axios'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; const { t } = useI18n(); const route = useRoute(); const from = ref(); const to = ref(); -const hideInventory = ref(true); -const inventorySupplierFk = ref(); - -async function getInventorySupplier() { - inventorySupplierFk.value = ( - await axios.get(`InventoryConfigs`) - )?.data[0]?.supplierFk; -} const exprBuilder = (param, value) => { switch (param) { @@ -49,10 +40,6 @@ const where = { itemFk: route.params.id, }; -if (hideInventory.value) { - where.supplierFk = { neq: inventorySupplierFk }; -} - const arrayData = useArrayData('ItemLastEntries', { url: 'Items/lastEntriesFilter', order: ['landed DESC', 'buyFk DESC'], @@ -110,7 +97,7 @@ const columns = computed(() => [ format: (val) => dashIfEmpty(val), }, { - label: t('shelvings.packing'), + label: 'Packing', name: 'packing', field: 'packing', align: 'center', @@ -182,15 +169,11 @@ const updateFilter = async () => { const userFilter = arrayData.store.userFilter.where; userFilter.landed = filter; - if (hideInventory.value) userFilter.supplierFk = { neq: inventorySupplierFk }; - else delete userFilter.supplierFk; await fetchItemLastEntries(); }; onMounted(async () => { - await getInventorySupplier(); - const _from = Date.vnNew(); _from.setDate(_from.getDate() - 75); from.value = getDate(_from, 'from'); @@ -200,12 +183,16 @@ onMounted(async () => { updateFilter(); - watch([from, to, hideInventory], ([nFrom, nTo], [oFrom, oTo]) => { + watch([from, to], ([nFrom, nTo], [oFrom, oTo]) => { if (nFrom && nFrom != oFrom) nFrom = getDate(new Date(nFrom), 'from'); if (nTo && nTo != oTo) nTo = getDate(new Date(nTo), 'to'); updateFilter(); }); }); + +function getBadgeClass(groupingMode, expectedGrouping) { + return groupingMode === expectedGrouping ? 'accent-badge' : 'simple-badge'; +} </script> <template> <VnSubToolbar> @@ -224,13 +211,6 @@ onMounted(async () => { class="q-mr-lg" data-cy="to" /> - <QCheckbox - :label="t('Hide inventory supplier')" - v-model="hideInventory" - dense - class="q-mr-lg" - data-cy="hideInventory" - /> </template> </VnSubToolbar> <QPage class="column items-center q-pa-xd"> @@ -249,6 +229,11 @@ onMounted(async () => { /> </QTd> </template> + <template #body-cell-warehouse="{ row }"> + <QTd> + <span>{{ row.warehouse }}</span> + </QTd> + </template> <template #body-cell-date="{ row }"> <QTd class="text-center"> <VnDateBadge :date="row.landed" /> @@ -262,32 +247,37 @@ onMounted(async () => { </div> </QTd> </template> + <template #body-cell-pvp="{ value }"> + <QTd @click.stop class="text-center"> + <span> {{ value }}</span> + <QTooltip> {{ t('lastEntries.grouping') }}/Packing </QTooltip></QTd + > + </template> + <template #body-cell-printedStickers="{ row }"> + <QTd @click.stop class="text-center"> + <span style="color: var(--vn-label-color)"> + {{ row.printedStickers }}</span + > + </QTd> + </template> <template #body-cell-packing="{ row }"> <QTd @click.stop> <QBadge class="center-content" + :class="getBadgeClass(row.groupingMode, 'packing')" rounded - :color="row.groupingMode == 'packing' ? 'grey-13' : 'black'" > {{ dashIfEmpty(row.packing) }} - <QTooltip>{{ t('lastEntries.packing') }}</QTooltip> + <QTooltip>Packing</QTooltip> </QBadge> </QTd> </template> - <template #body-cell-pvp="{ value }"> - <QTd @click.stop class="text-center"> - <span> {{ value }}</span> - <QTooltip> - {{ t('lastEntries.grouping') }}/{{ t('lastEntries.packing') }} - </QTooltip></QTd - > - </template> <template #body-cell-grouping="{ row }"> <QTd @click.stop> <QBadge class="center-content" + :class="getBadgeClass(row.groupingMode, 'grouping')" rounded - :color="row.groupingMode == 'grouping' ? 'grey-13' : 'black'" > {{ dashIfEmpty(row.grouping) }} <QTooltip>{{ t('lastEntries.grouping') }}</QTooltip> @@ -315,13 +305,16 @@ onMounted(async () => { </template> <template #body-cell-supplier="{ row }"> <QTd @click.stop> - <div class="full-width flex justify-center"> - <SupplierDescriptorProxy - :id="row.supplierFk" - class="q-ma-none" + <div class="full-width flex justify-left"> + <QBadge + :class=" + row.isInventorySupplier ? 'bg-vn-page' : 'transparent' + " dense - /> - <span class="link">{{ row.supplier }}</span> + > + <SupplierDescriptorProxy :id="row.supplierFk" /> + <span class="link">{{ row.supplier }}</span> + </QBadge> </div> </QTd> </template> @@ -349,4 +342,13 @@ onMounted(async () => { background-color: red; } } +.accent-badge { + background-color: var(--vn-label-color); + color: var(--vn-text-color-contrast); +} +.simple-badge { + background-color: transparent; + color: var(--vn-text-color); + font-size: 14px; +} </style> diff --git a/src/pages/Item/Card/ItemSummary.vue b/src/pages/Item/Card/ItemSummary.vue index e1b97d7c9..bc828bbf6 100644 --- a/src/pages/Item/Card/ItemSummary.vue +++ b/src/pages/Item/Card/ItemSummary.vue @@ -8,6 +8,7 @@ import VnLv from 'src/components/ui/VnLv.vue'; import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; +import ItemDescriptorMenu from './ItemDescriptorMenu.vue'; const $props = defineProps({ id: { @@ -43,10 +44,13 @@ const getUrl = (id, param) => `#/Item/${id}/${param}`; <template #header="{ entity: { item } }"> {{ item.id }} - {{ item.name }} </template> + <template #menu> + <ItemDescriptorMenu :entity-id="entityId" :warehouse-fk="warehouseFk" /> + </template> <template #body="{ entity: { item, tags, visible, available, botanical } }"> <QCard class="vn-one photo"> <ItemDescriptorImage - :entity-id="Number(entityId)" + :entity-id="entityId" :visible="visible" :available="available" :show-edit-button="false" @@ -89,7 +93,7 @@ const getUrl = (id, param) => `#/Item/${id}/${param}`; <QCard class="vn-one"> <VnTitle :url="getUrl(entityId, 'basic-data')" - :text="t('item.summary.basicData')" + :text="t('item.summary.otherData')" /> <VnLv :label="t('item.summary.intrastatCode')" diff --git a/src/pages/Item/Card/ItemTags.vue b/src/pages/Item/Card/ItemTags.vue index fbb0e01a7..992b1042b 100644 --- a/src/pages/Item/Card/ItemTags.vue +++ b/src/pages/Item/Card/ItemTags.vue @@ -107,7 +107,7 @@ const submitTags = async (data) => { @on-fetch="onItemTagsFetched" > <template #body="{ rows, validate }"> - <QCard class="q-px-lg q-pt-md q-pb-sm"> + <QCard class="q-px-lg q-pt-md q-pb-sm" data-cy="itemTags"> <VnRow v-for="(row, index) in rows" :key="index" @@ -128,7 +128,7 @@ const submitTags = async (data) => { <VnSelect v-if="row.tag?.isFree === false" :key="row.tagFk" - :label="t('Value')" + :label="t('itemTags.value')" v-model="row.value" :url="`Tags/${row.tagFk}/filterValue`" option-label="value" diff --git a/src/pages/Item/ItemFixedPrice.vue b/src/pages/Item/ItemFixedPrice.vue index 74403d471..53d300a3b 100644 --- a/src/pages/Item/ItemFixedPrice.vue +++ b/src/pages/Item/ItemFixedPrice.vue @@ -35,6 +35,7 @@ const editTableCellDialogRef = ref(null); const user = state.getUser(); const fixedPrices = ref([]); const warehousesOptions = ref([]); +const hasSelectedRows = computed(() => rowsSelected.value.length > 0); const rowsSelected = ref([]); const itemFixedPriceFilterRef = ref(); @@ -53,7 +54,6 @@ const columns = computed(() => [ name: 'itemFk', ...defaultColumnAttrs, isId: true, - cardVisible: true, columnField: { component: 'input', type: 'number', @@ -65,14 +65,12 @@ const columns = computed(() => [ name: 'name', ...defaultColumnAttrs, create: true, - cardVisible: true, }, { label: t('item.fixedPrice.groupingPrice'), field: 'rate2', name: 'rate2', ...defaultColumnAttrs, - cardVisible: true, component: 'input', type: 'number', }, @@ -81,7 +79,6 @@ const columns = computed(() => [ field: 'rate3', name: 'rate3', ...defaultColumnAttrs, - cardVisible: true, component: 'input', type: 'number', }, @@ -91,7 +88,6 @@ const columns = computed(() => [ field: 'minPrice', name: 'minPrice', ...defaultColumnAttrs, - cardVisible: true, component: 'input', type: 'number', }, @@ -100,7 +96,6 @@ const columns = computed(() => [ field: 'started', name: 'started', format: ({ started }) => toDate(started), - cardVisible: true, ...defaultColumnAttrs, columnField: { component: 'date', @@ -116,7 +111,6 @@ const columns = computed(() => [ field: 'ended', name: 'ended', ...defaultColumnAttrs, - cardVisible: true, columnField: { component: 'date', class: 'shrink', @@ -251,11 +245,14 @@ const upsertPrice = async (props, resetMinPrice = false) => { } if (!changes.updates && !changes.creates) return; const data = await upsertFixedPrice(row); - tableRef.value.CrudModelRef.formData[props.rowIndex] = data; + Object.assign(tableRef.value.CrudModelRef.formData[props.rowIndex], data); + notify(t('globals.dataSaved'), 'positive'); + tableRef.value.reload(); }; async function upsertFixedPrice(row) { const { data } = await axios.patch('FixedPrices/upsertFixedPrice', row); + data.hasMinPrice = data.hasMinPrice ? 1 : 0; return data; } @@ -372,9 +369,9 @@ function handleOnDataSave({ CrudModelRef }) { </template> </RightMenu> <VnSubToolbar> - <template #st-data> + <template #st-actions> <QBtn - v-if="rowsSelected.length" + :disable="!hasSelectedRows" @click="openEditTableCellDialog()" color="primary" icon="edit" @@ -384,29 +381,23 @@ function handleOnDataSave({ CrudModelRef }) { </QTooltip> </QBtn> <QBtn + :disable="!hasSelectedRows" :label="tMobile('globals.remove')" color="primary" icon="delete" flat @click="(row) => confirmRemove(row, true)" :title="t('globals.remove')" - v-if="rowsSelected.length" /> </template> </VnSubToolbar> <VnTable - @on-fetch=" - (data) => - data.forEach((item) => { - item.hasMinPrice = `${item.hasMinPrice !== 0}`; - }) - " :default-remove="false" :default-reset="false" :default-save="false" data-key="ItemFixedPrices" url="FixedPrices/filter" - :order="['itemFk DESC', 'name DESC']" + :order="['name DESC', 'itemFk DESC']" save-url="FixedPrices/crud" ref="tableRef" dense @@ -498,14 +489,15 @@ function handleOnDataSave({ CrudModelRef }) { <QCheckbox :model-value="props.row.hasMinPrice" @update:model-value="updateMinPrice($event, props)" - :false-value="'false'" - :true-value="'true'" + :false-value="0" + :true-value="1" + :toggle-indeterminate="false" /> <VnInput class="col" type="currency" mask="###.##" - :disable="props.row.hasMinPrice === 1" + :disable="props.row.hasMinPrice === 0" v-model.number="props.row.minPrice" v-on="getRowUpdateInputEvents(props)" > diff --git a/src/pages/Item/ItemList.vue b/src/pages/Item/ItemList.vue index 4aa3b13fe..f04563791 100644 --- a/src/pages/Item/ItemList.vue +++ b/src/pages/Item/ItemList.vue @@ -1,5 +1,5 @@ <script setup> -import { ref, computed } from 'vue'; +import { ref, computed, onBeforeMount } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import VnImg from 'src/components/ui/VnImg.vue'; @@ -15,6 +15,9 @@ import ItemTypeDescriptorProxy from './ItemType/Card/ItemTypeDescriptorProxy.vue import { cloneItem } from 'src/pages/Item/composables/cloneItem'; import RightMenu from 'src/components/common/RightMenu.vue'; import ItemListFilter from './ItemListFilter.vue'; +import VnInput from 'src/components/common/VnInput.vue'; +import VnSelect from 'src/components/common/VnSelect.vue'; +import axios from 'axios'; const entityId = computed(() => route.params.id); const { openCloneDialog } = cloneItem(); @@ -22,7 +25,9 @@ const { viewSummary } = useSummaryDialog(); const { t } = useI18n(); const tableRef = ref(); const route = useRoute(); - +const validPriorities = ref([]); +const defaultTag = ref(); +const defaultPriority = ref(); const itemFilter = { include: [ { @@ -90,7 +95,6 @@ const columns = computed(() => [ label: t('globals.description'), name: 'description', align: 'left', - create: true, columnFilter: { name: 'search', }, @@ -132,13 +136,23 @@ const columns = computed(() => [ fields: ['id', 'name'], }, }, - create: true, visible: false, }, { label: t('item.list.typeName'), name: 'typeName', align: 'left', + component: 'select', + columnFilter: { + name: 'typeFk', + attrs: { + url: 'ItemTypes', + fields: ['id', 'name'], + }, + }, + columnField: { + component: null, + }, }, { label: t('item.list.category'), @@ -161,6 +175,11 @@ const columns = computed(() => [ name: 'intrastat', align: 'left', component: 'select', + attrs: { + url: 'Intrastats', + optionValue: 'description', + optionLabel: 'description', + }, columnFilter: { name: 'intrastat', attrs: { @@ -172,7 +191,6 @@ const columns = computed(() => [ columnField: { component: null, }, - create: true, cardVisible: true, }, { @@ -198,7 +216,6 @@ const columns = computed(() => [ columnField: { component: null, }, - create: true, cardVisible: true, }, { @@ -297,12 +314,21 @@ const columns = computed(() => [ ], }, ]); + +onBeforeMount(async () => { + const { data } = await axios.get('ItemConfigs'); + defaultTag.value = data[0].defaultTag; + defaultPriority.value = data[0].defaultPriority; + data.forEach((priority) => { + validPriorities.value = priority.validPriorities; + }); +}); </script> <template> <VnSearchbar data-key="ItemList" :label="t('item.searchbar.label')" - :info="t('You can search by id')" + :info="t('item.searchbar.info')" /> <RightMenu> <template #right-panel> @@ -310,15 +336,18 @@ const columns = computed(() => [ </template> </RightMenu> <VnTable + v-if="defaultTag" ref="tableRef" data-key="ItemList" url="Items/filter" :create="{ - urlCreate: 'Items', - title: t('Create Item'), - onDataSaved: () => tableRef.redirect(), + urlCreate: 'Items/new', + title: t('item.list.newItem'), + onDataSaved: ({ id }) => tableRef.redirect(`${id}/basic-data`), formInitialData: { editorFk: entityId, + tag: defaultTag, + priority: defaultPriority, }, }" :order="['isActive DESC', 'name', 'id']" @@ -364,6 +393,96 @@ const columns = computed(() => [ </div> <FetchedTags :item="row" :columns="3" /> </template> + <template #more-create-dialog="{ data }"> + <VnInput + v-model="data.provisionalName" + :label="t('globals.description')" + :is-required="true" + /> + <VnSelect + url="Tags" + v-model="data.tag" + :label="t('globals.tag')" + :fields="['id', 'name']" + option-label="name" + option-value="id" + :is-required="true" + :sort-by="['name ASC']" + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.name }}</QItemLabel> + <QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> + <VnSelect + :options="validPriorities" + v-model="data.priority" + :label="t('item.create.priority')" + :is-required="true" + /> + <VnSelect + url="ItemTypes" + v-model="data.typeFk" + :label="t('item.list.typeName')" + :fields="['id', 'code', 'name']" + option-label="name" + option-value="id" + :is-required="true" + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.name }}</QItemLabel> + <QItemLabel caption> + {{ scope.opt?.code }} #{{ scope.opt?.id }} + </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> + <VnSelect + url="Intrastats" + v-model="data.intrastatFk" + :label="t('globals.intrastat')" + :fields="['id', 'description']" + option-label="description" + option-value="id" + :is-required="true" + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.description }}</QItemLabel> + <QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> + <VnSelect + url="Origins" + v-model="data.originFk" + :label="t('globals.origin')" + :fields="['id', 'code', 'name']" + option-label="code" + option-value="id" + :is-required="true" + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.name }}</QItemLabel> + <QItemLabel caption> + {{ scope.opt?.code }} #{{ scope.opt?.id }} + </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> + </template> </VnTable> </template> <style lang="scss" scoped> @@ -376,6 +495,7 @@ const columns = computed(() => [ <i18n> es: New item: Nuevo artículo + Create Item: Crear artículo + You can search by id: Puedes buscar por id Preview: Vista previa - Regularize stock: Regularizar stock </i18n> diff --git a/src/pages/Item/ItemListFilter.vue b/src/pages/Item/ItemListFilter.vue index 484265b49..a8349c935 100644 --- a/src/pages/Item/ItemListFilter.vue +++ b/src/pages/Item/ItemListFilter.vue @@ -199,17 +199,7 @@ onMounted(async () => { dense outlined rounded - > - <template #option="scope"> - <QItem v-bind="scope.itemProps"> - <QItemSection> - <QItemLabel>{{ - t(`params.${scope.opt?.name}`) - }}</QItemLabel> - </QItemSection> - </QItem> - </template> - </VnSelect> + /> </QItemSection> </QItem> <QItem> @@ -265,6 +255,7 @@ onMounted(async () => { option-value="id" option-label="name" :fields="['id', 'name', 'nickname']" + :filter-options="['id', 'name', 'nickname']" sort-by="name ASC" hide-selected dense @@ -274,9 +265,12 @@ onMounted(async () => { <template #option="scope"> <QItem v-bind="scope.itemProps"> <QItemSection> - <QItemLabel>{{ - scope.opt?.name + ': ' + scope.opt?.nickname - }}</QItemLabel> + <QItemLabel> + {{ scope.opt?.name}} + </QItemLabel> + <QItemLabel caption> + {{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }} + </QItemLabel> </QItemSection> </QItem> </template> @@ -375,6 +369,7 @@ onMounted(async () => { :model-value="fieldFilter.selectedField" :options="moreFields" option-label="label" + option-value="label" dense outlined rounded diff --git a/src/pages/Item/ItemRequest.vue b/src/pages/Item/ItemRequest.vue index 4447d1bcf..d96fbca2f 100644 --- a/src/pages/Item/ItemRequest.vue +++ b/src/pages/Item/ItemRequest.vue @@ -172,24 +172,22 @@ const changeQuantity = async (request) => { }; await axios.patch(`Sales/${request.saleFk}`, params); - notify(t('globals.dataSaved'), 'positive'); - confirmRequest(request); - } else confirmRequest(request); + } + await confirmRequest(request); + notify(t('globals.dataSaved'), 'positive'); }; const confirmRequest = async (request) => { - if (request.itemFk && request.saleQuantity) { - const params = { - itemFk: request.itemFk, - quantity: request.saleQuantity, - attenderFk: request.attenderFk, - }; + if (!request.itemFk || !request.saleQuantity) return; + const params = { + itemFk: request.itemFk, + quantity: request.saleQuantity, + attenderFk: request.attenderFk, + }; - const { data } = await axios.post(`TicketRequests/${request.id}/confirm`, params); - request.itemDescription = data.concept; - request.isOk = true; - notify(t('globals.dataSaved'), 'positive'); - } + const { data } = await axios.post(`TicketRequests/${request.id}/confirm`, params); + request.itemDescription = data.concept; + request.isOk = true; }; const getState = (isOk) => { diff --git a/src/pages/Item/ItemRequestFilter.vue b/src/pages/Item/ItemRequestFilter.vue index 4e8ae0d42..af48f7f5c 100644 --- a/src/pages/Item/ItemRequestFilter.vue +++ b/src/pages/Item/ItemRequestFilter.vue @@ -149,7 +149,6 @@ onMounted(async () => { :label="t('params.requesterFk')" v-model="params.requesterFk" @update:model-value="searchFn()" - :fields="['id', 'name']" :params="{ departmentCodes: ['VT'] }" hide-selected dense @@ -201,6 +200,7 @@ en: to: To mine: For me state: State + daysOnward: Days onward myTeam: My team dateFiltersTooltip: Cannot choose a range of dates and days onward at the same time denied: Denied @@ -218,6 +218,7 @@ es: to: Hasta mine: Para mi state: Estado + daysOnward: Días en adelante myTeam: Mi equipo dateFiltersTooltip: No se puede seleccionar un rango de fechas y días en adelante a la vez denied: Denegada diff --git a/src/pages/Item/locale/en.yml b/src/pages/Item/locale/en.yml index 74feb512b..907c72acd 100644 --- a/src/pages/Item/locale/en.yml +++ b/src/pages/Item/locale/en.yml @@ -107,6 +107,7 @@ item: scopeDays: Scope days searchbar: label: Search item + info: You can search by id descriptor: item: Item buyer: Buyer @@ -139,6 +140,7 @@ item: stemMultiplier: Multiplier producer: Producer landed: Landed + newItem: New item basicData: type: Type reference: Reference @@ -158,6 +160,7 @@ item: isFragileTooltip: Is shown at website, app that this item cannot travel (wreath, palms, ...) isPhotoRequested: Do photo isPhotoRequestedTooltip: This item does need a photo + isCustomInspectionRequired: Needs physical inspection (PIF) description: Description fixedPrice: itemFk: Item ID @@ -216,3 +219,4 @@ item: minSalesQuantity: 'Cantidad mínima de venta' genus: 'Genus' specie: 'Specie' + regularizeStock: Regularize stock diff --git a/src/pages/Item/locale/es.yml b/src/pages/Item/locale/es.yml index 3f2a06f1f..015dea4dd 100644 --- a/src/pages/Item/locale/es.yml +++ b/src/pages/Item/locale/es.yml @@ -109,6 +109,7 @@ item: scopeDays: Días en adelante searchbar: label: Buscar artículo + info: Puedes buscar por id descriptor: item: Artículo buyer: Comprador @@ -141,6 +142,7 @@ item: stemMultiplier: Multiplicador producer: Productor landed: F. entrega + newItem: Nuevo artículo basicData: type: Tipo reference: Referencia @@ -160,6 +162,7 @@ item: isFragileTooltip: Se muestra en la web, app que este artículo no puede viajar (coronas, palmas, ...) isPhotoRequested: Hacer foto isPhotoRequestedTooltip: Este artículo necesita una foto + isCustomInspectionRequired: Necesita inspección física (PIF) description: Descripción fixedPrice: itemFk: ID Artículo @@ -207,6 +210,7 @@ item: minSalesQuantity: 'Cantidad mínima de venta' genus: 'Genus' specie: 'Specie' + regularizeStock: Regularizar stock buyRequest: ticketId: 'ID Ticket' shipped: 'F. envío' diff --git a/src/pages/Login/LoginMain.vue b/src/pages/Login/LoginMain.vue index 44b868ebd..a4c3566a9 100644 --- a/src/pages/Login/LoginMain.vue +++ b/src/pages/Login/LoginMain.vue @@ -3,7 +3,7 @@ import { ref } from 'vue'; import { Notify } from 'quasar'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; - +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; import { useSession } from 'src/composables/useSession'; import { useLogin } from 'src/composables/useLogin'; @@ -63,11 +63,10 @@ async function onSubmit() { :rules="[(val) => (val && val.length > 0) || t('login.fieldRequired')]" color="primary" /> - <VnInput - type="password" + <VnInputPassword v-model="password" :label="t('login.password')" - lazy-rules + :toggle-visibility="true" :rules="[(val) => (val && val.length > 0) || t('login.fieldRequired')]" class="red" /> diff --git a/src/pages/Login/ResetPassword.vue b/src/pages/Login/ResetPassword.vue index 2751f1ceb..081801e0e 100644 --- a/src/pages/Login/ResetPassword.vue +++ b/src/pages/Login/ResetPassword.vue @@ -7,6 +7,7 @@ import axios from 'axios'; import VnInput from 'components/common/VnInput.vue'; import VnOutForm from 'components/ui/VnOutForm.vue'; +import VnInputPassword from 'src/components/common/VnInputPassword.vue'; const quasar = useQuasar(); const router = useRouter(); @@ -54,8 +55,7 @@ async function onSubmit() { <template> <VnOutForm @submit="onSubmit" :title="t('globals.pageTitles.resetPassword')"> <template #default> - <VnInput - type="password" + <VnInputPassword :label="t('login.password')" v-model="newPassword" :info=" @@ -72,9 +72,8 @@ async function onSubmit() { <template #prepend> <QIcon name="password" /> </template> - </VnInput> - <VnInput - type="password" + </VnInputPassword> + <VnInputPassword :label="t('resetPassword.repeatPassword')" v-model="repeatPassword" required @@ -82,7 +81,7 @@ async function onSubmit() { <template #prepend> <QIcon name="password" /> </template> - </VnInput> + </VnInputPassword> </template> <template #buttons> <QBtn diff --git a/src/pages/Monitor/Ticket/MonitorTickets.vue b/src/pages/Monitor/Ticket/MonitorTickets.vue index ef03ec20d..f363f5bf8 100644 --- a/src/pages/Monitor/Ticket/MonitorTickets.vue +++ b/src/pages/Monitor/Ticket/MonitorTickets.vue @@ -110,15 +110,13 @@ const columns = computed(() => [ name: 'salesPersonFk', field: 'userName', align: 'left', - optionFilter: 'firstName', columnFilter: { component: 'select', attrs: { - url: 'Workers/activeWithInheritedRole', - fields: ['id', 'name'], + url: 'Workers/search?departmentCodes=["VT"]', + fields: ['id', 'name', 'nickname', 'code'], sortBy: 'nickname ASC', - where: { role: 'salesPerson' }, - useLike: false, + optionLabel: 'nickname', }, }, }, diff --git a/src/pages/Order/Card/OrderCatalogItemDialog.vue b/src/pages/Order/Card/OrderCatalogItemDialog.vue index 0d55b7de1..163b036eb 100644 --- a/src/pages/Order/Card/OrderCatalogItemDialog.vue +++ b/src/pages/Order/Card/OrderCatalogItemDialog.vue @@ -1,6 +1,6 @@ <script setup> import toCurrency from 'src/filters/toCurrency'; -import { computed, inject, ref } from 'vue'; +import { computed, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import axios from 'axios'; import { useRoute } from 'vue-router'; diff --git a/src/pages/Order/Card/OrderDescriptor.vue b/src/pages/Order/Card/OrderDescriptor.vue index e0c613aed..0d5f0146f 100644 --- a/src/pages/Order/Card/OrderDescriptor.vue +++ b/src/pages/Order/Card/OrderDescriptor.vue @@ -9,7 +9,6 @@ import useCardDescription from 'src/composables/useCardDescription'; import CardDescriptor from 'components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import FetchData from 'components/FetchData.vue'; -import OrderDescriptorMenu from 'pages/Order/Card/OrderDescriptorMenu.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; const DEFAULT_ITEMS = 0; @@ -94,9 +93,6 @@ const total = ref(0); @on-fetch="setData" data-key="orderData" > - <template #menu="{ entity }"> - <OrderDescriptorMenu :order="entity" /> - </template> <template #body="{ entity }"> <VnLv :label="t('globals.state')" diff --git a/src/pages/Order/Card/OrderFilter.vue b/src/pages/Order/Card/OrderFilter.vue index dc86600ac..c387be241 100644 --- a/src/pages/Order/Card/OrderFilter.vue +++ b/src/pages/Order/Card/OrderFilter.vue @@ -97,6 +97,7 @@ const sourceList = ref([]); v-model="params.sourceApp" :options="sourceList" option-label="value" + option-value="value" dense outlined rounded @@ -128,6 +129,7 @@ en: from: From to: To orderFk: Order + workerFk: Worker sourceApp: Application myTeam: My Team isConfirmed: Is Confirmed @@ -151,6 +153,7 @@ es: from: Desde to: Hasta orderFk: Cesta + workerFk: Trabajador sourceApp: Aplicación myTeam: Mi Equipo isConfirmed: Confirmado diff --git a/src/pages/Order/Card/OrderLines.vue b/src/pages/Order/Card/OrderLines.vue index e5b683534..6093addb5 100644 --- a/src/pages/Order/Card/OrderLines.vue +++ b/src/pages/Order/Card/OrderLines.vue @@ -213,9 +213,9 @@ async function handleConfirm() { type: 'positive', }); router.push({ - name: 'TicketList', + name: 'TicketSale', query: { - table: JSON.stringify({ clientFk: descriptorData.store.data.clientFk }), + table: JSON.stringify({ id: route.params.id }), }, }); } diff --git a/src/pages/Order/Card/OrderSummary.vue b/src/pages/Order/Card/OrderSummary.vue index b8016abac..a289688e4 100644 --- a/src/pages/Order/Card/OrderSummary.vue +++ b/src/pages/Order/Card/OrderSummary.vue @@ -12,6 +12,7 @@ import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy import FetchedTags from 'components/ui/FetchedTags.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; +import OrderDescriptorMenu from 'pages/Order/Card/OrderDescriptorMenu.vue'; const { t } = useI18n(); const route = useRoute(); @@ -91,6 +92,9 @@ async function handleConfirm() { <QTooltip>{{ t('order.summary.confirmLines') }}</QTooltip> </QBtn> </template> + <template #menu="{ entity }"> + <OrderDescriptorMenu :order="entity" /> + </template> <template #body="{ entity }"> <QCard class="vn-one"> <VnTitle @@ -221,7 +225,7 @@ async function handleConfirm() { </span> </div> </div> - <FetchedTags :item="props.row.item" /> + <FetchedTags :item="props.row.item" :columns="3" /> </QTd> <QTd key="quantity" :props="props"> {{ props.row.quantity }} diff --git a/src/pages/Route/Agency/locale/es.yml b/src/pages/Route/Agency/locale/es.yml index 2607472bd..5c594a41d 100644 --- a/src/pages/Route/Agency/locale/es.yml +++ b/src/pages/Route/Agency/locale/es.yml @@ -10,3 +10,4 @@ agency: searchBar: info: Puedes buscar por nombre o id label: Buscar agencia... + diff --git a/src/pages/Route/Card/RouteAutonomousFilter.vue b/src/pages/Route/Card/RouteAutonomousFilter.vue index 3d08e1355..0b807b7b3 100644 --- a/src/pages/Route/Card/RouteAutonomousFilter.vue +++ b/src/pages/Route/Card/RouteAutonomousFilter.vue @@ -225,8 +225,8 @@ es: params: agencyModeFk: Agencia ruta m3: m³ - from: Desde - to: Hasta + From: Desde + To: Hasta date: Fecha agencyFk: Agencia Acuerdo packages: Bultos diff --git a/src/pages/Route/Card/RouteDescriptorMenu.vue b/src/pages/Route/Card/RouteDescriptorMenu.vue index 6092bcd95..d1a70c868 100644 --- a/src/pages/Route/Card/RouteDescriptorMenu.vue +++ b/src/pages/Route/Card/RouteDescriptorMenu.vue @@ -52,7 +52,7 @@ async function actualizeVolume() { const params = { isOk: true }; await axios.post(`Routes/${routeId}/updateVolume`, params); quasar.notify({ - message: t('globals.dataUpdated'), + message: t('globals.dataSaved'), type: 'positive', }); } diff --git a/src/pages/Route/Card/RouteFilter.vue b/src/pages/Route/Card/RouteFilter.vue index 6f65313d3..72bfed1da 100644 --- a/src/pages/Route/Card/RouteFilter.vue +++ b/src/pages/Route/Card/RouteFilter.vue @@ -161,6 +161,7 @@ en: warehouseFk: Warehouse description: Description m3: m³ + scopeDays: Days Onward vehicleFk: Vehicle agencyModeFk: Agency workerFk: Worker @@ -172,6 +173,7 @@ es: warehouseFk: Almacén description: Descripción m3: m³ + scopeDays: Días en adelante vehicleFk: Vehículo agencyModeFk: Agencia workerFk: Trabajador diff --git a/src/pages/Route/Card/RouteSummary.vue b/src/pages/Route/Card/RouteSummary.vue index a0b971195..3051972b2 100644 --- a/src/pages/Route/Card/RouteSummary.vue +++ b/src/pages/Route/Card/RouteSummary.vue @@ -12,6 +12,7 @@ import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue'; import VnLv from 'components/ui/VnLv.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; +import RouteDescriptorMenu from './RouteDescriptorMenu.vue'; const $props = defineProps({ id: { @@ -128,6 +129,9 @@ const ticketColumns = ref([ <template #header="{ entity }"> <span>{{ `${entity?.route.id} - ${entity?.route?.description}` }}</span> </template> + <template #menu="{ entity }"> + <RouteDescriptorMenu :route="entity.route" /> + </template> <template #body="{ entity }"> <QCard class="vn-max"> <VnTitle diff --git a/src/pages/Route/Roadmap/RoadmapSummary.vue b/src/pages/Route/Roadmap/RoadmapSummary.vue index 3fb36b4f7..1fbb1897d 100644 --- a/src/pages/Route/Roadmap/RoadmapSummary.vue +++ b/src/pages/Route/Roadmap/RoadmapSummary.vue @@ -10,6 +10,7 @@ import VnTitle from 'src/components/common/VnTitle.vue'; import CardSummary from 'components/ui/CardSummary.vue'; import SupplierDescriptorProxy from 'pages/Supplier/Card/SupplierDescriptorProxy.vue'; import VnLinkPhone from 'components/ui/VnLinkPhone.vue'; +import RoadmapDescriptorMenu from './RoadmapDescriptorMenu.vue'; const $props = defineProps({ id: { @@ -86,6 +87,9 @@ const filter = { <template #header="{ entity }"> <span>{{ `${entity?.id} - ${entity?.name}` }}</span> </template> + <template #menu="{ entity }"> + <RoadmapDescriptorMenu :route="entity" /> + </template> <template #body="{ entity }"> <QCard class="vn-one"> <VnTitle diff --git a/src/pages/Route/RouteAutonomous.vue b/src/pages/Route/RouteAutonomous.vue index e45af30c7..ca51b0fdb 100644 --- a/src/pages/Route/RouteAutonomous.vue +++ b/src/pages/Route/RouteAutonomous.vue @@ -271,6 +271,8 @@ es: Date: Fecha Agency route: Agencia Ruta Agency agreement: Agencia Acuerdo + From: Desde + To: Hasta Packages: Bultos Price: Precio Received: Recibida diff --git a/src/pages/Route/locale/en.yml b/src/pages/Route/locale/en.yml index 420d18dfe..7a1f9e1c0 100644 --- a/src/pages/Route/locale/en.yml +++ b/src/pages/Route/locale/en.yml @@ -1,4 +1,18 @@ route: + params: + etd: ETD + tractorPlate: Plate + price: Price + observations: Observations + id: ID + name: Name + cmrFk: CMR id + hasCmrDms: Attached in gestdoc + ticketFk: Ticketd id + routeFk: Route id + shipped: Shipped + agencyAgreement: Agency agreement + agencyModeName: Agency route Worker: Worker Agency: Agency Vehicle: Vehicle diff --git a/src/pages/Route/locale/es.yml b/src/pages/Route/locale/es.yml index a6ba4f370..b6f42bd5a 100644 --- a/src/pages/Route/locale/es.yml +++ b/src/pages/Route/locale/es.yml @@ -1,4 +1,18 @@ route: + params: + agencyModeName: Agencia Ruta + agencyAgreement: Agencia Acuerdo + id: Id + name: Troncal + etd: ETD + tractorPlate: Matrícula + price: Precio + observations: Observaciones + cmrFk: Id CMR + hasCmrDms: Gestdoc + ticketFk: Id ticket + routeFK: Id ruta + shipped: Fecha preparación Worker: Trabajador Agency: Agencia Vehicle: Vehículo diff --git a/src/pages/Shelving/Card/ShelvingDescriptorMenu.vue b/src/pages/Shelving/Card/ShelvingDescriptorMenu.vue index 16351fdd4..447737e9c 100644 --- a/src/pages/Shelving/Card/ShelvingDescriptorMenu.vue +++ b/src/pages/Shelving/Card/ShelvingDescriptorMenu.vue @@ -4,6 +4,7 @@ import { useQuasar } from 'quasar'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; import VnConfirm from 'components/ui/VnConfirm.vue'; +import { useRoute } from 'vue-router'; const $props = defineProps({ shelving: { @@ -14,8 +15,11 @@ const $props = defineProps({ const router = useRouter(); const quasar = useQuasar(); +const route = useRoute(); const { t } = useI18n(); +const emit = defineEmits(['onRemove']); + function confirmRemove() { quasar.dialog({ component: VnConfirm, @@ -32,11 +36,12 @@ async function remove() { return; } await axios.delete(`Shelvings/${$props.shelving.id}`); - await router.push({ name: 'ShelvingList' }); + if (route.name != 'ShelvingList') await router.push({ name: 'ShelvingList' }); quasar.notify({ message: t('globals.dataDeleted'), type: 'positive', }); + emit('onRemove', {}); } </script> <template> diff --git a/src/pages/Shelving/Card/ShelvingSummary.vue b/src/pages/Shelving/Card/ShelvingSummary.vue index 0c1eb2a1d..39fa4639f 100644 --- a/src/pages/Shelving/Card/ShelvingSummary.vue +++ b/src/pages/Shelving/Card/ShelvingSummary.vue @@ -1,10 +1,11 @@ <script setup> -import { computed } from 'vue'; +import { computed, ref } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import CardSummary from 'components/ui/CardSummary.vue'; import VnLv from 'components/ui/VnLv.vue'; import VnUserLink from 'components/ui/VnUserLink.vue'; +import ShelvingDescriptorMenu from './ShelvingDescriptorMenu.vue'; const $props = defineProps({ id: { @@ -14,7 +15,7 @@ const $props = defineProps({ }); const route = useRoute(); const { t } = useI18n(); - +const summary = ref({}); const entityId = computed(() => $props.id || route.params.id); const filter = { @@ -43,7 +44,13 @@ const filter = { data-key="ShelvingSummary" > <template #header="{ entity }"> - <div>{{ entity.id }} - {{ entity.code }}</div> + <div>{{ entity.code }}</div> + </template> + <template #menu="{ entity }"> + <ShelvingDescriptorMenu + :shelving="entity" + @on-remove="$refs.summary.fetch()" + /> </template> <template #body="{ entity }"> <QCard class="vn-one"> diff --git a/src/pages/Supplier/Card/SupplierBasicData.vue b/src/pages/Supplier/Card/SupplierBasicData.vue index 842109656..22a6deaab 100644 --- a/src/pages/Supplier/Card/SupplierBasicData.vue +++ b/src/pages/Supplier/Card/SupplierBasicData.vue @@ -6,9 +6,11 @@ import VnRow from 'components/ui/VnRow.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelectWorker from 'src/components/common/VnSelectWorker.vue'; +import { useArrayData } from 'src/composables/useArrayData'; const route = useRoute(); const { t } = useI18n(); +const arrayData = useArrayData(); const companySizes = [ { id: 'small', name: t('globals.small'), size: '1-5' }, { id: 'medium', name: t('globals.medium'), size: '6-50' }, @@ -22,6 +24,7 @@ const companySizes = [ model="supplier" auto-load :clear-store-on-unmount="false" + @on-data-saved="arrayData.fetch({})" > <template #form="{ data, validate }"> <VnRow> diff --git a/src/pages/Supplier/Card/SupplierConsumptionFilter.vue b/src/pages/Supplier/Card/SupplierConsumptionFilter.vue index 401bde8fa..390f7d9ff 100644 --- a/src/pages/Supplier/Card/SupplierConsumptionFilter.vue +++ b/src/pages/Supplier/Card/SupplierConsumptionFilter.vue @@ -134,6 +134,7 @@ defineProps({ <i18n> en: params: + supplierFk: Supplier search: General search itemId: Item id buyerId: Buyer @@ -143,6 +144,7 @@ en: to: To es: params: + supplierFk: Proveedor search: Búsqueda general itemId: Id Artículo buyerId: Comprador diff --git a/src/pages/Supplier/Card/SupplierDescriptor.vue b/src/pages/Supplier/Card/SupplierDescriptor.vue index 28cfe49ce..a1a2a0991 100644 --- a/src/pages/Supplier/Card/SupplierDescriptor.vue +++ b/src/pages/Supplier/Card/SupplierDescriptor.vue @@ -9,7 +9,7 @@ import VnLv from 'src/components/ui/VnLv.vue'; import { toDateString } from 'src/filters'; import useCardDescription from 'src/composables/useCardDescription'; import { getUrl } from 'src/composables/getUrl'; -import { useState } from 'src/composables/useState'; +import { useArrayData } from 'src/composables/useArrayData'; const $props = defineProps({ id: { @@ -26,7 +26,7 @@ const $props = defineProps({ const route = useRoute(); const { t } = useI18n(); const url = ref(); -const state = useState(); +const arrayData = useArrayData(); const filter = { fields: [ @@ -77,7 +77,7 @@ const setData = (entity) => { data.value = useCardDescription(entity.ref, entity.id); }; -const supplier = computed(() => state.get('supplier')); +const supplier = computed(() => arrayData.store.data); const getEntryQueryParams = (supplier) => { if (!supplier) return null; diff --git a/src/pages/Supplier/Card/SupplierSummary.vue b/src/pages/Supplier/Card/SupplierSummary.vue index a467006a3..b658ca5fb 100644 --- a/src/pages/Supplier/Card/SupplierSummary.vue +++ b/src/pages/Supplier/Card/SupplierSummary.vue @@ -39,6 +39,7 @@ const getUrl = (section) => `#/supplier/${entityId.value}/${section}`; :url="`Suppliers/${entityId}/getSummary`" @on-fetch="(data) => setData(data)" data-key="SupplierSummary" + module-name="Supplier" > <template #header> <span>{{ supplier.id }} - {{ supplier.name }}</span> @@ -149,7 +150,7 @@ const getUrl = (section) => `#/supplier/${entityId.value}/${section}`; <VnLv :label="t('supplier.summary.taxNumber')" :value="supplier.nif" /> <VnLv :label="t('globals.street')" :value="supplier.street" /> <VnLv :label="t('supplier.summary.city')" :value="supplier.city" /> - <VnLv :label="t('globals.postCode')" :value="supplier.postCode" /> + <VnLv :label="t('globals.postcode')" :value="supplier.postCode" /> <VnLv :label="t('supplier.summary.province')" :value="supplier.province?.name" diff --git a/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue b/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue index df84add93..cf4481537 100644 --- a/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue +++ b/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue @@ -1,5 +1,5 @@ <script setup> -import { ref, computed, onMounted, watch } from 'vue'; +import { ref, computed, onMounted } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; diff --git a/src/pages/Ticket/Card/TicketExpedition.vue b/src/pages/Ticket/Card/TicketExpedition.vue index 7da049124..166e86978 100644 --- a/src/pages/Ticket/Card/TicketExpedition.vue +++ b/src/pages/Ticket/Card/TicketExpedition.vue @@ -59,7 +59,7 @@ const columns = computed(() => [ }, { label: t('basicData.item'), - name: 'packagingItemFk', + name: 'longName', align: 'left', cardVisible: true, columnFilter: { @@ -201,7 +201,7 @@ const getExpeditionState = async (expedition) => { const openGrafana = (expeditionFk) => { useOpenURL( - `https://grafana.verdnatura.es/d/d552ab74-85b4-4e7f-a279-fab7cd9c6124/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}` + `https://grafana.verdnatura.es/d/de1njb6p5answd/control-de-expediciones?orgId=1&var-expeditionFk=${expeditionFk}` ); }; @@ -319,14 +319,21 @@ onMounted(async () => { } } " + :redirect="false" order="created DESC" > - <template #column-packagingItemFk="{ row }"> + <template #column-freightItemName="{ row }"> <span class="link" @click.stop> - {{ row.packagingItemFk }} + {{ row.freightItemName }} <ItemDescriptorProxy :id="row.packagingItemFk" /> </span> </template> + <template #column-longName="{ row }"> + <span class="link" @click.stop> + {{ row.longName }} + <ItemDescriptorProxy :id="row.itemFk" /> + </span> + </template> </VnTable> <QDialog ref="newTicketDialogRef" transition-show="scale" transition-hide="scale"> <ExpeditionNewTicket diff --git a/src/pages/Ticket/Card/TicketPurchaseRequest.vue b/src/pages/Ticket/Card/TicketPurchaseRequest.vue index 3b9d6a25b..4e77c7277 100644 --- a/src/pages/Ticket/Card/TicketPurchaseRequest.vue +++ b/src/pages/Ticket/Card/TicketPurchaseRequest.vue @@ -275,4 +275,5 @@ onMounted(() => (stateStore.rightDrawer = false)); New: Nueva Denied: Denegada Accepted: Aceptada + Create request: Crear petición de compra </i18n> diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue index 703a00a0e..8aa785c74 100644 --- a/src/pages/Ticket/Card/TicketSale.vue +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -54,6 +54,7 @@ const transfer = ref({ }); const tableRef = ref([]); const canProceed = ref(); +const isLoading = ref(false); watch( () => route.params.id, @@ -213,6 +214,9 @@ const updateQuantity = async ({ quantity, id }) => { }; const addSale = async (sale) => { + if (isLoading.value) return; + + isLoading.value = true; const params = { barcode: sale.itemFk, quantity: sale.quantity, @@ -233,7 +237,7 @@ const addSale = async (sale) => { sale.item = newSale.item; notify('globals.dataSaved', 'positive'); - window.location.reload(); + arrayData.fetch({}); }; const updateConcept = async (sale) => { @@ -464,6 +468,7 @@ const addRow = (original = null) => { }; const endNewRow = (row) => { + if (!row) return; if (row.itemFk && row.quantity) { row.isNew = false; } diff --git a/src/pages/Ticket/Card/TicketSummary.vue b/src/pages/Ticket/Card/TicketSummary.vue index 2f5f69e1c..2c6e34864 100644 --- a/src/pages/Ticket/Card/TicketSummary.vue +++ b/src/pages/Ticket/Card/TicketSummary.vue @@ -96,7 +96,6 @@ function toTicketUrl(section) { ref="summaryRef" :url="`Tickets/${entityId}/summary`" data-key="TicketSummary" - data-cy="ticketSummary" > <template #header-left> <VnToSummary @@ -114,7 +113,7 @@ function toTicketUrl(section) { {{ entity.nickname }} </div> </template> - <template #header-right="{ entity }"> + <template #header-right> <div> <QBtnDropdown ref="stateBtnDropdownRef" @@ -133,18 +132,11 @@ function toTicketUrl(section) { @update:model-value="changeState" /> </QBtnDropdown> - <QBtn color="white" dense flat icon="more_vert" round size="md"> - <QTooltip> - {{ t('components.cardDescriptor.moreOptions') }} - </QTooltip> - <QMenu> - <QList> - <TicketDescriptorMenu :ticket="entity" /> - </QList> - </QMenu> - </QBtn> </div> </template> + <template #menu="{ entity }"> + <TicketDescriptorMenu :ticket="entity" /> + </template> <template #body="{ entity }"> <QCard class="vn-one"> <VnTitle @@ -258,7 +250,7 @@ function toTicketUrl(section) { <QCard class="vn-one" v-if="entity.notes.length"> <VnTitle :url="toTicketUrl('observation')" - :text="t('globals.pageTitles.notes')" + :text="t('ticket.pageTitles.notes')" /> <QVirtualScroll :items="entity.notes" diff --git a/src/pages/Ticket/TicketFilter.vue b/src/pages/Ticket/TicketFilter.vue index bde27f30e..7dcb834d2 100644 --- a/src/pages/Ticket/TicketFilter.vue +++ b/src/pages/Ticket/TicketFilter.vue @@ -101,7 +101,7 @@ const getGroupedStates = (data) => { <QSkeleton type="QInput" class="full-width" /> </QItemSection> <QItemSection v-if="states"> - <QSelect + <VnSelect :label="t('State')" v-model="params.stateFk" @update:model-value="searchFn()" @@ -122,7 +122,7 @@ const getGroupedStates = (data) => { <QSkeleton type="QInput" class="full-width" /> </QItemSection> <QItemSection v-if="groupedStates"> - <QSelect + <VnSelect :label="t('Grouped state')" v-model="params.groupedStates" @update:model-value="searchFn()" @@ -217,7 +217,7 @@ const getGroupedStates = (data) => { <QSkeleton type="QInput" class="full-width" /> </QItemSection> <QItemSection v-if="provinces"> - <QSelect + <VnSelect :label="t('Province')" v-model="params.provinceFk" @update:model-value="searchFn()" @@ -238,7 +238,7 @@ const getGroupedStates = (data) => { <QSkeleton type="QInput" class="full-width" /> </QItemSection> <QItemSection v-if="agencies"> - <QSelect + <VnSelect :label="t('Agency')" v-model="params.agencyModeFk" @update:model-value="searchFn()" @@ -259,7 +259,7 @@ const getGroupedStates = (data) => { <QSkeleton type="QInput" class="full-width" /> </QItemSection> <QItemSection v-if="warehouses"> - <QSelect + <VnSelect :label="t('Warehouse')" v-model="params.warehouseFk" @update:model-value="searchFn()" @@ -298,14 +298,19 @@ en: to: To salesPersonFk: Salesperson stateFk: State + groupedStates: Grouped State refFk: Invoice Ref. + scopeDays: Days onward + nickname: Nickname myTeam: My team pending: Pending hasInvoice: Invoiced hasRoute: Routed + problems: With problems provinceFk: Province agencyModeFk: Agency warehouseFk: Warehouse + collectionFk: Collection FREE: Free ON_PREPARATION: On preparation PACKED: Packed @@ -320,11 +325,19 @@ es: to: Hasta salesPersonFk: Comercial stateFk: Estado + groupedStates: Estado agrupado refFk: Ref. Factura + scopeDays: Días en adelante + nickname: Nombre mostrado myTeam: Mi equipo pending: Pendiente hasInvoice: Facturado hasRoute: Enrutado + problems: Con problemas + provinceFk: Provincia + agencyModeFk: Agencia + warehouseFk: Almacén + collectionFk: Colección Customer ID: ID Cliente Order ID: ID Pedido From: Desde diff --git a/src/pages/Ticket/TicketList.vue b/src/pages/Ticket/TicketList.vue index 5147af81f..64cf3d649 100644 --- a/src/pages/Ticket/TicketList.vue +++ b/src/pages/Ticket/TicketList.vue @@ -684,6 +684,7 @@ function setReference(data) { color="primary" fab icon="vn:invoice-in" + data-cy="ticketListMakeInvoiceBtn" /> <QTooltip> {{ t('ticketList.createInvoice') }} diff --git a/src/pages/Travel/Card/TravelSummary.vue b/src/pages/Travel/Card/TravelSummary.vue index 59c3a8a91..9deb22808 100644 --- a/src/pages/Travel/Card/TravelSummary.vue +++ b/src/pages/Travel/Card/TravelSummary.vue @@ -11,6 +11,7 @@ import FetchData from 'src/components/FetchData.vue'; import VnRow from 'components/ui/VnRow.vue'; import { toDate, toCurrency } from 'src/filters'; import axios from 'axios'; +import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue'; const $props = defineProps({ id: { @@ -242,7 +243,9 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`; <template #header> <span>{{ travel.id }} - {{ travel.ref }}</span> </template> - + <template #menu="{ entity }"> + <TravelDescriptorMenuItems :travel="entity" /> + </template> <template #body> <QCard class="vn-one"> <QCardSection class="q-pa-none"> diff --git a/src/pages/Travel/ExtraCommunity.vue b/src/pages/Travel/ExtraCommunity.vue index 675a44979..dee9d923a 100644 --- a/src/pages/Travel/ExtraCommunity.vue +++ b/src/pages/Travel/ExtraCommunity.vue @@ -11,9 +11,8 @@ import VnInput from 'src/components/common/VnInput.vue'; import EntryDescriptorProxy from '../Entry/Card/EntryDescriptorProxy.vue'; import { useStateStore } from 'stores/useStateStore'; -import { toCurrency } from 'src/filters'; import { useArrayData } from 'composables/useArrayData'; -import { toDate } from 'src/filters'; +import { toDate, toCurrency } from 'src/filters'; import { usePrintService } from 'composables/usePrintService'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import axios from 'axios'; @@ -128,6 +127,10 @@ const tableColumnComponents = { component: 'span', attrs: {}, }, + isCustomInspectionRequired: { + component: 'span', + attrs: {}, + }, }; const columns = computed(() => [ @@ -589,7 +592,16 @@ const getColor = (percentage) => { <QBtn flat class="link" dense>{{ entry.supplierName }}</QBtn> <SupplierDescriptorProxy :id="entry.supplierFk" /> </QTd> - <QTd /> + <QTd> + <QIcon + v-if="entry.isCustomInspectionRequired" + name="warning" + color="negative" + size="md" + :title="t('requiresInspection')" + > + </QIcon> + </QTd> <QTd> <span>{{ toCurrency(entry.invoiceAmount) }}</span> </QTd> @@ -615,7 +627,7 @@ const getColor = (percentage) => { <QBtn v-if="entry.evaNotes" icon="comment" - size="sm" + size="md" flat color="primary" > @@ -704,12 +716,17 @@ en: physicKg: Phy. KG shipped: W. shipped landed: W. landed - + requiresInspection: Requires inspection + BIP: Boder Inspection Point + notes: Notes es: searchExtraCommunity: Buscar por envío extra comunitario kg: KG Bloq. physicKg: KG físico shipped: F. envío landed: F. llegada + notes: Notas Open as PDF: Abrir como PDF + requiresInspection: Requiere inspección + BIP: Punto de Inspección Fronteriza </i18n> diff --git a/src/pages/Travel/ExtraCommunityFilter.vue b/src/pages/Travel/ExtraCommunityFilter.vue index 75b744168..273158a34 100644 --- a/src/pages/Travel/ExtraCommunityFilter.vue +++ b/src/pages/Travel/ExtraCommunityFilter.vue @@ -221,7 +221,20 @@ warehouses(); dense outlined rounded - /> + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel> + {{ scope.opt?.name}} + </QItemLabel> + <QItemLabel caption> + {{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }} + </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> </QItemSection> </QItem> <QItem> @@ -232,6 +245,7 @@ warehouses(); :options="continentsOptions" option-value="code" option-label="name" + :filter-options="['code', 'name']" hide-selected dense outlined diff --git a/src/pages/Travel/TravelFilter.vue b/src/pages/Travel/TravelFilter.vue index bb78080ef..90901ee4d 100644 --- a/src/pages/Travel/TravelFilter.vue +++ b/src/pages/Travel/TravelFilter.vue @@ -140,10 +140,10 @@ en: Id: Contains ref: Reference agency: Agency - warehouseInFk: W. In + warehouseInFk: Warehouse In shipped: Shipped shipmentHour: Shipment Hour - warehouseOut: W. Out + warehouseOut: Warehouse Out landed: Landed landingHour: Landing Hour totalEntries: Σ @@ -156,7 +156,7 @@ es: warehouseInFk: Alm.Entrada shipped: F.Envío shipmentHour: Hora de envío - warehouseOut: Alm.Entrada + warehouseOut: Alm.Salida landed: F.Entrega landingHour: Hora de entrega totalEntries: Σ diff --git a/src/pages/Travel/TravelList.vue b/src/pages/Travel/TravelList.vue index 4d2912bf7..67fdb3254 100644 --- a/src/pages/Travel/TravelList.vue +++ b/src/pages/Travel/TravelList.vue @@ -286,6 +286,7 @@ es: Search travel: Buscar envio Clone: Clonar Add entry: Añadir Entrada + Create Travels: Crear envíos </i18n> <style lang="scss" scoped> .is-active { diff --git a/src/pages/Wagon/WagonList.vue b/src/pages/Wagon/WagonList.vue index f306c4c8d..e716686d1 100644 --- a/src/pages/Wagon/WagonList.vue +++ b/src/pages/Wagon/WagonList.vue @@ -168,3 +168,8 @@ async function remove(row) { </VnTable> </QPage> </template> + +<i18n> +es: + Create new wagon: Crear nuevo vagón +</i18n> \ No newline at end of file diff --git a/src/pages/Worker/Card/WorkerCard.vue b/src/pages/Worker/Card/WorkerCard.vue index d66bd2608..1ada15a33 100644 --- a/src/pages/Worker/Card/WorkerCard.vue +++ b/src/pages/Worker/Card/WorkerCard.vue @@ -1,21 +1,7 @@ <script setup> -import VnCard from 'components/common/VnCard.vue'; import WorkerDescriptor from './WorkerDescriptor.vue'; -import WorkerFilter from '../WorkerFilter.vue'; +import VnCardBeta from 'src/components/common/VnCardBeta.vue'; </script> <template> - <VnCard - data-key="Worker" - custom-url="Workers/summary" - :descriptor="WorkerDescriptor" - :filter-panel="WorkerFilter" - search-data-key="WorkerList" - :searchbar-props="{ - url: 'Workers/filter', - label: 'Search worker', - info: 'You can search by worker id or name', - order: 'id DESC', - }" - :redirect-on-error="true" - /> + <VnCardBeta data-key="Worker" custom-url="Workers/summary" :descriptor="WorkerDescriptor" /> </template> diff --git a/src/pages/Worker/Card/WorkerDescriptor.vue b/src/pages/Worker/Card/WorkerDescriptor.vue index f09aec816..c09e8868f 100644 --- a/src/pages/Worker/Card/WorkerDescriptor.vue +++ b/src/pages/Worker/Card/WorkerDescriptor.vue @@ -6,11 +6,10 @@ import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; import VnChangePassword from 'src/components/common/VnChangePassword.vue'; -import { useState } from 'src/composables/useState'; import axios from 'axios'; import VnImg from 'src/components/ui/VnImg.vue'; import EditPictureForm from 'components/EditPictureForm.vue'; -import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue'; +import WorkerDescriptorMenu from './WorkerDescriptorMenu.vue'; const $props = defineProps({ id: { @@ -28,8 +27,6 @@ const image = ref(null); const route = useRoute(); const { t } = useI18n(); -const state = useState(); -const user = state.getUser(); const showEditPhotoForm = ref(false); const toggleEditPictureForm = () => { showEditPhotoForm.value = !showEditPhotoForm.value; @@ -45,18 +42,6 @@ const getIsExcluded = async () => { workerExcluded.value = data.exists; }; -const handleExcluded = async () => { - if (workerExcluded.value) - await axios.delete(`WorkerDisableExcludeds/${entityId.value}`); - else - await axios.post(`WorkerDisableExcludeds`, { - workerFk: entityId.value, - dated: new Date(), - }); - - workerExcluded.value = !workerExcluded.value; -}; - const handlePhotoUpdated = (evt = false) => { image.value.reload(evt); }; @@ -72,25 +57,11 @@ const handlePhotoUpdated = (evt = false) => { @on-fetch="getIsExcluded" > <template #menu="{ entity }"> - <QItem v-ripple clickable @click="handleExcluded"> - <QItemSection> - {{ - workerExcluded - ? t('Click to allow the user to be disabled') - : t('Click to exclude the user from getting disabled') - }} - </QItemSection> - </QItem> - <QItem - v-if="!entity.user.emailVerified && user.id != entity.id" - v-ripple - clickable - @click="$refs.changePassRef.show" - > - <QItemSection> - {{ t('globals.changePass') }} - </QItemSection> - </QItem> + <WorkerDescriptorMenu + :worker="entity" + :is-excluded="workerExcluded" + @show-dialog="$refs.changePassRef.show" + /> </template> <template #before> <div class="relative-position"> @@ -144,14 +115,10 @@ const handlePhotoUpdated = (evt = false) => { :value="entity.user?.emailUser?.email" copy /> - <VnLv :label="t('worker.list.department')"> - <template #value> - <span class="link" v-text="entity.department?.department?.name" /> - <DepartmentDescriptorProxy - :id="entity.department?.department?.id" - /> - </template> - </VnLv> + <VnLv + :label="t('worker.list.department')" + :value="entity.department ? entity.department.department.name : null" + /> <VnLv :value="entity.phone"> <template #label> {{ t('globals.phone') }} @@ -211,8 +178,6 @@ const handlePhotoUpdated = (evt = false) => { <i18n> es: - Go to client: Ir a cliente - Go to user: Ir al usuario Click to allow the user to be disabled: Marcar para deshabilitar Click to exclude the user from getting disabled: Marcar para no deshabilitar </i18n> diff --git a/src/pages/Worker/Card/WorkerDescriptorMenu.vue b/src/pages/Worker/Card/WorkerDescriptorMenu.vue new file mode 100644 index 000000000..8d82dc839 --- /dev/null +++ b/src/pages/Worker/Card/WorkerDescriptorMenu.vue @@ -0,0 +1,65 @@ +<script setup> +import { computed, ref, toRefs } from 'vue'; +import axios from 'axios'; +import { useRoute } from 'vue-router'; +import { useI18n } from 'vue-i18n'; +import { useState } from 'src/composables/useState'; + +const $props = defineProps({ + worker: { + type: Object, + required: true, + }, + isExcluded: { + type: Boolean, + required: true, + }, +}); +const route = useRoute(); +const { t } = useI18n(); +const state = useState(); +const user = state.getUser(); +const { worker } = toRefs($props); +const workerExcluded = ref($props.isExcluded); +const entityId = computed(() => { + return $props.worker.id || route.params.id; +}); +const emit = defineEmits(['show-dialog']); +const handleExcluded = async () => { + if (workerExcluded.value) + await axios.delete(`WorkerDisableExcludeds/${entityId.value}`); + else + await axios.post(`WorkerDisableExcludeds`, { + workerFk: entityId.value, + dated: new Date(), + }); + + workerExcluded.value = !workerExcluded.value; +}; + +const showChangePasswordDialog = () => { + emit('show-dialog', true); +}; +</script> + +<template> + <QItem v-ripple clickable @click="handleExcluded"> + <QItemSection> + {{ + workerExcluded + ? t('Click to allow the user to be disabled') + : t('Click to exclude the user from getting disabled') + }} + </QItemSection> + </QItem> + <QItem + v-if="!worker.user.emailVerified && user.id == worker.id" + v-ripple + clickable + @click="showChangePasswordDialog" + > + <QItemSection> + {{ t('globals.changePass') }} + </QItemSection> + </QItem> +</template> diff --git a/src/pages/Worker/Card/WorkerPBX.vue b/src/pages/Worker/Card/WorkerPBX.vue index 547156532..12f2a4b23 100644 --- a/src/pages/Worker/Card/WorkerPBX.vue +++ b/src/pages/Worker/Card/WorkerPBX.vue @@ -1,68 +1,28 @@ +src/pages/Worker/Card/WorkerPBX.vue + <script setup> -import { watch, ref } from 'vue'; -import { useI18n } from 'vue-i18n'; -import { useRoute } from 'vue-router'; - -import { useState } from 'src/composables/useState'; - import FormModel from 'src/components/FormModel.vue'; -import VnRow from 'components/ui/VnRow.vue'; import VnInput from 'src/components/common/VnInput.vue'; - -const { t } = useI18n(); -const state = useState(); -const route = useRoute(); -const workerPBXForm = ref(); -const extension = ref(null); - -const filter = { - include: [ - { - relation: 'sip', - }, - ], -}; - -watch( - () => route.params.id, - () => state.set('extension', null) -); - -const onFetch = (data) => { - state.set('extension', data?.sip?.extension); - extension.value = state.get('extension'); -}; - -const updateModelValue = (data) => { - state.set('extension', data); - workerPBXForm.value.hasChanges = true; -}; </script> <template> <FormModel - ref="workerPBXForm" - :filter="filter" - :url="`Workers/${route.params.id}`" + model="WorkerPbx" + :url="`Workers/${$route.params.id}/sip`" url-update="Sips" - auto-load :mapper=" - () => ({ - userFk: +route.params.id, + ({ userFk, extension }) => ({ + userFk, extension, }) " - model="DeviceProductionUser" - @on-fetch="onFetch" + auto-load > - <template #form="{}"> - <VnRow> - <VnInput - :label="t('worker.summary.sipExtension')" - v-model="extension" - @update:model-value="updateModelValue" - /> - </VnRow> + <template #form="{ data }"> + <VnInput + :label="$t('worker.summary.sipExtension')" + v-model="data.extension" + /> </template> </FormModel> </template> diff --git a/src/pages/Worker/Card/WorkerSummary.vue b/src/pages/Worker/Card/WorkerSummary.vue index 496f1ca16..bfb503f6b 100644 --- a/src/pages/Worker/Card/WorkerSummary.vue +++ b/src/pages/Worker/Card/WorkerSummary.vue @@ -11,6 +11,7 @@ import VnTitle from 'src/components/common/VnTitle.vue'; import RoleDescriptorProxy from 'src/pages/Account/Role/Card/RoleDescriptorProxy.vue'; import DepartmentDescriptorProxy from 'src/pages/Department/Card/DepartmentDescriptorProxy.vue'; import { useAdvancedSummary } from 'src/composables/useAdvancedSummary'; +import WorkerDescriptorMenu from './WorkerDescriptorMenu.vue'; const route = useRoute(); const { t } = useI18n(); @@ -42,6 +43,9 @@ onBeforeMount(async () => { <template #header="{ entity }"> <div>{{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }}</div> </template> + <template #menu="{ entity }"> + <WorkerDescriptorMenu :worker="entity" :is-excluded="workerExcluded" /> + </template> <template #body="{ entity: worker }"> <QCard class="vn-one"> <VnTitle :url="basicDataUrl" :text="t('globals.summary.basicData')" /> diff --git a/src/pages/Worker/Card/WorkerTimeControl.vue b/src/pages/Worker/Card/WorkerTimeControl.vue index c480d5bd8..65fbf4b43 100644 --- a/src/pages/Worker/Card/WorkerTimeControl.vue +++ b/src/pages/Worker/Card/WorkerTimeControl.vue @@ -22,6 +22,7 @@ import { useVnConfirm } from 'composables/useVnConfirm'; import { useArrayData } from 'composables/useArrayData'; import { toTimeFormat, secondsToHoursMinutes } from 'filters/date.js'; import toDateString from 'filters/toDateString.js'; +import moment from 'moment'; import { date } from 'quasar'; const route = useRoute(); @@ -64,6 +65,7 @@ const selectedDateFormatted = ref(toDateString(defaultDate.value)); const arrayData = useArrayData('workerData'); const acl = useAcl(); +const selectedDateYear = computed(() => moment(selectedDate.value).isoWeekYear()); const worker = computed(() => arrayData.store?.data); const canSend = computed(() => acl.hasAny([{ model: 'WorkerTimeControl', props: 'sendMail', accessType: 'WRITE' }]) @@ -208,13 +210,30 @@ const getWorkedHours = async (from, to) => { }; const getAbsences = async () => { - const params = { - workerFk: route.params.id, - businessFk: null, - year: startOfWeek.value.getFullYear(), + const startYear = startOfWeek.value.getFullYear(); + const endYear = endOfWeek.value.getFullYear(); + const defaultParams = { workerFk: route.params.id, businessFk: null }; + + const startData = ( + await axios.get('Calendars/absences', { + params: { ...defaultParams, year: startYear }, + }) + ).data; + + let endData; + if (startYear !== endYear) { + endData = ( + await axios.get('Calendars/absences', { + params: { ...defaultParams, year: endYear }, + }) + ).data; + } + + const data = { + holidays: [...(startData?.holidays || []), ...(endData?.holidays || [])], + absences: [...(startData?.absences || []), ...(endData?.absences || [])], }; - const { data } = await axios.get('Calendars/absences', { params }); if (data) addEvents(data); }; @@ -261,7 +280,7 @@ const fetchHours = async () => { const fetchWeekData = async () => { const where = { - year: selectedDate.value.getFullYear(), + year: selectedDateYear.value, week: selectedWeekNumber.value, }; const mail = ( @@ -353,7 +372,7 @@ const showReasonForm = () => { const updateWorkerTimeControlMail = async (state, reason) => { const params = { - year: selectedDate.value.getFullYear(), + year: selectedDateYear.value, week: selectedWeekNumber.value, state, }; @@ -383,7 +402,7 @@ const resendEmail = async () => { const params = { recipient: worker.value[0]?.user?.emailUser?.email, week: selectedWeekNumber.value, - year: selectedDate.value.getFullYear(), + year: selectedDateYear.value, workerId: Number(route.params.id), state: 'SENDED', }; diff --git a/src/pages/Worker/Card/WorkerTimeControlCalendar.vue b/src/pages/Worker/Card/WorkerTimeControlCalendar.vue index 2717a71f4..46ae4b698 100644 --- a/src/pages/Worker/Card/WorkerTimeControlCalendar.vue +++ b/src/pages/Worker/Card/WorkerTimeControlCalendar.vue @@ -102,8 +102,7 @@ const getWorkWeekElements = () => { }; const paintWorkWeeks = async () => { - for (var i = 0; i < workWeeksElements.value.length; i++) { - const element = workWeeksElements.value[i]; + for (const element of workWeeksElements.value) { const week = Number(element.innerHTML); const weekState = workerTimeControlMailsMap.value.get(week); const { className, title } = stateClasses[weekState] || {}; diff --git a/src/pages/Worker/WorkerCreate.vue b/src/pages/Worker/WorkerCreate.vue deleted file mode 100644 index a4c6c2a06..000000000 --- a/src/pages/Worker/WorkerCreate.vue +++ /dev/null @@ -1,254 +0,0 @@ -<script setup> -import { onBeforeMount, ref } from 'vue'; -import { useI18n } from 'vue-i18n'; -import axios from 'axios'; -import VnRow from 'components/ui/VnRow.vue'; -import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; -import VnInputDate from 'components/common/VnInputDate.vue'; -import VnSelect from 'src/components/common/VnSelect.vue'; -import VnLocation from 'src/components/common/VnLocation.vue'; -import VnInput from 'src/components/common/VnInput.vue'; -import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; -import FetchData from 'components/FetchData.vue'; -import FormModel from 'components/FormModel.vue'; -import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue'; -import VnRadio from 'src/components/common/VnRadio.vue'; -import { useState } from 'src/composables/useState'; -import VnSelectWorker from 'src/components/common/VnSelectWorker.vue'; - -const { t } = useI18n(); -const user = useState().getUser(); - -const companiesOptions = ref([]); -const payMethodsOptions = ref([]); -const bankEntitiesOptions = ref([]); -const formData = ref({ companyFk: user.value.companyFk, isFreelance: false }); -const defaultPayMethod = ref(); - -onBeforeMount(async () => { - defaultPayMethod.value = ( - await axios.get('WorkerConfigs/findOne', { - params: { field: ['payMethodFk'] }, - }) - ).data.payMethodFk; - formData.value.payMethodFk = defaultPayMethod.value; -}); - -function handleLocation(data, location) { - const { town, code, provinceFk, countryFk } = location ?? {}; - data.postcode = code; - data.city = town; - data.provinceFk = provinceFk; - data.countryFk = countryFk; -} - -function generateCodeUser(worker) { - if (!worker.firstName || !worker.lastNames) return; - - const totalName = worker.firstName.concat(' ' + worker.lastNames).toLowerCase(); - const totalNameArray = totalName.split(' '); - let newCode = ''; - - for (let part of totalNameArray) newCode += part.charAt(0); - - worker.code = newCode.toUpperCase().slice(0, 3); - worker.name = totalNameArray[0] + newCode.slice(1); - - if (!worker.companyFk) worker.companyFk = user.companyFk; -} - -async function autofillBic(worker) { - if (!worker || !worker.iban) return; - - let bankEntityId = parseInt(worker.iban.substr(4, 4)); - let filter = { where: { id: bankEntityId } }; - - const { data } = await axios.get(`BankEntities`, { params: { filter } }); - const hasData = data && data[0]; - if (hasData) worker.bankEntityFk = data[0].id; - else if (!hasData) worker.bankEntityFk = undefined; -} -</script> -<template> - <FetchData - url="Companies" - @on-fetch="(data) => (companiesOptions = data)" - auto-load - /> - <FetchData - url="Paymethods" - @on-fetch="(data) => (payMethodsOptions = data)" - auto-load - /> - <FetchData - url="BankEntities" - @on-fetch="(data) => (bankEntitiesOptions = data)" - auto-load - /> - <QPage> - <VnSubToolbar> - <template #st-data> - <VnRadio - v-model="formData.isFreelance" - :val="false" - :label="`${t('Internal')}`" - @update:model-value="formData.payMethodFk = defaultPayMethod" - /> - <VnRadio - v-model="formData.isFreelance" - :val="true" - :label="`${t('External')}`" - @update:model-value="delete formData.payMethodFk" - /> - </template> - </VnSubToolbar> - <FormModel - url-create="Workers/new" - model="worker" - :form-initial-data="formData" - @on-data-saved="(__, { id }) => $router.push({ path: `/worker/${id}` })" - > - <template #form="{ data, validate }"> - <VnRow> - <VnInput - v-model="data.firstName" - :label="t('globals.name')" - :rules="validate('Worker.firstName')" - @update:model-value="generateCodeUser(data)" - /> - <VnInput - v-model="data.lastNames" - :label="t('worker.create.lastName')" - :rules="validate('Worker.lastNames')" - @update:model-value="generateCodeUser(data)" - /> - <VnInput - v-model="data.code" - :label="t('worker.create.code')" - :rules="validate('Worker.code')" - /> - </VnRow> - <VnRow> - <VnInput - v-model="data.name" - :label="t('worker.create.webUser')" - :rules="validate('Worker.name')" - /> - <VnInput - v-model="data.email" - :label="t('worker.create.personalEmail')" - :rules="validate('Worker.email')" - /> - </VnRow> - <VnRow> - <VnSelect - :label="t('globals.company')" - v-model="data.companyFk" - :options="companiesOptions" - option-value="id" - option-label="code" - hide-selected - :rules="validate('Worker.company')" - /> - <VnSelectWorker - :label="t('worker.summary.boss')" - v-model="data.bossFk" - :rules="validate('Worker.boss')" - /> - </VnRow> - <VnRow> - <VnInput - v-model="data.fi" - :label="t('worker.create.fi')" - :rules="validate('Worker.fi')" - /> - <VnInputDate - v-model="data.birth" - :label="t('worker.create.birth')" - :rules="validate('Worker.birth')" - :disable="formData.isFreelance" - /> - <VnInput - v-model="data.phone" - :label="t('globals.phone')" - :rules="validate('Worker.phone')" - :disable="formData.isFreelance" - /> - </VnRow> - <VnRow> - <VnLocation - :rules="validate('Worker.postcode')" - :roles-allowed-to-create="['deliveryAssistant']" - @update:model-value="(location) => handleLocation(data, location)" - :disable="formData.isFreelance" - > - </VnLocation> - </VnRow> - <VnRow> - <VnInput - :label="t('globals.street')" - v-model="data.street" - :rules="validate('Worker.street')" - :disable="formData.isFreelance" - /> - </VnRow> - <VnRow> - <VnSelect - :label="t('worker.create.payMethods')" - v-model="data.payMethodFk" - :options="payMethodsOptions" - option-value="id" - option-label="name" - map-options - hide-selected - :rules="validate('Worker.payMethodFk')" - :disable="formData.isFreelance" - @update:model-value="(val) => !val && delete formData.payMethodFk" - /> - <VnInput - v-model="data.iban" - :label="t('worker.create.iban')" - :rules="validate('Worker.iban')" - :disable="formData.isFreelance" - @update:model-value="autofillBic(data)" - > - <template #append> - <QIcon name="info" class="cursor-info"> - <QTooltip>{{ t('components.iban_tooltip') }}</QTooltip> - </QIcon> - </template> - </VnInput> - <VnSelectDialog - :label="t('worker.create.bankEntity')" - v-model="data.bankEntityFk" - :options="bankEntitiesOptions" - option-label="name" - option-value="id" - hide-selected - :roles-allowed-to-create="['salesAssistant', 'hr']" - :rules="validate('Worker.bankEntity')" - :disable="formData.isFreelance" - @update:model-value="autofillBic(data)" - :filter-options="['bic', 'name']" - > - <template #form> - <CreateBankEntityForm - @on-data-saved="(data) => bankEntitiesOptions.push(data)" - /> - </template> - <template #option="scope"> - <QItem v-bind="scope.itemProps"> - <QItemSection v-if="scope.opt"> - <QItemLabel - >{{ scope.opt.bic }} - {{ scope.opt.name }}</QItemLabel - > - </QItemSection> - </QItem> - </template> - </VnSelectDialog> - </VnRow> - </template> - </FormModel> - </QPage> -</template> diff --git a/src/pages/Worker/WorkerDepartment.vue b/src/pages/Worker/WorkerDepartment.vue index fe4c23051..baf6db154 100644 --- a/src/pages/Worker/WorkerDepartment.vue +++ b/src/pages/Worker/WorkerDepartment.vue @@ -1,11 +1,16 @@ <script setup> +import VnSection from 'src/components/common/VnSection.vue'; import WorkerDepartmentTree from './WorkerDepartmentTree.vue'; </script> <template> - <QPage class="column items-center q-pa-md"> - <WorkerDepartmentTree /> - </QPage> + <VnSection data-key="WorkerDepartment" :search-bar="false"> + <template #body> + <div class="flex flex-center q-pa-md"> + <WorkerDepartmentTree /> + </div> + </template> + </VnSection> </template> <i18n> diff --git a/src/pages/Worker/WorkerDepartmentTree.vue b/src/pages/Worker/WorkerDepartmentTree.vue index f349b449d..9abf4e312 100644 --- a/src/pages/Worker/WorkerDepartmentTree.vue +++ b/src/pages/Worker/WorkerDepartmentTree.vue @@ -111,18 +111,16 @@ function handleEvent(type, event, node) { switch (type) { case 'path': state.set('TreeState', lastId); - node.id && router.push({ path: `/department/department/${node.id}/summary` }); + node.id && router.push({ path: `/worker/department/${node.id}/summary` }); break; case 'tab': state.set('TreeState', lastId); - node.id && - window.open(`#/department/department/${node.id}/summary`, '_blank'); + node.id && window.open(`#/worker/department/${node.id}/summary`, '_blank'); break; default: - node.id && - router.push({ path: `#/department/department/${node.id}/summary` }); + node.id && router.push({ path: `#/worker/department/${node.id}/summary` }); break; } } diff --git a/src/pages/Worker/WorkerList.vue b/src/pages/Worker/WorkerList.vue index c2ddfcd20..48393a8c7 100644 --- a/src/pages/Worker/WorkerList.vue +++ b/src/pages/Worker/WorkerList.vue @@ -2,7 +2,6 @@ import { onBeforeMount, computed, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; -import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import VnTable from 'src/components/VnTable/VnTable.vue'; import WorkerSummary from './Card/WorkerSummary.vue'; import VnRow from 'src/components/ui/VnRow.vue'; @@ -14,12 +13,11 @@ import VnLocation from 'src/components/common/VnLocation.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue'; import FetchData from 'src/components/FetchData.vue'; -import RightMenu from 'src/components/common/RightMenu.vue'; import WorkerFilter from './WorkerFilter.vue'; import { useState } from 'src/composables/useState'; import axios from 'axios'; import VnSelectWorker from 'src/components/common/VnSelectWorker.vue'; - +import VnSection from 'src/components/common/VnSection.vue'; const { t } = useI18n(); const tableRef = ref(); const { viewSummary } = useSummaryDialog(); @@ -31,6 +29,7 @@ const postcodesOptions = ref([]); const user = useState().getUser(); const defaultPayMethod = ref(); const bankEntitiesRef = ref(); +const dataKey = 'WorkerList'; const columns = computed(() => [ { align: 'left', @@ -170,11 +169,6 @@ async function autofillBic(worker) { } </script> <template> - <VnSearchbar - data-key="WorkerList" - :label="t('Search worker')" - :info="t('You can search by worker id or name')" - /> <FetchData url="Companies" @on-fetch="(data) => (companiesOptions = data)" @@ -191,173 +185,202 @@ async function autofillBic(worker) { @on-fetch="(data) => (bankEntitiesOptions = data)" auto-load /> - <RightMenu> - <template #right-panel> + + <VnSection + :data-key="dataKey" + :columns="columns" + prefix="workerSearch" + :array-data-props="{ + url: 'Workers/filter', + order: ['id DESC'], + }" + > + <template #rightMenu> <WorkerFilter data-key="WorkerList" /> </template> - </RightMenu> - <VnTable - v-if="defaultPayMethod" - ref="tableRef" - data-key="WorkerList" - url="Workers/filter" - :create="{ - urlCreate: 'Workers/new', - title: t('Create worker'), - onDataSaved: ({ id }) => tableRef.redirect(id), - formInitialData: { - payMethodFk: defaultPayMethod, - companyFk: user.companyFk, - isFreelance: false, - }, - }" - :columns="columns" - default-mode="table" - redirect="worker" - :right-search="false" - :order="['id DESC']" - > - <template #more-create-dialog="{ data }"> - <div class="q-pa-lg full-width"> - <VnRadio - v-model="data.isFreelance" - :val="false" - :label="`${t('Internal')}`" - @update:model-value="data.payMethodFk = defaultPayMethod" - /> - <VnRadio - v-model="data.isFreelance" - :val="true" - :label="`${t('External')}`" - @update:model-value="delete data.payMethodFk" - /> - <VnRow> - <VnInput - next - v-model="data.firstName" - :label="t('globals.name')" - @update:model-value="generateCodeUser(data)" - /> - <VnInput - v-model="data.lastNames" - :label="t('worker.create.lastName')" - @update:model-value="generateCodeUser(data)" - /> - <VnInput v-model="data.code" :label="t('worker.create.code')" /> - </VnRow> - <VnRow> - <VnInput v-model="data.name" :label="t('worker.create.webUser')" /> - <VnInput - v-model="data.email" - type="email" - :label="t('worker.create.personalEmail')" - /> - </VnRow> - <VnRow> - <VnSelect - :label="t('globals.company')" - v-model="data.companyFk" - :options="companiesOptions" - option-value="id" - option-label="code" - hide-selected - /> - <VnSelectWorker - :label="t('worker.summary.boss')" - v-model="data.bossFk" - /> - </VnRow> - <VnRow> - <VnInput v-model="data.fi" :label="t('worker.create.fi')" /> - <VnInputDate - v-model="data.birth" - :label="t('worker.create.birth')" - :disable="data.isFreelance" - /> - <VnInput - v-model="data.phone" - :label="t('globals.phone')" - :disable="data.isFreelance" - /> - </VnRow> - <VnRow> - <VnLocation - :roles-allowed-to-create="['deliveryAssistant']" - :acls="[{ model: 'Town', props: '*', accessType: 'WRITE' }]" - :options="postcodesOptions" - @update:model-value="(location) => handleLocation(data, location)" - :disable="data.isFreelance" - > - </VnLocation> - </VnRow> - <VnRow> - <VnInput - :label="t('globals.street')" - :model-value="uppercaseStreetModel(data).get()" - @update:model-value="uppercaseStreetModel(data).set" - :disable="data.isFreelance" - /> - </VnRow> - <VnRow> - <VnSelect - :label="t('worker.create.payMethods')" - v-model="data.payMethodFk" - :options="payMethodsOptions" - option-value="id" - option-label="name" - map-options - hide-selected - :disable="data.isFreelance" - @update:model-value="(val) => !val && delete data.payMethodFk" - /> - <VnInput - v-model="data.iban" - :label="t('worker.create.iban')" - :disable="data.isFreelance" - @update:model-value="autofillBic(data)" - > - <template #append> - <QIcon name="info" class="cursor-info"> - <QTooltip>{{ t('components.iban_tooltip') }}</QTooltip> - </QIcon> - </template> - </VnInput> - </VnRow> - <VnRow> - <VnSelectDialog - :label="t('worker.create.bankEntity')" - v-model="data.bankEntityFk" - :options="bankEntitiesOptions" - option-label="name" - option-value="id" - hide-selected - :acls="[{ model: 'BankEntity', props: '*', accessType: 'WRITE' }]" - :disable="data.isFreelance" - @update:model-value="autofillBic(data)" - :filter-options="['bic', 'name']" - > - <template #form> - <CreateBankEntityForm - @on-data-saved=" - (_, resp) => handleNewBankEntity(data, resp) + <template #body> + <VnTable + v-if="defaultPayMethod" + ref="tableRef" + :data-key="dataKey" + :create="{ + urlCreate: 'Workers/new', + title: t('Create worker'), + onDataSaved: ({ id }) => tableRef.redirect(id), + formInitialData: { + payMethodFk: defaultPayMethod, + companyFk: user.companyFk, + isFreelance: false, + }, + }" + default-mode="table" + :columns="columns" + redirect="worker" + :right-search="false" + > + <template #more-create-dialog="{ data }"> + <div class="q-pa-lg full-width"> + <VnRadio + v-model="data.isFreelance" + :val="false" + :label="`${t('Internal')}`" + @update:model-value="data.payMethodFk = defaultPayMethod" + /> + <VnRadio + v-model="data.isFreelance" + :val="true" + :label="`${t('External')}`" + @update:model-value="delete data.payMethodFk" + /> + <VnRow> + <VnInput + next + v-model="data.firstName" + :label="t('globals.name')" + @update:model-value="generateCodeUser(data)" + /> + <VnInput + v-model="data.lastNames" + :label="t('worker.create.lastName')" + @update:model-value="generateCodeUser(data)" + /> + <VnInput + v-model="data.code" + :label="t('worker.create.code')" + /> + </VnRow> + <VnRow> + <VnInput + v-model="data.name" + :label="t('worker.create.webUser')" + /> + <VnInput + v-model="data.email" + type="email" + :label="t('worker.create.personalEmail')" + /> + </VnRow> + <VnRow> + <VnSelect + :label="t('globals.company')" + v-model="data.companyFk" + :options="companiesOptions" + option-value="id" + option-label="code" + hide-selected + /> + <VnSelectWorker + :label="t('worker.summary.boss')" + v-model="data.bossFk" + /> + </VnRow> + <VnRow> + <VnInput v-model="data.fi" :label="t('worker.create.fi')" /> + <VnInputDate + v-model="data.birth" + :label="t('worker.create.birth')" + :disable="data.isFreelance" + /> + <VnInput + v-model="data.phone" + :label="t('globals.phone')" + :disable="data.isFreelance" + /> + </VnRow> + <VnRow> + <VnLocation + :roles-allowed-to-create="['deliveryAssistant']" + :acls="[ + { model: 'Town', props: '*', accessType: 'WRITE' }, + ]" + :options="postcodesOptions" + @update:model-value=" + (location) => handleLocation(data, location) + " + :disable="data.isFreelance" + > + </VnLocation> + </VnRow> + <VnRow> + <VnInput + :label="t('globals.street')" + :model-value="uppercaseStreetModel(data).get()" + @update:model-value="uppercaseStreetModel(data).set" + :disable="data.isFreelance" + /> + </VnRow> + <VnRow> + <VnSelect + :label="t('worker.create.payMethods')" + v-model="data.payMethodFk" + :options="payMethodsOptions" + option-value="id" + option-label="name" + map-options + hide-selected + :disable="data.isFreelance" + @update:model-value=" + (val) => !val && delete data.payMethodFk " /> - </template> - <template #option="scope"> - <QItem v-bind="scope.itemProps"> - <QItemSection v-if="scope.opt"> - <QItemLabel - >{{ scope.opt.bic }} - {{ scope.opt.name }}</QItemLabel - > - </QItemSection> - </QItem> - </template> - </VnSelectDialog> - </VnRow> - </div> + <VnInput + v-model="data.iban" + :label="t('worker.create.iban')" + :disable="data.isFreelance" + @update:model-value="autofillBic(data)" + > + <template #append> + <QIcon name="info" class="cursor-info"> + <QTooltip>{{ + t('components.iban_tooltip') + }}</QTooltip> + </QIcon> + </template> + </VnInput> + </VnRow> + <VnRow> + <VnSelectDialog + :label="t('worker.create.bankEntity')" + v-model="data.bankEntityFk" + :options="bankEntitiesOptions" + option-label="name" + option-value="id" + hide-selected + :acls="[ + { + model: 'BankEntity', + props: '*', + accessType: 'WRITE', + }, + ]" + :disable="data.isFreelance" + @update:model-value="autofillBic(data)" + :filter-options="['bic', 'name']" + > + <template #form> + <CreateBankEntityForm + @on-data-saved=" + (_, resp) => handleNewBankEntity(data, resp) + " + /> + </template> + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection v-if="scope.opt"> + <QItemLabel + >{{ scope.opt.bic }} + {{ scope.opt.name }}</QItemLabel + > + </QItemSection> + </QItem> + </template> + </VnSelectDialog> + </VnRow> + </div> + </template> + </VnTable> </template> - </VnTable> + </VnSection> </template> <i18n> diff --git a/src/pages/Worker/locale/en.yml b/src/pages/Worker/locale/en.yml index 8276977fd..1d47a0c1d 100644 --- a/src/pages/Worker/locale/en.yml +++ b/src/pages/Worker/locale/en.yml @@ -1,3 +1,6 @@ +workerSearch: + search: Search worker + searchInfo: Search worker by id or name passwordRequirements: 'The password must have at least { length } length characters, {nAlpha} alphabetic characters, {nUpper} capital letters, {nDigits} digits and {nPunct} symbols (Ex: $%&.)\n' tableColumns: id: ID diff --git a/src/pages/Worker/locale/es.yml b/src/pages/Worker/locale/es.yml index 9c7618bc3..e4bb724e0 100644 --- a/src/pages/Worker/locale/es.yml +++ b/src/pages/Worker/locale/es.yml @@ -1,5 +1,6 @@ -Search worker: Buscar trabajador -You can search by worker id or name: Puedes buscar por id o nombre del trabajador +workerSearch: + search: Buscar trabajador + searchInfo: Buscar trabajador por id o nombre Locker: Taquilla Internal: Interno External: Externo diff --git a/src/pages/Zone/Card/ZoneBasicData.vue b/src/pages/Zone/Card/ZoneBasicData.vue index 2d65476ce..c38da614c 100644 --- a/src/pages/Zone/Card/ZoneBasicData.vue +++ b/src/pages/Zone/Card/ZoneBasicData.vue @@ -100,6 +100,16 @@ const agencyOptions = ref([]); required="true" clearable /> + <VnInput + v-model="data.priceOptimum" + :label="t('Price optimum')" + type="number" + min="0" + required="true" + clearable + /> + </VnRow> + <VnRow> <VnInput v-model="data.bonus" :label="t('Bonus')" @@ -107,8 +117,6 @@ const agencyOptions = ref([]); min="0" clearable /> - </VnRow> - <VnRow> <VnSelect :label="t('Distribution point')" v-model="data.addressFk" @@ -152,6 +160,7 @@ es: Traveling days: Dias de viaje Closing: Cierre Price: Precio + Price optimum: Precio óptimo Bonus: Bonificación Inflation: Inflación Volumetric: Volumétrico diff --git a/src/pages/Zone/Card/ZoneEventExclusionForm.vue b/src/pages/Zone/Card/ZoneEventExclusionForm.vue index 0882036c1..4b6aa52bd 100644 --- a/src/pages/Zone/Card/ZoneEventExclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventExclusionForm.vue @@ -59,7 +59,7 @@ const arrayData = useArrayData('ZoneEvents'); const exclusionGeoCreate = async () => { const params = { zoneFk: parseInt(route.params.id), - date: dated.value, + date: dated, geoIds: tickedNodes.value, }; await axios.post('Zones/exclusionGeo', params); diff --git a/src/pages/Zone/Card/ZoneEventInclusionForm.vue b/src/pages/Zone/Card/ZoneEventInclusionForm.vue index b4096e5a2..805d03b27 100644 --- a/src/pages/Zone/Card/ZoneEventInclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventInclusionForm.vue @@ -182,13 +182,19 @@ onMounted(() => { min="0" /> <VnInput - v-model="eventInclusionFormData.bonus" - :label="t('zone.bonus')" + v-model="eventInclusionFormData.priceOptimum" + :label="t('list.priceOptimum')" type="number" min="0" /> </VnRow> <VnRow> + <VnInput + v-model="eventInclusionFormData.bonus" + :label="t('zone.bonus')" + type="number" + min="0" + /> <VnInput v-model="eventInclusionFormData.m3Max" :label="t('zone.m3Max')" diff --git a/src/pages/Zone/Card/ZoneSummary.vue b/src/pages/Zone/Card/ZoneSummary.vue index 384ee1fe9..124802633 100644 --- a/src/pages/Zone/Card/ZoneSummary.vue +++ b/src/pages/Zone/Card/ZoneSummary.vue @@ -11,6 +11,7 @@ import { getUrl } from 'src/composables/getUrl'; import { toCurrency } from 'filters/index'; import { toTimeFormat } from 'src/filters/date'; import axios from 'axios'; +import ZoneDescriptorMenuItems from './ZoneDescriptorMenuItems.vue'; const route = useRoute(); const { t } = useI18n(); @@ -79,6 +80,9 @@ onMounted(async () => { <template #header="{ entity }"> <div>#{{ entity.id }} - {{ entity.name }}</div> </template> + <template #menu="{ entity }"> + <ZoneDescriptorMenuItems :zone="entity" /> + </template> <template #body="{ entity: zone }"> <QCard class="vn-one"> <VnTitle :url="zoneUrl + `basic-data`" :text="t('summary.basicData')" /> diff --git a/src/pages/Zone/ZoneDeliveryPanel.vue b/src/pages/Zone/ZoneDeliveryPanel.vue index ccc7aab3f..0a535afcb 100644 --- a/src/pages/Zone/ZoneDeliveryPanel.vue +++ b/src/pages/Zone/ZoneDeliveryPanel.vue @@ -89,7 +89,7 @@ watch( v-model="formData.geoFk" url="Postcodes/location" :fields="['geoFk', 'code', 'townFk', 'countryFk']" - sort-by="code, townFk" + :sort-by="['code ASC']" option-value="geoFk" option-label="code" :filter-options="['code']" @@ -97,6 +97,7 @@ watch( dense outlined rounded + map-key="geoFk" > <template #option="{ itemProps, opt }"> <QItem v-bind="itemProps"> diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue index dcd136383..71a3d27ac 100644 --- a/src/pages/Zone/ZoneList.vue +++ b/src/pages/Zone/ZoneList.vue @@ -14,8 +14,10 @@ import VnTable from 'src/components/VnTable/VnTable.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnInputTime from 'src/components/common/VnInputTime.vue'; +import RightMenu from 'src/components/common/RightMenu.vue'; import ZoneFilterPanel from './ZoneFilterPanel.vue'; -import VnSection from 'src/components/common/VnSection.vue'; +import ZoneSearchbar from './Card/ZoneSearchbar.vue'; +import FetchData from 'src/components/FetchData.vue'; const { t } = useI18n(); const router = useRouter(); @@ -24,7 +26,7 @@ const { viewSummary } = useSummaryDialog(); const { openConfirmationModal } = useVnConfirm(); const tableRef = ref(); const warehouseOptions = ref([]); -const dataKey = 'ZoneList'; +const validAddresses = ref([]); const tableFilter = { include: [ @@ -34,6 +36,32 @@ const tableFilter = { fields: ['id', 'name'], }, }, + { + relation: 'address', + scope: { + fields: ['id', 'nickname', 'provinceFk', 'postalCode'], + include: [ + { + relation: 'province', + scope: { + fields: ['id', 'name'], + }, + }, + { + relation: 'postcode', + scope: { + fields: ['code', 'townFk'], + include: { + relation: 'town', + scope: { + fields: ['id', 'name'], + }, + }, + }, + }, + ], + }, + }, ], }; @@ -95,7 +123,14 @@ const columns = computed(() => [ label: t('list.close'), cardVisible: true, format: (row) => toTimeFormat(row.hour), - hidden: true, + columnFilter: false, + }, + { + align: 'left', + name: 'addressFk', + label: t('list.addressFk'), + cardVisible: true, + columnFilter: false, }, { align: 'right', @@ -129,45 +164,51 @@ const handleClone = (id) => { () => clone(id) ); }; + +function showValidAddresses(row) { + if (row.addressFk) { + const isValid = validAddresses.value.some( + (address) => address.addressFk === row.addressFk + ); + if (isValid) + return `${row.address?.nickname}, + ${row.address?.postcode?.town?.name} (${row.address?.province?.name})`; + else return '-'; + } + return '-'; +} </script> <template> - <VnSection - :data-key="dataKey" - :columns="columns" - prefix="list" - :array-data-props="{ - url: 'Zones', - order: ['id'], - exprBuilder, - }" - > - <template #rightMenu> + <FetchData + url="RoadmapAddresses" + auto-load + @on-fetch="(data) => (validAddresses = data)" + /> + <ZoneSearchbar /> + <RightMenu> + <template #right-panel> <ZoneFilterPanel data-key="ZonesList" /> </template> - <template #body> + </RightMenu> <VnTable ref="tableRef" - data-key="dataKey" + data-key="ZonesList" + url="Zones" :create="{ urlCreate: 'Zones', title: t('list.createZone'), onDataSaved: ({ id }) => tableRef.redirect(`${id}/location`), formInitialData: {}, }" - default-mode="table" - :columns="columns" :user-filter="tableFilter" - :user-params="userParams" - :right-search="false" + :columns="columns" redirect="zone" - v-model:selected="selectedRows" - :table="{ - 'row-key': 'id', - slelection: 'multiple', - }" - data-cy="zoneListTable" + :right-search="false" > + <template #column-addressFk="{ row }"> + {{ showValidAddresses(row) }} + </template> <template #more-create-dialog="{ data }"> <VnSelect url="AgencyModes" @@ -211,13 +252,10 @@ const handleClone = (id) => { /> </template> </VnTable> - </template> -</VnSection> </template> - <i18n> es: Search zone: Buscar zona You can search zones by id or name: Puedes buscar zonas por id o nombre -</i18n> +</i18n> \ No newline at end of file diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml index 8fb5528d2..92d406351 100644 --- a/src/pages/Zone/locale/en.yml +++ b/src/pages/Zone/locale/en.yml @@ -32,6 +32,7 @@ list: warehouse: Warehouse createZone: Create zone zoneSummary: Summary + addressFk: Address create: name: Name closingHour: Closing hour @@ -41,6 +42,7 @@ summary: basicData: Basic data closeHour: Close hour filterPanel: + name: Name agencyModeFk: Agency deliveryPanel: pickup: Pick up diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml index d0bab83f4..575b12f7a 100644 --- a/src/pages/Zone/locale/es.yml +++ b/src/pages/Zone/locale/es.yml @@ -22,6 +22,7 @@ list: agency: Agencia close: Cierre price: Precio + priceOptimum: Precio óptimo create: Crear zona openSummary: Detalles searchZone: Buscar zonas @@ -33,6 +34,7 @@ list: isVolumetric: Volumétrico createZone: Crear zona zoneSummary: Resumen + addressFk: Consignatario create: closingHour: Hora de cierre itemMaxSize: Medida máxima @@ -41,6 +43,7 @@ summary: basicData: Datos básicos closeHour: Hora de cierre filterPanel: + name: Nombre agencyModeFk: Agencia deliveryPanel: pickup: Recogida diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index 8b0a70896..4dfde08da 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -1,19 +1,12 @@ import { RouterView } from 'vue-router'; -export default { - name: 'Claim', - path: '/claim', +const claimCard = { + name: 'ClaimCard', + path: ':id', + component: () => import('src/pages/Claim/Card/ClaimCard.vue'), + redirect: { name: 'ClaimSummary' }, meta: { - title: 'claims', - icon: 'vn:claims', - moduleName: 'Claim', - keyBinding: 'r', - }, - component: RouterView, - redirect: { name: 'ClaimMain' }, - menus: { - main: ['ClaimList'], - card: [ + menu: [ 'ClaimBasicData', 'ClaimLines', 'ClaimPhotos', @@ -23,109 +16,125 @@ export default { 'ClaimLog', ], }, + children: [ + { + path: 'summary', + name: 'ClaimSummary', + meta: { + title: 'summary', + icon: 'launch', + }, + component: () => import('src/pages/Claim/Card/ClaimSummary.vue'), + }, + { + path: 'basic-data', + name: 'ClaimBasicData', + meta: { + title: 'basicData', + icon: 'vn:settings', + acls: [{ model: 'Claim', props: 'findById', accessType: 'READ' }], + }, + component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'), + }, + { + path: 'lines', + name: 'ClaimLines', + meta: { + title: 'lines', + icon: 'vn:details', + }, + component: () => import('src/pages/Claim/Card/ClaimLines.vue'), + }, + { + path: 'photos', + name: 'ClaimPhotos', + meta: { + title: 'photos', + icon: 'image', + }, + component: () => import('src/pages/Claim/Card/ClaimPhoto.vue'), + }, + { + path: 'notes', + name: 'ClaimNotes', + meta: { + title: 'notes', + icon: 'draft', + }, + component: () => import('src/pages/Claim/Card/ClaimNotes.vue'), + }, + { + path: 'development', + name: 'ClaimDevelopment', + meta: { + title: 'development', + icon: 'vn:traceability', + acls: [ + { + model: 'ClaimDevelopment', + props: '*', + accessType: 'WRITE', + }, + ], + }, + component: () => import('src/pages/Claim/Card/ClaimDevelopment.vue'), + }, + { + path: 'action', + name: 'ClaimAction', + meta: { + title: 'action', + icon: 'vn:actions', + }, + component: () => import('src/pages/Claim/Card/ClaimAction.vue'), + }, + { + path: 'log', + name: 'ClaimLog', + meta: { + title: 'log', + icon: 'history', + }, + component: () => import('src/pages/Claim/Card/ClaimLog.vue'), + }, + ], +} + +export default { + name: 'Claim', + path: '/claim', + meta: { + title: 'claims', + icon: 'vn:claims', + moduleName: 'Claim', + keyBinding: 'r', + menu: ['ClaimList'], + }, + component: RouterView, + redirect: { name: 'ClaimMain' }, children: [ { name: 'ClaimMain', path: '', component: () => import('src/components/common/VnModule.vue'), - redirect: { name: 'ClaimList' }, + redirect: { name: 'ClaimIndexMain' }, children: [ { - name: 'ClaimList', - path: 'list', - meta: { - title: 'list', - icon: 'view_list', - }, + path: '', + name: 'ClaimIndexMain', + redirect: { name: 'ClaimList' }, component: () => import('src/pages/Claim/ClaimList.vue'), - }, - ], - }, - { - name: 'ClaimCard', - path: ':id', - component: () => import('src/pages/Claim/Card/ClaimCard.vue'), - redirect: { name: 'ClaimSummary' }, - children: [ - { - name: 'ClaimSummary', - path: 'summary', - meta: { - title: 'summary', - icon: 'launch', - }, - component: () => import('src/pages/Claim/Card/ClaimSummary.vue'), - }, - { - name: 'ClaimBasicData', - path: 'basic-data', - meta: { - title: 'basicData', - icon: 'vn:settings', - acls: [{ model: 'Claim', props: 'findById', accessType: 'READ' }], - }, - component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'), - }, - { - name: 'ClaimLines', - path: 'lines', - meta: { - title: 'lines', - icon: 'vn:details', - }, - component: () => import('src/pages/Claim/Card/ClaimLines.vue'), - }, - { - name: 'ClaimPhotos', - path: 'photos', - meta: { - title: 'photos', - icon: 'image', - }, - component: () => import('src/pages/Claim/Card/ClaimPhoto.vue'), - }, - { - name: 'ClaimNotes', - path: 'notes', - meta: { - title: 'notes', - icon: 'draft', - }, - component: () => import('src/pages/Claim/Card/ClaimNotes.vue'), - }, - { - name: 'ClaimDevelopment', - path: 'development', - meta: { - title: 'development', - icon: 'vn:traceability', - acls: [ - { - model: 'ClaimDevelopment', - props: '*', - accessType: 'WRITE', + children: [ + { + name: 'ClaimList', + path: 'list', + meta: { + title: 'list', + icon: 'view_list', }, - ], - }, - component: () => import('src/pages/Claim/Card/ClaimDevelopment.vue'), - }, - { - name: 'ClaimAction', - path: 'action', - meta: { - title: 'action', - icon: 'vn:actions', - }, - component: () => import('src/pages/Claim/Card/ClaimAction.vue'), - }, - { - name: 'ClaimLog', - path: 'log', - meta: { - title: 'log', - icon: 'history', - }, - component: () => import('src/pages/Claim/Card/ClaimLog.vue'), + }, + claimCard, + ], }, ], }, diff --git a/src/router/modules/department.js b/src/router/modules/department.js deleted file mode 100644 index 9aab40534..000000000 --- a/src/router/modules/department.js +++ /dev/null @@ -1,47 +0,0 @@ -import { RouterView } from 'vue-router'; - -export default { - path: '/department', - name: 'Department', - meta: { - title: 'department', - icon: 'vn:greuge', - moduleName: 'Department', - }, - component: RouterView, - redirect: { name: 'WorkerDepartment' }, - menus: { - main: [], - card: ['DepartmentBasicData'], - }, - children: [ - { - name: 'DepartmentCard', - path: 'department/:id', - component: () => import('src/pages/Department/Card/DepartmentCard.vue'), - redirect: { name: 'DepartmentSummary' }, - children: [ - { - name: 'DepartmentSummary', - path: 'summary', - meta: { - title: 'summary', - icon: 'launch', - }, - component: () => - import('src/pages/Department/Card/DepartmentSummary.vue'), - }, - { - name: 'DepartmentBasicData', - path: 'basic-data', - meta: { - title: 'basicData', - icon: 'vn:settings', - }, - component: () => - import('src/pages/Department/Card/DepartmentBasicData.vue'), - }, - ], - }, - ], -}; diff --git a/src/router/modules/index.js b/src/router/modules/index.js index f28fed1c2..a22d5399c 100644 --- a/src/router/modules/index.js +++ b/src/router/modules/index.js @@ -11,7 +11,6 @@ import Route from './route'; import Supplier from './supplier'; import Travel from './travel'; import Order from './order'; -import Department from './department'; import Entry from './entry'; import roadmap from './roadmap'; import Parking from './parking'; @@ -35,7 +34,6 @@ export default [ Travel, Order, invoiceIn, - Department, Entry, roadmap, Parking, diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index c732664ec..e9fb0c4f1 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -1,19 +1,12 @@ import { RouterView } from 'vue-router'; -export default { - path: '/worker', - name: 'Worker', +const workerCard = { + name: 'WorkerCard', + path: ':id', + component: () => import('src/pages/Worker/Card/WorkerCard.vue'), + redirect: { name: 'WorkerSummary' }, meta: { - title: 'workers', - icon: 'vn:worker', - moduleName: 'Worker', - keyBinding: 'w', - }, - component: RouterView, - redirect: { name: 'WorkerMain' }, - menus: { - main: ['WorkerList', 'WorkerDepartment'], - card: [ + menu: [ 'WorkerBasicData', 'WorkerNotes', 'WorkerPda', @@ -33,207 +26,247 @@ export default { }, children: [ { - path: '', - name: 'WorkerMain', - component: () => import('src/components/common/VnModule.vue'), - redirect: { name: 'WorkerList' }, + name: 'WorkerSummary', + path: 'summary', + meta: { + title: 'summary', + icon: 'launch', + }, + component: () => import('src/pages/Worker/Card/WorkerSummary.vue'), + }, + { + path: 'basic-data', + name: 'WorkerBasicData', + meta: { + title: 'basicData', + icon: 'vn:settings', + acls: [ + { + model: 'Worker', + props: 'updateAttributes', + accessType: 'WRITE', + }, + ], + }, + component: () => import('src/pages/Worker/Card/WorkerBasicData.vue'), + }, + { + path: 'notes', + name: 'NotesCard', + redirect: { name: 'WorkerNotes' }, children: [ { - path: 'list', - name: 'WorkerList', + path: '', + name: 'WorkerNotes', meta: { - title: 'list', - icon: 'view_list', + title: 'notes', + icon: 'vn:notes', }, - component: () => import('src/pages/Worker/WorkerList.vue'), - }, - { - path: 'department', - name: 'WorkerDepartment', - meta: { - title: 'department', - icon: 'vn:greuge', - }, - component: () => import('src/pages/Worker/WorkerDepartment.vue'), - }, - { - path: 'create', - name: 'WorkerCreate', - meta: { - title: 'workerCreate', - icon: 'add', - }, - component: () => import('src/pages/Worker/WorkerCreate.vue'), + component: () => import('src/pages/Worker/Card/WorkerNotes.vue'), }, ], }, { - name: 'WorkerCard', - path: ':id', - component: () => import('src/pages/Worker/Card/WorkerCard.vue'), - redirect: { name: 'WorkerSummary' }, + name: 'WorkerTimeControl', + path: 'time-control', + meta: { + title: 'timeControl', + icon: 'access_time', + }, + component: () => import('src/pages/Worker/Card/WorkerTimeControl.vue'), + }, + { + name: 'WorkerCalendar', + path: 'calendar', + meta: { + title: 'calendar', + icon: 'calendar_today', + }, + component: () => import('src/pages/Worker/Card/WorkerCalendar.vue'), + }, + { + name: 'WorkerPda', + path: 'pda', + meta: { + title: 'pda', + icon: 'phone_android', + }, + component: () => import('src/pages/Worker/Card/WorkerPda.vue'), + }, + { + name: 'WorkerNotificationsManager', + path: 'notifications', + meta: { + title: 'notifications', + icon: 'notifications', + }, + component: () => + import('src/pages/Worker/Card/WorkerNotificationsManager.vue'), + }, + { + path: 'pbx', + name: 'WorkerPBX', + meta: { + title: 'pbx', + icon: 'vn:pbx', + }, + component: () => import('src/pages/Worker/Card/WorkerPBX.vue'), + }, + { + name: 'WorkerDms', + path: 'dms', + meta: { + title: 'dms', + icon: 'cloud_upload', + }, + component: () => import('src/pages/Worker/Card/WorkerDms.vue'), + }, + { + name: 'WorkerLog', + path: 'log', + meta: { + title: 'log', + icon: 'vn:History', + acls: [{ model: 'WorkerLog', props: 'find', accessType: 'READ' }], + }, + component: () => import('src/pages/Worker/Card/WorkerLog.vue'), + }, + { + name: 'WorkerLocker', + path: 'locker', + meta: { + title: 'locker', + icon: 'lock', + }, + component: () => import('src/pages/Worker/Card/WorkerLocker.vue'), + }, + { + name: 'WorkerBalance', + path: 'balance', + meta: { + title: 'balance', + icon: 'balance', + }, + component: () => import('src/pages/Worker/Card/WorkerBalance.vue'), + }, + { + name: 'WorkerFormation', + path: 'formation', + meta: { + title: 'formation', + icon: 'clinical_notes', + }, + component: () => import('src/pages/Worker/Card/WorkerFormation.vue'), + }, + { + name: 'WorkerMedical', + path: 'medical', + meta: { + title: 'medical', + icon: 'medical_information', + }, + component: () => import('src/pages/Worker/Card/WorkerMedical.vue'), + }, + { + name: 'WorkerPit', + path: 'pit', + meta: { + title: 'pit', + icon: 'lock', + }, + component: () => import('src/pages/Worker/Card/WorkerPit.vue'), + }, + { + name: 'WorkerOperator', + path: 'operator', + meta: { + title: 'operator', + icon: 'person', + }, + component: () => import('src/pages/Worker/Card/WorkerOperator.vue'), + }, + ], +}; + +const departmentCard = { + name: 'DepartmentCard', + path: ':id', + component: () => import('src/pages/Department/Card/DepartmentCard.vue'), + redirect: { name: 'DepartmentSummary' }, + meta: { + menu: ['DepartmentBasicData'], + }, + children: [ + { + path: 'summary', + name: 'DepartmentSummary', + meta: { + title: 'summary', + icon: 'launch', + }, + component: () => import('src/pages/Department/Card/DepartmentSummary.vue'), + }, + { + path: 'basic-data', + name: 'DepartmentBasicData', + meta: { + title: 'basicData', + icon: 'vn:settings', + }, + component: () => import('src/pages/Department/Card/DepartmentBasicData.vue'), + }, + ], +}; + +export default { + name: 'Worker', + path: '/worker', + meta: { + title: 'workers', + icon: 'vn:worker', + moduleName: 'Worker', + keyBinding: 'w', + menu: ['WorkerList', 'WorkerDepartment'], + }, + component: RouterView, + redirect: { name: 'WorkerMain' }, + children: [ + { + path: '', + name: 'WorkerMain', + component: () => import('src/components/common/VnModule.vue'), + redirect: { name: 'WorkerIndexMain' }, children: [ { - name: 'WorkerSummary', - path: 'summary', - meta: { - title: 'summary', - icon: 'launch', - }, - component: () => import('src/pages/Worker/Card/WorkerSummary.vue'), - }, - { - path: 'basic-data', - name: 'WorkerBasicData', - meta: { - title: 'basicData', - icon: 'vn:settings', - acls: [ - { - model: 'Worker', - props: 'updateAttributes', - accessType: 'WRITE', - }, - ], - }, - component: () => import('src/pages/Worker/Card/WorkerBasicData.vue'), - }, - { - path: 'notes', - name: 'NotesCard', - redirect: { name: 'WorkerNotes' }, + path: '', + name: 'WorkerIndexMain', + redirect: { name: 'WorkerList' }, + component: () => import('src/pages/Worker/WorkerList.vue'), children: [ { - path: '', - name: 'WorkerNotes', + name: 'WorkerList', + path: 'list', meta: { - title: 'notes', - icon: 'vn:notes', + title: 'list', + icon: 'view_list', }, - component: () => - import('src/pages/Worker/Card/WorkerNotes.vue'), }, + workerCard, ], }, { - name: 'WorkerTimeControl', - path: 'time-control', - meta: { - title: 'timeControl', - icon: 'access_time', - }, - component: () => - import('src/pages/Worker/Card/WorkerTimeControl.vue'), - }, - { - name: 'WorkerCalendar', - path: 'calendar', - meta: { - title: 'calendar', - icon: 'calendar_today', - }, - component: () => import('src/pages/Worker/Card/WorkerCalendar.vue'), - }, - { - name: 'WorkerPda', - path: 'pda', - meta: { - title: 'pda', - icon: 'phone_android', - }, - component: () => import('src/pages/Worker/Card/WorkerPda.vue'), - }, - { - name: 'WorkerNotificationsManager', - path: 'notifications', - meta: { - title: 'notifications', - icon: 'notifications', - }, - component: () => - import('src/pages/Worker/Card/WorkerNotificationsManager.vue'), - }, - { - path: 'pbx', - name: 'WorkerPBX', - meta: { - title: 'pbx', - icon: 'vn:pbx', - }, - component: () => import('src/pages/Worker/Card/WorkerPBX.vue'), - }, - { - name: 'WorkerDms', - path: 'dms', - meta: { - title: 'dms', - icon: 'cloud_upload', - }, - component: () => import('src/pages/Worker/Card/WorkerDms.vue'), - }, - { - name: 'WorkerLog', - path: 'log', - meta: { - title: 'log', - icon: 'vn:History', - acls: [{ model: 'WorkerLog', props: 'find', accessType: 'READ' }], - }, - component: () => import('src/pages/Worker/Card/WorkerLog.vue'), - }, - { - name: 'WorkerLocker', - path: 'locker', - meta: { - title: 'locker', - icon: 'lock', - }, - component: () => import('src/pages/Worker/Card/WorkerLocker.vue'), - }, - { - name: 'WorkerBalance', - path: 'balance', - meta: { - title: 'balance', - icon: 'balance', - }, - component: () => import('src/pages/Worker/Card/WorkerBalance.vue'), - }, - { - name: 'WorkerFormation', - path: 'formation', - meta: { - title: 'formation', - icon: 'clinical_notes', - }, - component: () => import('src/pages/Worker/Card/WorkerFormation.vue'), - }, - { - name: 'WorkerMedical', - path: 'medical', - meta: { - title: 'medical', - icon: 'medical_information', - }, - component: () => import('src/pages/Worker/Card/WorkerMedical.vue'), - }, - { - name: 'WorkerPit', - path: 'pit', - meta: { - title: 'pit', - icon: 'lock', - }, - component: () => import('src/pages/Worker/Card/WorkerPit.vue'), - }, - { - name: 'WorkerOperator', - path: 'operator', - meta: { - title: 'operator', - icon: 'person', - }, - component: () => import('src/pages/Worker/Card/WorkerOperator.vue'), + path: 'department', + name: 'Department', + redirect: { name: 'WorkerDepartment' }, + component: () => import('src/pages/Worker/WorkerDepartment.vue'), + children: [ + { + name: 'WorkerDepartment', + path: 'list', + meta: { title: 'department', icon: 'vn:greuge' }, + }, + departmentCard, + ], }, ], }, diff --git a/src/router/routes.js b/src/router/routes.js index b9120f8c4..d84ba7e46 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -9,7 +9,6 @@ import invoiceIn from './modules/invoiceIn'; import wagon from './modules/wagon'; import supplier from './modules/supplier'; import travel from './modules/travel'; -import department from './modules/department'; import ItemType from './modules/itemType'; import shelving from 'src/router/modules/shelving'; import order from 'src/router/modules/order'; @@ -85,7 +84,6 @@ const routes = [ route, supplier, travel, - department, roadmap, entry, parking, diff --git a/src/stores/invoiceOutGlobal.js b/src/stores/invoiceOutGlobal.js index cc8d86ea8..d8e061f84 100644 --- a/src/stores/invoiceOutGlobal.js +++ b/src/stores/invoiceOutGlobal.js @@ -7,10 +7,16 @@ import useNotify from 'src/composables/useNotify.js'; import axios from 'axios'; const { notify } = useNotify(); - +const initInvoicing = { + invoicing: false, + nRequests: 0, + nPdfs: 0, + totalPdfs: 0, + addressIndex: 0, + errors: [], +}; export const useInvoiceOutGlobalStore = defineStore({ id: 'invoiceOutGlobal', - state: () => ({ initialDataLoading: true, formInitialData: { @@ -24,15 +30,11 @@ export const useInvoiceOutGlobalStore = defineStore({ addresses: [], minInvoicingDate: null, parallelism: null, - invoicing: false, - isInvoicing: false, status: null, - addressIndex: 0, - errors: [], + printer: null, - nRequests: 0, - nPdfs: 0, - totalPdfs: 0, + formData: null, + ...initInvoicing, }), actions: { async init() { @@ -93,8 +95,6 @@ export const useInvoiceOutGlobalStore = defineStore({ }, async makeInvoice(formData, clientsToInvoice) { - this.invoicing = true; - const promises = []; try { this.printer = formData.printer; const params = { @@ -119,11 +119,13 @@ export const useInvoiceOutGlobalStore = defineStore({ ); throw new Error("There aren't addresses to invoice"); } + this.formData = formData; this.status = 'invoicing'; - for (let index = 0; index < this.parallelism; index++) { - promises.push(this.invoiceClient(formData, index)); + //reset data + for (const key in initInvoicing) { + this[key] = initInvoicing[key]; } - await Promise.all(promises); + this.invoiceClient(); } catch (err) { this.handleError(err); } @@ -182,45 +184,43 @@ export const useInvoiceOutGlobalStore = defineStore({ } }, - async invoiceClient(formData, index) { - const address = this.addresses[index]; + async invoiceClient() { + if (this.invoicing || this.nRequests >= this.parallelism) return; + const address = this.addresses[this.addressIndex]; if (!address || !this.status || this.status == 'stopping') { this.status = 'stopping'; this.invoicing = false; return; } try { + this.invoicing = true; + this.nRequests++; const params = { clientId: address.clientId, addressId: address.id, - invoiceDate: new Date(formData.invoiceDate), - maxShipped: new Date(formData.maxShipped), - companyFk: formData.companyFk, - serialType: formData.serialType, + invoiceDate: new Date(this.formData.invoiceDate), + maxShipped: new Date(this.formData.maxShipped), + companyFk: this.formData.companyFk, + serialType: this.formData.serialType, }; - this.invoicing = true; - const { data } = await axios.post('InvoiceOuts/invoiceClient', params); - - if (data) await this.makePdfAndNotify(data, address); - this.isInvoicing = false; + if (data) this.makePdfAndNotify(data, address); } catch (err) { if (err?.response?.status >= 400 && err?.response?.status < 500) { this.invoiceClientError(address, err.response?.data?.error?.message); return; } else { - this.invoicing = false; notify( 'invoiceOut.globalInvoices.errors.criticalInvoiceError', 'negative' ); - throw new Error('Critical invoicing error, process stopped'); } } finally { + this.invoicing = false; + this.nRequests--; this.addressIndex++; - if (this.status != 'stopping') - await this.invoiceClient(formData, this.addressIndex); + this.invoiceClient(); } }, @@ -231,9 +231,11 @@ export const useInvoiceOutGlobalStore = defineStore({ const params = { printerFk: this.printer }; await axios.post(`InvoiceOuts/${invoiceId}/makePdfAndNotify`, params); this.nPdfs++; - this.nRequests--; } catch (err) { this.invoiceClientError(client, err.response?.data?.error?.message, true); + } finally { + this.nRequests--; + this.invoiceClient(); } }, diff --git a/src/stores/useArrayDataStore.js b/src/stores/useArrayDataStore.js index e0d8b7929..8d62fdb4a 100644 --- a/src/stores/useArrayDataStore.js +++ b/src/stores/useArrayDataStore.js @@ -18,6 +18,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => { navigate: null, page: 1, mapKey: 'id', + keepData: false, }; function get(key) { diff --git a/test/cypress/.gitignore b/test/cypress/.gitignore index 8d940320e..c9793a5f2 100644 --- a/test/cypress/.gitignore +++ b/test/cypress/.gitignore @@ -1,2 +1,3 @@ reports/* screenshots/* +downloads/* \ No newline at end of file diff --git a/test/cypress/integration/Order/orderCatalog.spec.js b/test/cypress/integration/Order/orderCatalog.spec.js index 45eda6f1f..cffc47f91 100644 --- a/test/cypress/integration/Order/orderCatalog.spec.js +++ b/test/cypress/integration/Order/orderCatalog.spec.js @@ -11,21 +11,6 @@ describe('OrderCatalog', () => { cy.dataCy('catalogFilterCustomTag').contains(filterName); }; - const checkFilterTag = (filterName = 'Plant') => { - cy.dataCy('vnFilterPanelChip').should('exist'); - cy.dataCy('vnFilterPanelChip').contains(filterName); - }; - - const selectCategory = (categoryIndex = 1, categoryName = 'Plant') => { - cy.get( - `div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']` - ).should('exist'); - cy.get( - `div.q-page-container div:nth-of-type(${categoryIndex}) > [data-cy='catalogFilterCategory']` - ).click(); - checkCustomFilterTag(categoryName); - }; - const searchByCustomTagInput = (option) => { cy.dataCy('catalogFilterValueInput').find('input').last().focus(); cy.dataCy('catalogFilterValueInput').find('input').last().type(option); @@ -33,31 +18,19 @@ describe('OrderCatalog', () => { checkCustomFilterTag(option); }; - const selectTypeFilter = (option) => { - cy.selectOption( - 'div.q-page-container div.list > div:nth-of-type(2) div:nth-of-type(3)', - option - ); - checkFilterTag(option); - }; - it('Shows empty state', () => { cy.dataCy('orderCatalogPage').should('exist'); cy.dataCy('orderCatalogPage').contains('No data to display'); }); - it('filter by category', () => { - selectCategory(); + it('filter by category and type', () => { + cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click(); + cy.selectOption('[data-cy="catalogFilterType"]', 'Anthurium'); cy.dataCy('orderCatalogItem').should('exist'); }); - it('filters by type', () => { - selectCategory(); - selectTypeFilter('Anthurium'); - }); - it('filters by custom value select', () => { - selectCategory(); + cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click(); searchByCustomTagInput('Silver'); }); @@ -67,10 +40,12 @@ describe('OrderCatalog', () => { return false; } }); - selectCategory(); - cy.dataCy('catalogFilterValueDialogBtn').should('exist'); + cy.get( + '[data-cy="vn-searchbar"] > .q-field > .q-field__inner > .q-field__control' + ).type('{enter}'); + cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click(); cy.dataCy('catalogFilterValueDialogBtn').last().click(); - cy.dataCy('catalogFilterValueDialogTagSelect').should('exist'); + cy.get('[data-cy="catalogFilterValueDialogTagSelect"]').click(); cy.selectOption("[data-cy='catalogFilterValueDialogTagSelect']", 'Tallos'); cy.dataCy('catalogFilterValueDialogValueInput').find('input').focus(); cy.dataCy('catalogFilterValueDialogValueInput').find('input').type('2'); @@ -79,34 +54,16 @@ describe('OrderCatalog', () => { }); it('removes a secondary tag', () => { - selectCategory(); - selectTypeFilter('Anthurium'); + cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click(); + cy.selectOption('[data-cy="catalogFilterType"]', 'Anthurium'); cy.dataCy('vnFilterPanelChip').should('exist'); - cy.get( - "div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove" - ) - .contains('cancel') - .should('exist'); - cy.get( - "div.q-page-container [data-cy='vnFilterPanelChip'] > i.q-chip__icon--remove" - ) - .contains('cancel') - .click(); + cy.get('[data-cy="catalogFilterCustomTag"] > .q-chip__icon--remove').click(); cy.dataCy('vnFilterPanelChip').should('not.exist'); }); it('Removes category tag', () => { - selectCategory(); - cy.get( - "div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove" - ) - .contains('cancel') - .should('exist'); - cy.get( - "div.q-page-container [data-cy='catalogFilterCustomTag'] > i.q-chip__icon--remove" - ) - .contains('cancel') - .click(); + cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click(); + cy.get('.q-chip__icon--remove').click(); cy.dataCy('catalogFilterCustomTag').should('not.exist'); }); }); diff --git a/test/cypress/integration/client/clientList.spec.js b/test/cypress/integration/client/clientList.spec.js index dcded63b0..d5723375b 100644 --- a/test/cypress/integration/client/clientList.spec.js +++ b/test/cypress/integration/client/clientList.spec.js @@ -15,7 +15,7 @@ describe('Client list', () => { }); }); - it('Client list create new client', () => { + it.skip('Client list create new client', () => { cy.addBtnClick(); const randomInt = Math.floor(Math.random() * 90) + 10; diff --git a/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js b/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js index a64f98c10..0eb873355 100644 --- a/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInCorrective.spec.js @@ -1,7 +1,7 @@ /// <reference types="cypress" /> describe('InvoiceInCorrective', () => { - const createRectificative = '.q-menu > .q-list > :nth-child(6) > .q-item__section'; + const createCorrective = '.q-menu > .q-list > :nth-child(6) > .q-item__section'; const rectificativeSection = '.q-drawer-container .q-list > a:nth-child(6)'; const saveDialog = '.q-card > .q-card__actions > .q-btn--standard '; @@ -13,7 +13,7 @@ describe('InvoiceInCorrective', () => { cy.openActionsDescriptor(); - cy.get(createRectificative).click(); + cy.get(createCorrective).click(); cy.get(saveDialog).click(); cy.wait('@corrective').then((interception) => { const correctingId = interception.response.body; diff --git a/test/cypress/integration/invoiceOut/invoiceOutList.spec.js b/test/cypress/integration/invoiceOut/invoiceOutList.spec.js new file mode 100644 index 000000000..30cc8e497 --- /dev/null +++ b/test/cypress/integration/invoiceOut/invoiceOutList.spec.js @@ -0,0 +1,46 @@ +/// <reference types="cypress" /> +describe('InvoiceOut list', () => { + const invoice = { + Ticket: { val: '8' }, + Serial: { val: 'Española rapida', type: 'select' }, + }; + const invoiceError = { + Ticket: { val: '1' }, + Serial: { val: 'Española rapida', type: 'select' }, + }; + + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/invoice-out/list`); + cy.typeSearchbar('{enter}'); + }); + + it('should search and filter an invoice and enter to the summary', () => { + cy.typeSearchbar('1{enter}'); + cy.get('.q-virtual-scroll__content > :nth-child(2) > :nth-child(7)').click(); + cy.get('.header > a.q-btn > .q-btn__content').click(); + cy.typeSearchbar('{enter}'); + cy.dataCy('InvoiceOutFilterAmountBtn').find('input').type('8.88{enter}'); + }); + + it('should download all pdfs', () => { + cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click(); + cy.dataCy('InvoiceOutDownloadPdfBtn').click(); + cy.get('.bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner').click(); + }); + + it('should give an error when manual invoicing a ticket that is already invoiced', () => { + cy.dataCy('vnTableCreateBtn').click(); + cy.fillInForm(invoiceError); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('This ticket is already invoiced'); + }); + + it('should create a manual invoice and enter to its summary', () => { + cy.dataCy('vnTableCreateBtn').click(); + cy.fillInForm(invoice); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + }); +}); diff --git a/test/cypress/integration/invoiceOut/invoiceOutMakeInvoice.spec.js b/test/cypress/integration/invoiceOut/invoiceOutMakeInvoice.spec.js new file mode 100644 index 000000000..145f492a1 --- /dev/null +++ b/test/cypress/integration/invoiceOut/invoiceOutMakeInvoice.spec.js @@ -0,0 +1,21 @@ +/// <reference types="cypress" /> +describe('InvoiceOut manual invoice', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/ticket/list`); + cy.get('#searchbar input').type('{enter}'); + }); + + it('should create an invoice from a ticket and go to that invoice', () => { + cy.searchByLabel('Customer ID', '1101'); + cy.get( + '[data-q-vs-anchor=""] > :nth-child(1) > .q-checkbox > .q-checkbox__inner' + ).click(); + cy.dataCy('ticketListMakeInvoiceBtn').click(); + cy.checkNotification('Data saved'); + cy.get('.q-virtual-scroll__content > :nth-child(1) > :nth-child(3)').click(); + cy.get(':nth-child(8) > .value > .link').click(); + cy.get('.header > :nth-child(3) > .q-btn__content').click(); + }); +}); diff --git a/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js b/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js new file mode 100644 index 000000000..5f629df0b --- /dev/null +++ b/test/cypress/integration/invoiceOut/invoiceOutNegativeBases.spec.js @@ -0,0 +1,16 @@ +/// <reference types="cypress" /> +describe('InvoiceOut negative bases', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/invoice-out/negative-bases`); + }); + + it('should filter and download as CSV', () => { + cy.get( + ':nth-child(7) > .full-width > :nth-child(1) > .column > div.q-px-xs > .q-field > .q-field__inner > .q-field__control' + ).type('23{enter}'); + cy.get('#subToolbar > .q-btn').click(); + cy.checkNotification('CSV downloaded successfully'); + }); +}); diff --git a/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js b/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js new file mode 100644 index 000000000..b7fd11307 --- /dev/null +++ b/test/cypress/integration/invoiceOut/invoiceOutSummary.spec.js @@ -0,0 +1,47 @@ +/// <reference types="cypress" /> +describe('InvoiceOut summary', () => { + const transferInvoice = { + Client: { val: 'employee', type: 'select' }, + Type: { val: 'Error in customer data', type: 'select' }, + }; + + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/invoice-out/list`); + cy.typeSearchbar('{enter}'); + }); + + it('should generate the invoice PDF', () => { + cy.typeSearchbar('T1111111{enter}'); + cy.dataCy('descriptor-more-opts').click(); + cy.get('.q-menu > .q-list > :nth-child(6)').click(); + cy.dataCy('VnConfirm_confirm').click(); + cy.checkNotification('The invoice PDF document has been regenerated'); + }); + + it('should refund the invoice ', () => { + cy.typeSearchbar('T1111111{enter}'); + cy.dataCy('descriptor-more-opts').click(); + cy.get('.q-menu > .q-list > :nth-child(7)').click(); + cy.get('#q-portal--menu--3 > .q-menu > .q-list > :nth-child(2)').click(); + cy.checkNotification('The following refund ticket have been created 1000000'); + }); + + it('should delete an invoice ', () => { + cy.typeSearchbar('T2222222{enter}'); + cy.dataCy('descriptor-more-opts').click(); + cy.get('.q-menu > .q-list > :nth-child(4)').click(); + cy.dataCy('VnConfirm_confirm').click(); + cy.checkNotification('InvoiceOut deleted'); + }); + + it('should transfer the invoice ', () => { + cy.typeSearchbar('T1111111{enter}'); + cy.dataCy('descriptor-more-opts').click(); + cy.get('.q-menu > .q-list > :nth-child(1)').click(); + cy.fillInForm(transferInvoice); + cy.get('.q-mt-lg > .q-btn').click(); + cy.checkNotification('Transferred invoice'); + }); +}); diff --git a/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js b/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js new file mode 100644 index 000000000..06e132b39 --- /dev/null +++ b/test/cypress/integration/invoiceOut/invvoiceOutGlobal.spec.js @@ -0,0 +1,28 @@ +/// <reference types="cypress" /> +describe('InvoiceOut global invoicing', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('administrative'); + cy.visit(`/#/invoice-out/global-invoicing`); + }); + + it('should invoice the client tickets', () => { + cy.get('.q-mb-sm > .q-radio__inner').click(); + cy.dataCy('InvoiceOutGlobalClientSelect').type('1102'); + cy.get('.q-menu .q-item').contains('1102').click(); + cy.dataCy('InvoiceOutGlobalSerialSelect').click(); + cy.get('.q-menu .q-item').contains('global').click(); + cy.dataCy('InvoiceOutGlobalCompanySelect').type('VNL'); + cy.get('.q-menu .q-item').contains('VNL').click(); + cy.dataCy('InvoiceOutGlobalPrinterSelect').type('printer1'); + cy.get('.q-menu .q-item').contains('printer1').click(); + cy.get( + '[label="Invoice date"] > .q-field > .q-field__inner > .q-field__control' + ).click(); + cy.get(':nth-child(5) > div > .q-btn > .q-btn__content > .block').click(); + cy.get('.q-date__years-content > :nth-child(2) > .q-btn').click(); + cy.get('.q-date__calendar-days > :nth-child(6) > .q-btn').click(); + cy.get('[label="Max date ticket"]').type('01-01-2001{enter}'); + cy.get('.q-card').should('be.visible'); + }); +}); diff --git a/test/cypress/integration/item/ItemFixedPrice.spec.js b/test/cypress/integration/item/ItemFixedPrice.spec.js index 92dc27fda..edb6a63fe 100644 --- a/test/cypress/integration/item/ItemFixedPrice.spec.js +++ b/test/cypress/integration/item/ItemFixedPrice.spec.js @@ -14,7 +14,7 @@ describe('Handle Items FixedPrice', () => { '.q-header > .q-toolbar > :nth-child(1) > .q-btn__content > .q-icon' ).click(); }); - it('filter', function () { + it.skip('filter', function () { cy.get('.category-filter > :nth-child(1) > .q-btn__content > .q-icon').click(); cy.selectOption('.list > :nth-child(2)', 'Alstroemeria'); cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click(); @@ -27,7 +27,7 @@ describe('Handle Items FixedPrice', () => { cy.get('.q-notification__message').should('have.text', 'Data saved'); /* ==== End Cypress Studio ==== */ }); - it('Create and delete ', function () { + it.skip('Create and delete ', function () { cy.get('.q-gutter-x-sm > .q-btn > .q-btn__content > .q-icon').click(); cy.addBtnClick(); cy.selectOption(`${firstRow} > :nth-child(2)`, '#11'); @@ -43,7 +43,7 @@ describe('Handle Items FixedPrice', () => { cy.get('.q-notification__message').should('have.text', 'Data saved'); }); - it('Massive edit', function () { + it.skip('Massive edit', function () { cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click(); cy.get('#subToolbar > .q-btn--standard').click(); cy.selectOption("[data-cy='field-to-edit']", 'Min price'); @@ -52,7 +52,7 @@ describe('Handle Items FixedPrice', () => { cy.get('.q-mt-lg > .q-btn--standard').click(); cy.get('.q-notification__message').should('have.text', 'Data saved'); }); - it('Massive remove', function () { + it.skip('Massive remove', function () { cy.get(' .bg-header > :nth-child(1) > .q-checkbox > .q-checkbox__inner ').click(); cy.get('#subToolbar > .q-btn--flat').click(); cy.get( diff --git a/test/cypress/integration/item/itemBarcodes.spec.js b/test/cypress/integration/item/itemBarcodes.spec.js new file mode 100644 index 000000000..4d17fa260 --- /dev/null +++ b/test/cypress/integration/item/itemBarcodes.spec.js @@ -0,0 +1,25 @@ +/// <reference types="cypress" /> +describe('Item shelving', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/list`); + cy.typeSearchbar('1{enter}'); + }); + + it('should throw an error if the barcode exists', () => { + cy.get('[href="#/item/1/barcode"]').click(); + cy.get('.q-card > .q-btn > .q-btn__content > .q-icon').click(); + cy.dataCy('Code_input').eq(3).type('1111111111'); + cy.dataCy('crudModelDefaultSaveBtn').click(); + cy.checkNotification('Codes can not be repeated'); + }); + + it('should create a new barcode', () => { + cy.get('[href="#/item/1/barcode"]').click(); + cy.get('.q-card > .q-btn > .q-btn__content > .q-icon').click(); + cy.dataCy('Code_input').eq(3).type('1231231231'); + cy.dataCy('crudModelDefaultSaveBtn').click(); + cy.checkNotification('Data saved'); + }); +}); diff --git a/test/cypress/integration/item/itemBotanical.spec.js b/test/cypress/integration/item/itemBotanical.spec.js new file mode 100644 index 000000000..08886d9a8 --- /dev/null +++ b/test/cypress/integration/item/itemBotanical.spec.js @@ -0,0 +1,31 @@ +/// <reference types="cypress" /> +describe('Item botanical', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/1/botanical`); + }); + + it('should modify the botanical', () => { + cy.dataCy('AddGenusSelectDialog').type('Abies'); + cy.get('.q-menu .q-item').contains('Abies').click(); + cy.dataCy('AddSpeciesSelectDialog').type('dealbata'); + cy.get('.q-menu .q-item').contains('dealbata').click(); + cy.get('.q-btn-group > .q-btn--standard').click(); + cy.checkNotification('Data saved'); + }); + + it('should create a new Genus', () => { + cy.dataCy('Genus_icon').click(); + cy.dataCy('Latin genus name_input').type('Test'); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + }); + + it('should create a new specie', () => { + cy.dataCy('Species_icon').click(); + cy.dataCy('Latin species name_input').type('Test specie'); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + }); +}); diff --git a/test/cypress/integration/item/itemLastEntries.spec.js b/test/cypress/integration/item/itemLastEntries.spec.js deleted file mode 100644 index c94cfa480..000000000 --- a/test/cypress/integration/item/itemLastEntries.spec.js +++ /dev/null @@ -1,20 +0,0 @@ -describe('ItemLastEntries', () => { - beforeEach(() => { - cy.viewport(1280, 720); - cy.login('buyer'); - cy.visit('/#/item/1/last-entries'); - cy.intercept('GET', /.*lastEntriesFilter/).as('item'); - cy.waitForElement('tbody'); - }); - - it('should filter by agency', () => { - cy.get('tbody > tr') - .its('length') - .then((rowCount) => { - cy.get('[data-cy="hideInventory"]').click(); - cy.wait('@item'); - cy.waitForElement('tbody'); - cy.get('tbody > tr').should('have.length.greaterThan', rowCount); - }); - }); -}); diff --git a/test/cypress/integration/item/itemList.spec.js b/test/cypress/integration/item/itemList.spec.js new file mode 100644 index 000000000..49e393451 --- /dev/null +++ b/test/cypress/integration/item/itemList.spec.js @@ -0,0 +1,34 @@ +/// <reference types="cypress" /> + +describe('Item list', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/list`); + cy.typeSearchbar('{enter}'); + }); + + it('should filter the items and redirect to the summary', () => { + cy.dataCy('Category_select').type('Plant'); + cy.get('.q-menu .q-item').contains('Plant').click(); + cy.dataCy('Type_select').type('Anthurium'); + cy.get('.q-menu .q-item').contains('Anthurium').click(); + cy.get('.q-virtual-scroll__content > :nth-child(4) > :nth-child(4)').click(); + }); + + it('should create an item', () => { + const data = { + Description: { val: `Test item` }, + Type: { val: `Crisantemo`, type: 'select' }, + Intrastat: { val: `Coral y materiales similares`, type: 'select' }, + Origin: { val: `SPA`, type: 'select' }, + }; + cy.dataCy('vnTableCreateBtn').click(); + cy.fillInForm(data); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + cy.get( + ':nth-child(2) > .q-drawer > .q-drawer__content > .q-scrollarea > .q-scrollarea__container > .q-scrollarea__content' + ).should('be.visible'); + }); +}); diff --git a/test/cypress/integration/item/itemSummary.spec.js b/test/cypress/integration/item/itemSummary.spec.js new file mode 100644 index 000000000..ad8267ecf --- /dev/null +++ b/test/cypress/integration/item/itemSummary.spec.js @@ -0,0 +1,24 @@ +/// <reference types="cypress" /> +describe('Item summary', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/1/summary`); + }); + + it('should clone the item', () => { + cy.dataCy('descriptor-more-opts').click(); + cy.get('.q-menu > .q-list > :nth-child(2) > .q-item__section').click(); + cy.dataCy('VnConfirm_confirm').click(); + cy.waitForElement('[data-cy="itemTags"]'); + cy.dataCy('itemTags').should('be.visible'); + }); + + it('should regularize stock', () => { + cy.dataCy('descriptor-more-opts').click(); + cy.get('.q-menu > .q-list > :nth-child(1) > .q-item__section').click(); + cy.dataCy('regularizeStockInput').type('10'); + cy.dataCy('Warehouse_select').type('Warehouse One{enter}'); + cy.checkNotification('Data created'); + }); +}); diff --git a/test/cypress/integration/item/itemTag.spec.js b/test/cypress/integration/item/itemTag.spec.js new file mode 100644 index 000000000..c2de93068 --- /dev/null +++ b/test/cypress/integration/item/itemTag.spec.js @@ -0,0 +1,39 @@ +/// <reference types="cypress" /> +describe('Item tag', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/1/tags`); + }); + + it('should throw an error adding an existent tag', () => { + cy.get('.q-page').should('be.visible'); + cy.get('.q-page-sticky > div').click(); + cy.get('.q-page-sticky > div').click(); + cy.dataCy('Tag_select').eq(7).type('Tallos'); + cy.get('.q-menu .q-item').contains('Tallos').click(); + cy.get( + ':nth-child(8) > [label="Value"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Value_input"]' + ).type('1'); + +cy.dataCy('crudModelDefaultSaveBtn').click(); + cy.checkNotification("The tag or priority can't be repeated for an item"); + }); + + it('should add a new tag', () => { + cy.get('.q-page').should('be.visible'); + cy.get('.q-page-sticky > div').click(); + cy.get('.q-page-sticky > div').click(); + cy.dataCy('Tag_select').eq(7).click(); + cy.get('.q-menu .q-item').contains('Ancho de la base').click(); + cy.get( + ':nth-child(8) > [label="Value"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Value_input"]' + ).type('50'); + cy.dataCy('crudModelDefaultSaveBtn').click(); + cy.checkNotification('Data saved'); + cy.get( + '[data-cy="itemTags"] > :nth-child(7) > .justify-center > .q-icon' + ).click(); + cy.dataCy('VnConfirm_confirm').click(); + cy.checkNotification('Data saved'); + }); +}); diff --git a/test/cypress/integration/item/itemTax.spec.js b/test/cypress/integration/item/itemTax.spec.js new file mode 100644 index 000000000..6ff147135 --- /dev/null +++ b/test/cypress/integration/item/itemTax.spec.js @@ -0,0 +1,14 @@ +/// <reference types="cypress" /> +describe('Item tax', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/1/tax`); + }); + + it('should modify the tax for Spain', () => { + cy.dataCy('Class_select').eq(1).type('General VAT{enter}'); + cy.dataCy('crudModelDefaultSaveBtn').click(); + cy.checkNotification('Data saved'); + }); +}); diff --git a/test/cypress/integration/item/itemType.spec.js b/test/cypress/integration/item/itemType.spec.js new file mode 100644 index 000000000..b0a7b0ca9 --- /dev/null +++ b/test/cypress/integration/item/itemType.spec.js @@ -0,0 +1,40 @@ +/// <reference types="cypress" /> +describe('Item type', () => { + beforeEach(() => { + cy.viewport(1920, 1080); + cy.login('developer'); + cy.visit(`/#/item/item-type`); + }); + + it('should throw an error if the code already exists', () => { + cy.dataCy('vnTableCreateBtn').click(); + cy.get( + 'div.fit > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Code_input"]' + ).type('ALS'); + cy.get( + 'div.fit > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Name_input"]' + ).type('Alstroemeria'); + cy.dataCy('Worker_select').type('employeeNick'); + cy.get('.q-menu .q-item').contains('employeeNick').click(); + cy.dataCy('ItemCategory_select').type('Artificial'); + cy.get('.q-menu .q-item').contains('Artificial').click(); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('An item type with the same code already exists'); + }); + + it('should create a new type', () => { + cy.dataCy('vnTableCreateBtn').click(); + cy.get( + 'div.fit > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Code_input"]' + ).type('LIL'); + cy.get( + 'div.fit > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Name_input"]' + ).type('Lilium'); + cy.dataCy('Worker_select').type('buyerNick'); + cy.get('.q-menu .q-item').contains('buyerNick').click(); + cy.dataCy('ItemCategory_select').type('Flower'); + cy.get('.q-menu .q-item').contains('Flower').click(); + cy.dataCy('FormModelPopup_save').click(); + cy.checkNotification('Data created'); + }); +}); diff --git a/test/cypress/integration/outLogin/login.spec.js b/test/cypress/integration/outLogin/login.spec.js index 3db223cdb..2bd5a8c3b 100755 --- a/test/cypress/integration/outLogin/login.spec.js +++ b/test/cypress/integration/outLogin/login.spec.js @@ -19,6 +19,7 @@ describe('Login', () => { it('should fail to log in using wrong password', () => { cy.get('input[aria-label="Username"]').type('employee'); cy.get('input[aria-label="Password"]').type('wrongPassword'); + cy.get('.q-field__append > .q-icon'); cy.get('button[type="submit"]').click(); cy.get('.q-notification__message').should( 'have.text', diff --git a/test/cypress/integration/ticket/ticketExpedition.spec.js b/test/cypress/integration/ticket/ticketExpedition.spec.js index d4afd401f..d74a122a1 100644 --- a/test/cypress/integration/ticket/ticketExpedition.spec.js +++ b/test/cypress/integration/ticket/ticketExpedition.spec.js @@ -16,7 +16,9 @@ describe('Ticket expedtion', () => { cy.wait('@show'); cy.selectRows([1, 2]); - cy.selectOption('[data-cy="change-state"]', 'Perdida'); + + cy.dataCy('change-state').click(); + cy.selectOption('[data-cy="vnBtnSelect_select"]', 'Perdida'); cy.wait('@add'); cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => { diff --git a/test/cypress/integration/ticket/ticketList.spec.js b/test/cypress/integration/ticket/ticketList.spec.js index b30b4cdad..e273825c0 100644 --- a/test/cypress/integration/ticket/ticketList.spec.js +++ b/test/cypress/integration/ticket/ticketList.spec.js @@ -9,9 +9,9 @@ describe('TicketList', () => { }); const searchResults = (search) => { - cy.dataCy('vnSearchBar').find('input').focus(); - if (search) cy.dataCy('vnSearchBar').find('input').type(search); - cy.dataCy('vnSearchBar').find('input').type('{enter}'); + cy.dataCy('vn-searchbar').find('input').focus(); + if (search) cy.dataCy('vn-searchbar').find('input').type(search); + cy.dataCy('vn-searchbar').find('input').type('{enter}'); cy.dataCy('ticketListTable').should('exist'); cy.get(firstRow).should('exist'); }; @@ -37,7 +37,7 @@ describe('TicketList', () => { cy.dataCy('ticketSummary').should('exist'); }); - it('Client list create new client', () => { + it.skip('Client list create new client', () => { cy.dataCy('vnTableCreateBtn').should('exist'); cy.dataCy('vnTableCreateBtn').click(); const data = { diff --git a/test/cypress/integration/ticket/ticketRequest.spec.js b/test/cypress/integration/ticket/ticketRequest.spec.js index b9dc509ef..5a0ae636f 100644 --- a/test/cypress/integration/ticket/ticketRequest.spec.js +++ b/test/cypress/integration/ticket/ticketRequest.spec.js @@ -6,7 +6,7 @@ describe('TicketRequest', () => { cy.visit('/#/ticket/31/request'); }); - it('Creates a new request', () => { + it.skip('Creates a new request', () => { cy.dataCy('vnTableCreateBtn').should('exist'); cy.dataCy('vnTableCreateBtn').click(); const data = { diff --git a/test/cypress/integration/ticket/ticketSale.spec.js b/test/cypress/integration/ticket/ticketSale.spec.js index 60f31dbf6..7bc53f010 100644 --- a/test/cypress/integration/ticket/ticketSale.spec.js +++ b/test/cypress/integration/ticket/ticketSale.spec.js @@ -66,7 +66,7 @@ describe('TicketSale', () => { cy.dataCy('ticketSaleMoreActionsDropdown').click(); cy.dataCy('createClaimItem').click(); cy.dataCy('VnConfirm_confirm').click(); - cy.url().should('match', /\/claim\/\d+\/basic-data/); + cy.url().should('contain', 'claim/'); // Delete created claim to avoid cluttering the database cy.dataCy('descriptor-more-opts').click(); cy.dataCy('deleteClaim').click(); @@ -106,22 +106,15 @@ describe('TicketSale', () => { cy.checkNotification('The following refund ticket have been created'); }); - it('transfers ticket', () => { + it('transfer sale to a new ticket', () => { cy.visit('/#/ticket/32/sale'); + cy.get('.q-item > .q-item__label').should('have.text', ' #32'); selectFirstRow(); cy.dataCy('ticketSaleTransferBtn').click(); cy.dataCy('ticketTransferPopup').should('exist'); cy.dataCy('ticketTransferNewTicketBtn').click(); - // existen 3 elementos "tbody" necesito checkear que el segundo elemento tbody tenga una row sola - cy.get('tbody').eq(1).find('tr').should('have.length', 1); - selectFirstRow(); - cy.dataCy('ticketSaleTransferBtn').click(); - cy.dataCy('ticketTransferPopup').should('exist'); - cy.dataCy('ticketTransferDestinationTicketInput').find('input').focus(); - cy.dataCy('ticketTransferDestinationTicketInput').find('input').type('32'); - cy.dataCy('ticketTransferTransferBtn').click(); - // checkear que la url contenga /ticket/1000002/sale - cy.url().should('match', /\/ticket\/32\/sale/); + //check the new ticket has been created succesfully + cy.get('.q-item > .q-item__label').should('not.have.text', ' #32'); }); it('should redirect to ticket logs', () => { diff --git a/test/cypress/integration/vnComponent/VnLocation.spec.js b/test/cypress/integration/vnComponent/VnLocation.spec.js index 82d12a1e4..14eb0f978 100644 --- a/test/cypress/integration/vnComponent/VnLocation.spec.js +++ b/test/cypress/integration/vnComponent/VnLocation.spec.js @@ -38,10 +38,7 @@ describe('VnLocation', () => { const province = 'Province five'; cy.selectOption(countrySelector, country); - cy.selectOption( - `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, - province - ); + cy.dataCy('locationProvince').type(`${province}{enter}`); cy.get( `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) ` ).click(); @@ -134,13 +131,9 @@ describe('VnLocation', () => { it('Create city with country', () => { const cityName = 'Saskatchew'.concat(Math.random(1 * 100)); cy.get(createLocationButton).click(); - cy.selectOption( - `${createForm.prefix} > :nth-child(5) > :nth-child(3) `, - 'Italia' - ); + cy.dataCy('locationCountry').type('Italia{enter}'); cy.dataCy('City_icon').click(); cy.selectOption('[data-cy="locationProvince"]:last', 'Province four'); - cy.countSelectOptions('[data-cy="locationProvince"]:last', 1); cy.dataCy('cityName').type(cityName); cy.dataCy('FormModelPopup_save').eq(1).click(); diff --git a/test/cypress/integration/vnComponent/VnLog.spec.js b/test/cypress/integration/vnComponent/VnLog.spec.js index 80b9d07df..10917859a 100644 --- a/test/cypress/integration/vnComponent/VnLog.spec.js +++ b/test/cypress/integration/vnComponent/VnLog.spec.js @@ -10,14 +10,14 @@ describe('VnLog', () => { cy.openRightMenu(); }); - it('should filter by insert actions', () => { + it.skip('should filter by insert actions', () => { cy.checkOption(':nth-child(7) > .q-checkbox'); cy.get('.q-page').click(); cy.validateContent(chips[0], 'Document'); cy.validateContent(chips[1], 'Beginning'); }); - it('should filter by entity', () => { + it.skip('should filter by entity', () => { cy.selectOption('.q-drawer--right .q-item > .q-select', 'Claim'); cy.get('.q-page').click(); cy.validateContent(chips[0], 'Claim'); diff --git a/test/cypress/integration/vnComponent/VnSearchBar.spec.js b/test/cypress/integration/vnComponent/VnSearchBar.spec.js index 885e5d6b3..c710d5192 100644 --- a/test/cypress/integration/vnComponent/VnSearchBar.spec.js +++ b/test/cypress/integration/vnComponent/VnSearchBar.spec.js @@ -16,17 +16,20 @@ describe('VnSearchBar', () => { }); it('should stay on the list page if there are several results or none', () => { - cy.writeSearchbar('salesA{enter}'); + cy.typeSearchbar('salesA{enter}'); + cy.typeSearchbar('salesA{enter}'); checkTableLength(2); cy.clearSearchbar(); - cy.writeSearchbar('0{enter}'); + + cy.typeSearchbar('0{enter}'); checkTableLength(0); }); const searchAndCheck = (searchTerm, expectedText) => { cy.clearSearchbar(); - cy.writeSearchbar(`${searchTerm}{enter}`); + cy.typeSearchbar(`${searchTerm}{enter}`); + cy.typeSearchbar(`${searchTerm}{enter}`); cy.get(idGap).should('have.text', expectedText); }; diff --git a/test/cypress/integration/wagon/wagonCreate.spec.js b/test/cypress/integration/wagon/wagonCreate.spec.js index cd248d1bb..501375d8c 100644 --- a/test/cypress/integration/wagon/wagonCreate.spec.js +++ b/test/cypress/integration/wagon/wagonCreate.spec.js @@ -2,41 +2,22 @@ describe('WagonCreate', () => { beforeEach(() => { cy.viewport(1280, 720); cy.login('developer'); - cy.visit('/#/wagon/create'); + cy.visit('/#/wagon'); }); it('should create and delete a new wagon', () => { - cy.waitForElement('.q-card'); - cy.get('input').eq(0).type('1234'); - cy.get('input').eq(1).type('1234ABCD'); - cy.get('input').eq(2).type('100'); - cy.get('input').eq(3).click(); - cy.get('.q-select > .q-field__inner > .q-field__control').type( - '{downarrow}{enter}' - ); - - // Save - cy.get('button[type="submit"]').click(); - - // Check data has been saved successfully - cy.waitForElement('.q-card'); - + cy.dataCy('vnTableCreateBtn').click(); cy.get( - '[to="/null/1"] > .q-card > .no-padding > .q-py-none > .cursor-text' - ).should('have.text', '1234'); + '.grid-create > [label="Label"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Label_input"]' + ).type('1234'); cy.get( - '[to="/null/1"] > .q-card > .no-padding > .q-pr-lg > :nth-child(1) > .vn-label-value > .value > :nth-child(1) > .row > span' - ).should('have.text', '1234ABCD'); + '.grid-create > [label="Plate"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Plate_input"]' + ).type('1234ABCD'); cy.get( - '[to="/null/1"] > .q-card > .no-padding > .q-pr-lg > :nth-child(2) > .vn-label-value > .value > :nth-child(1) > .row > span' - ).should('have.text', '100'); - cy.get( - '[to="/null/1"] > .q-card > .no-padding > .q-pr-lg > :nth-child(3) > .vn-label-value > .value > :nth-child(1) > .row > span' - ).should('have.text', 'Wagon Type #1'); - - // Delete wagon type created - cy.get( - '[to="/null/2"] > .q-card > .column > [title="Remove"] > .q-btn__content > .q-icon' - ).click(); + '.grid-create > [label="Volume"] > .q-field > .q-field__inner > .q-field__control > .q-field__control-container > [data-cy="Volume_input"]' + ).type('100'); + cy.dataCy('Type_select').type('{downarrow}{enter}'); + // // Delete wagon type created + cy.get('[to="/null/1"] > .q-card > .column > [title="Remove"]').click(); }); }); diff --git a/test/cypress/integration/worker/workerCreate.spec.js b/test/cypress/integration/worker/workerCreate.spec.js index 50afe1892..7f2810395 100644 --- a/test/cypress/integration/worker/workerCreate.spec.js +++ b/test/cypress/integration/worker/workerCreate.spec.js @@ -1,6 +1,5 @@ describe('WorkerCreate', () => { const externalRadio = '.q-radio:nth-child(2)'; - const notification = '.q-notification__message'; const developerBossId = 120; const payMethodCross = '.grid-create .full-width > :nth-child(9) .q-select .q-field__append:not(.q-anchor--skip)'; @@ -41,7 +40,7 @@ describe('WorkerCreate', () => { cy.fillInForm(internal); cy.get(payMethodCross).click(); cy.get(saveBtn).click(); - cy.get(notification).should('contains.text', 'Payment method is required'); + cy.checkNotification('Payment method is required'); }); it('should create an internal', () => { @@ -50,13 +49,13 @@ describe('WorkerCreate', () => { 'Pay method': { val: 'PayMethod one', type: 'select' }, }); cy.get(saveBtn).click(); - cy.get(notification).should('contains.text', 'Data created'); + cy.checkNotification('Data created'); }); it('should create an external', () => { cy.get(externalRadio).click(); cy.fillInForm(external); cy.get(saveBtn).click(); - cy.get(notification).should('contains.text', 'Data created'); + cy.checkNotification('Data created'); }); }); diff --git a/test/cypress/integration/zone/zoneBasicData.spec.js b/test/cypress/integration/zone/zoneBasicData.spec.js index 6229039b7..95a075fb3 100644 --- a/test/cypress/integration/zone/zoneBasicData.spec.js +++ b/test/cypress/integration/zone/zoneBasicData.spec.js @@ -1,5 +1,4 @@ describe('ZoneBasicData', () => { - const notification = '.q-notification__message'; const priceBasicData = '[data-cy="Price_input"]'; beforeEach(() => { @@ -11,13 +10,13 @@ describe('ZoneBasicData', () => { it('should throw an error if the name is empty', () => { cy.get('[data-cy="zone-basic-data-name"] input').type('{selectall}{backspace}'); cy.get('.q-btn-group > .q-btn--standard').click(); - cy.get(notification).should('contains.text', "can't be blank"); + cy.checkNotification("can't be blank"); }); it('should throw an error if the price is empty', () => { cy.get(priceBasicData).clear(); cy.get('.q-btn-group > .q-btn--standard').click(); - cy.get(notification).should('contains.text', 'cannot be blank'); + cy.checkNotification('cannot be blank'); }); it("should edit the basicData's zone", () => { diff --git a/test/cypress/integration/zone/zoneCreate.spec.js b/test/cypress/integration/zone/zoneCreate.spec.js index cc5de8c6c..0f630db5d 100644 --- a/test/cypress/integration/zone/zoneCreate.spec.js +++ b/test/cypress/integration/zone/zoneCreate.spec.js @@ -1,6 +1,4 @@ describe('ZoneCreate', () => { - const notification = '.q-notification__message'; - const data = { Name: { val: 'Zone pickup D' }, Price: { val: '3' }, @@ -24,7 +22,7 @@ describe('ZoneCreate', () => { cy.get('input[aria-label="Close"]').type('10:00'); cy.get('body').click(); cy.get('.q-mt-lg > .q-btn--standard').click(); - cy.get(notification).should('contains.text', 'Agency cannot be blank'); + cy.checkNotification('Agency cannot be blank'); }); it('should create a zone', () => { @@ -35,6 +33,6 @@ describe('ZoneCreate', () => { cy.get('input[aria-label="Close"]').type('10:00'); cy.get('body').click(); cy.get('.q-mt-lg > .q-btn--standard').click(); - cy.get(notification).should('contains.text', 'Data created'); + cy.checkNotification('Data created'); }); }); diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index df2c00e03..93f6d0054 100755 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -101,7 +101,6 @@ Cypress.Commands.add('selectOption', (selector, option, timeout = 5000) => { .then(() => { cy.get('@dataUrl').then((url) => { if (url) { - cy.log('url: ', url); // Esperar a que el menú no esté visible (desaparezca) cy.get('.q-menu').should('not.be.visible'); // Ahora esperar a que el menú vuelva a aparecer @@ -125,7 +124,7 @@ Cypress.Commands.add('countSelectOptions', (selector, option) => { }); Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => { - cy.waitForElement('.q-form > .q-card'); + cy.waitForElement(form); cy.get(`${form} input`).each(([el]) => { cy.wrap(el) .invoke('attr', 'aria-label') @@ -275,15 +274,11 @@ Cypress.Commands.add('openLeftMenu', (element) => { Cypress.Commands.add('clearSearchbar', (element) => { if (element) cy.waitForElement(element); - cy.get( - '#searchbar > form > div:nth-child(1) > label > div:nth-child(1) input' - ).clear(); + cy.get('[data-cy="vn-searchbar"]').clear(); }); -Cypress.Commands.add('writeSearchbar', (value) => { - cy.get('#searchbar > form > div:nth-child(1) > label > div:nth-child(1) input').type( - value - ); +Cypress.Commands.add('typeSearchbar', (value) => { + cy.get('[data-cy="vn-searchbar"]').type(value); }); Cypress.Commands.add('validateContent', (selector, expectedValue) => { diff --git a/test/vitest/helper.js b/test/vitest/helper.js index ce057c7c3..1e693ab63 100644 --- a/test/vitest/helper.js +++ b/test/vitest/helper.js @@ -26,7 +26,7 @@ vi.mock('vue-router', () => ({ params: { id: 1, }, - meta: { moduleName: 'mockName' }, + meta: { moduleName: 'mockModuleName' }, matched: [{ path: 'mockName/list' }], }, }, @@ -35,7 +35,7 @@ vi.mock('vue-router', () => ({ matched: [], query: {}, params: {}, - meta: { moduleName: 'mockName' }, + meta: { moduleName: 'mockModuleName', title: 'mockTitle', name: 'mockName' }, path: 'mockSection/list', }), onBeforeRouteLeave: () => {}, -- 2.40.1