diff --git a/CHANGELOG.md b/CHANGELOG.md index e34523545..b72bc2c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- (Worker) => Se crea la sección Taquilla +- (General) => Se mantiene el filtro lateral en cualquier parte de la seccíon. + ### Fixed - (General) => Se vuelven a mostrar los parámetros en la url al aplicar un filtro diff --git a/quasar.config.js b/quasar.config.js index dd7a91002..b59c62eeb 100644 --- a/quasar.config.js +++ b/quasar.config.js @@ -29,7 +29,7 @@ module.exports = configure(function (/* ctx */) { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli/boot-files - boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar.defaults'], + boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar', 'quasar.defaults'], // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css css: ['app.scss'], diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index fd8570176..064ad1631 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -127,9 +127,10 @@ const onProvinceCreated = async ({ name }, formData) => { - - - + { async function fetch() { try { - const { data } = await axios.get($props.url, { + let { data } = await axios.get($props.url, { params: { filter: JSON.stringify($props.filter) }, }); + + if (Array.isArray(data)) data = data[0] ?? {}; + state.set($props.model, data); originalData.value = data && JSON.parse(JSON.stringify(data)); diff --git a/src/components/common/RightMenu.vue b/src/components/common/RightMenu.vue new file mode 100644 index 000000000..e288fbc87 --- /dev/null +++ b/src/components/common/RightMenu.vue @@ -0,0 +1,55 @@ + + + + + + + {{ t('globals.collapseMenu') }} + + + + + + + + + + + diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 6d0badffb..58cb12708 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -1,13 +1,13 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/ui/CardSummary.vue b/src/components/ui/CardSummary.vue index 1a4514ef5..e52be753f 100644 --- a/src/components/ui/CardSummary.vue +++ b/src/components/ui/CardSummary.vue @@ -54,6 +54,13 @@ async function fetch() { emit('onFetch', Array.isArray(data) ? data[0] : data); isLoading.value = false; } + +const showRedirectToSummaryIcon = computed(() => { + const routeExists = route.matched.some( + (route) => route.name === `${route.meta.moduleName}Summary` + ); + return !isSummary.value && route.meta.moduleName && routeExists; +}); @@ -64,7 +71,7 @@ async function fetch() { - {{ props.info }} + {{ t(props.info) }} diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 525cf6e6b..326ddff5d 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -47,7 +47,10 @@ export function useArrayData(key, userOptions) { if (isEmpty || !allowedOptions.includes(option)) continue; if (Object.prototype.hasOwnProperty.call(store, option)) { - store[option] = userOptions[option]; + const defaultOpts = userOptions[option]; + store[option] = userOptions.keepOpts?.includes(option) + ? Object.assign(defaultOpts, store[option]) + : defaultOpts; } } } diff --git a/src/composables/useRedirect.js b/src/composables/useRedirect.js new file mode 100644 index 000000000..c1470718b --- /dev/null +++ b/src/composables/useRedirect.js @@ -0,0 +1,25 @@ +import { useRouter } from 'vue-router'; + +export default function useRedirect() { + const router = useRouter(); + + const navigate = (data, { customRouteRedirectName, searchText }) => { + if (customRouteRedirectName) + return router.push({ + name: customRouteRedirectName, + params: { id: searchText }, + }); + + const { matched: matches } = router.currentRoute.value; + const { path } = matches.at(-1); + + const to = + data.length === 1 + ? path.replace(/\/(list|:id)|-list/, `/${data[0].id}`) + : path.replace(/:id.*/, ''); + + router.push({ path: to }); + }; + + return { navigate }; +} diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index c5f923855..7dc5777bf 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -430,6 +430,7 @@ ticket: boxing: Boxing sms: Sms notes: Notes + sale: Sale list: nickname: Nickname state: State @@ -826,6 +827,7 @@ worker: log: Log calendar: Calendar timeControl: Time control + locker: Locker list: name: Name email: Email @@ -1234,6 +1236,10 @@ item/itemType: itemType: Item type basicData: Basic data summary: Summary +monitor: + pageTitles: + monitors: Monitors + list: List components: topbar: {} itemsFilterPanel: diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 3b417c3a6..ad7c8d4aa 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -428,6 +428,7 @@ ticket: boxing: Encajado sms: Sms notes: Notas + sale: Lineas del pedido list: nickname: Alias state: Estado @@ -824,6 +825,7 @@ worker: log: Historial calendar: Calendario timeControl: Control de horario + locker: Taquilla list: name: Nombre email: Email @@ -1233,7 +1235,16 @@ item/itemType: itemType: Familia basicData: Datos básicos summary: Resumen - +zone: + pageTitles: + zones: Zona + zonesList: Zonas + deliveryList: Días de entrega + upcomingList: Próximos repartos +monitor: + pageTitles: + monitors: Monitores + list: Listado components: topbar: {} itemsFilterPanel: diff --git a/src/pages/Agency/Card/AgencyCard.vue b/src/pages/Agency/Card/AgencyCard.vue index e78d1cc55..6b2296df3 100644 --- a/src/pages/Agency/Card/AgencyCard.vue +++ b/src/pages/Agency/Card/AgencyCard.vue @@ -1,34 +1,14 @@ diff --git a/src/pages/Agency/Card/AgencyDescriptor.vue b/src/pages/Agency/Card/AgencyDescriptor.vue index 0fa89d07d..b9772037c 100644 --- a/src/pages/Agency/Card/AgencyDescriptor.vue +++ b/src/pages/Agency/Card/AgencyDescriptor.vue @@ -15,8 +15,8 @@ const props = defineProps({ }); const { t } = useI18n(); -const { params } = useRoute(); -const entityId = computed(() => props.id || params.id); +const route = useRoute(); +const entityId = computed(() => props.id || route.params.id); const { store } = useArrayData('Parking'); const card = computed(() => store.data); diff --git a/src/pages/Agency/Card/AgencySummary.vue b/src/pages/Agency/Card/AgencySummary.vue index a4a6a2a18..1a506b154 100644 --- a/src/pages/Agency/Card/AgencySummary.vue +++ b/src/pages/Agency/Card/AgencySummary.vue @@ -3,11 +3,9 @@ import { computed } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; -import FetchData from 'src/components/FetchData.vue'; import CardSummary from 'components/ui/CardSummary.vue'; import VnLv from 'components/ui/VnLv.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; -import VnSelect from 'src/components/common/VnSelect.vue'; const $props = defineProps({ id: { @@ -15,9 +13,9 @@ const $props = defineProps({ default: 0, }, }); -const { params } = useRoute(); +const route = useRoute(); const { t } = useI18n(); -const entityId = computed(() => $props.id || params.id); +const entityId = computed(() => $props.id || route.params.id); const filter = { fields: ['id', 'sectorFk', 'code', 'pickingOrder', 'row', 'column'], diff --git a/src/pages/Claim/Card/ClaimAction.vue b/src/pages/Claim/Card/ClaimAction.vue index b0650b610..a24a2a15e 100644 --- a/src/pages/Claim/Card/ClaimAction.vue +++ b/src/pages/Claim/Card/ClaimAction.vue @@ -201,30 +201,7 @@ async function post(query, params) { auto-load @on-fetch="(data) => (destinationTypes = data)" /> - - - - - - {{ t('globals.collapseMenu') }} - - - - - - + {{ `${t('Total claimed')}: ${toCurrency(totalClaimed)}` }} @@ -274,7 +251,7 @@ async function post(query, params) { v-model="multiplicatorValue" /> - + import VnCard from 'components/common/VnCard.vue'; import ClaimDescriptor from './ClaimDescriptor.vue'; +import ClaimFilter from '../ClaimFilter.vue'; diff --git a/src/pages/Customer/Card/CustomerCard.vue b/src/pages/Customer/Card/CustomerCard.vue index 872bd7da7..98842a0c7 100644 --- a/src/pages/Customer/Card/CustomerCard.vue +++ b/src/pages/Customer/Card/CustomerCard.vue @@ -1,14 +1,16 @@ diff --git a/src/pages/Entry/Card/EntryCard.vue b/src/pages/Entry/Card/EntryCard.vue index 3eb4bd776..9fadd2d06 100644 --- a/src/pages/Entry/Card/EntryCard.vue +++ b/src/pages/Entry/Card/EntryCard.vue @@ -1,14 +1,16 @@ diff --git a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue index bdba33500..a963f1792 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInBasicData.vue @@ -3,14 +3,13 @@ import { ref, computed } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import { useQuasar } from 'quasar'; +import axios from 'axios'; import { useArrayData } from 'src/composables/useArrayData'; import { downloadFile } from 'src/composables/downloadFile'; - import FormModel from 'components/FormModel.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import FetchData from 'src/components/FetchData.vue'; - -import axios from 'axios'; +import VnRow from 'src/components/ui/VnRow.vue'; const quasar = useQuasar(); const route = useRoute(); @@ -181,7 +180,7 @@ async function upsert() { :auto-load="true" > - + - - + + - - + + - - + + - - + + - - - - + + diff --git a/src/pages/InvoiceIn/Card/InvoiceInCard.vue b/src/pages/InvoiceIn/Card/InvoiceInCard.vue index ceec5042d..912713f23 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInCard.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInCard.vue @@ -1,6 +1,7 @@ diff --git a/src/pages/Item/Card/ItemCard.vue b/src/pages/Item/Card/ItemCard.vue index 4eca6137c..66d46f576 100644 --- a/src/pages/Item/Card/ItemCard.vue +++ b/src/pages/Item/Card/ItemCard.vue @@ -1,7 +1,17 @@ - + diff --git a/src/pages/Item/ItemList.vue b/src/pages/Item/ItemList.vue index 39e190147..27acf3fdd 100644 --- a/src/pages/Item/ItemList.vue +++ b/src/pages/Item/ItemList.vue @@ -457,6 +457,7 @@ onUnmounted(() => (stateStore.rightDrawer = false)); :limit="12" :expr-builder="exprBuilder" :user-params="params" + :keep-opts="['userParams']" :offset="50" auto-load > diff --git a/src/pages/Item/ItemTypeList.vue b/src/pages/Item/ItemTypeList.vue index 9d826655f..dd023f94b 100644 --- a/src/pages/Item/ItemTypeList.vue +++ b/src/pages/Item/ItemTypeList.vue @@ -7,8 +7,7 @@ import VnLv from 'src/components/ui/VnLv.vue'; import CardList from 'src/components/ui/CardList.vue'; import ItemTypeSummary from 'src/pages/ItemType/Card/ItemTypeSummary.vue'; import ItemTypeFilter from 'src/pages/ItemType/ItemTypeFilter.vue'; -import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; - +import ItemTypeSearchbar from '../ItemType/ItemTypeSearchbar.vue'; import { useStateStore } from 'stores/useStateStore'; import { useSummaryDialog } from 'src/composables/useSummaryDialog'; @@ -63,13 +62,7 @@ const exprBuilder = (param, value) => { - + @@ -132,11 +125,3 @@ const exprBuilder = (param, value) => { - - -es: - New item type: Nueva familia - Name: Nombre - Search item type: Buscar familia - Search itemType by id, name or code: Buscar familia por id, nombre o código - diff --git a/src/pages/Item/locale/en.yml b/src/pages/Item/locale/en.yml index c08c71f48..99dbeb9fd 100644 --- a/src/pages/Item/locale/en.yml +++ b/src/pages/Item/locale/en.yml @@ -78,3 +78,6 @@ itemTags: tag: Tag value: Value relevancy: Relevancy +searchbar: + label: Search item + info: Search by item id diff --git a/src/pages/Item/locale/es.yml b/src/pages/Item/locale/es.yml index 9b6a51b8a..60e589932 100644 --- a/src/pages/Item/locale/es.yml +++ b/src/pages/Item/locale/es.yml @@ -78,3 +78,6 @@ itemTags: tag: Etiqueta value: Valor relevancy: Relevancia +searchbar: + label: Buscar artículo + info: Buscar por id de artículo diff --git a/src/pages/ItemType/Card/ItemTypeCard.vue b/src/pages/ItemType/Card/ItemTypeCard.vue index cb8adf7f6..9daec7921 100644 --- a/src/pages/ItemType/Card/ItemTypeCard.vue +++ b/src/pages/ItemType/Card/ItemTypeCard.vue @@ -1,12 +1,20 @@ + :filter-panel="ItemTypeFilter" + search-data-key="ItemTypeList" + search-url="ItemTypes" + > + + + + diff --git a/src/pages/ItemType/ItemTypeSearchbar.vue b/src/pages/ItemType/ItemTypeSearchbar.vue new file mode 100644 index 000000000..749033d43 --- /dev/null +++ b/src/pages/ItemType/ItemTypeSearchbar.vue @@ -0,0 +1,19 @@ + + + + + + +es: + Search item type: Buscar familia + Search itemType by id, name or code: Buscar familia por id, nombre o código + diff --git a/src/pages/Monitor/MonitorList.vue b/src/pages/Monitor/MonitorList.vue new file mode 100644 index 000000000..1b1ccb5b3 --- /dev/null +++ b/src/pages/Monitor/MonitorList.vue @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + {{ t('salesMonitor.clientsOnWebsite') }} + + + {{ t('salesMonitor.recentOrderActions') }} + + + + + + + + {{ t('salesMonitor.clientsOnWebsite') }} + + + + + + {{ t('salesMonitor.recentOrderActions') }} + + + + + + + + + + + {{ t('salesMonitor.ticketsMonitor') }} + + + + + + + + + diff --git a/src/pages/Monitor/MonitorMain.vue b/src/pages/Monitor/MonitorMain.vue new file mode 100644 index 000000000..c1f2a31db --- /dev/null +++ b/src/pages/Monitor/MonitorMain.vue @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/src/pages/Monitor/SalesClientsTable.vue b/src/pages/Monitor/SalesClientsTable.vue new file mode 100644 index 000000000..3f2389471 --- /dev/null +++ b/src/pages/Monitor/SalesClientsTable.vue @@ -0,0 +1,219 @@ + + + + (workersActiveOptions = data)" + /> + (clientsOptions = data)" + /> + + + + + + + + + + + + + + + + + + {{ row.salesPerson }} + + + + + + {{ row.clientName }} + + + + + + + + diff --git a/src/pages/Monitor/SalesOrdersTable.vue b/src/pages/Monitor/SalesOrdersTable.vue new file mode 100644 index 000000000..d8e28f6b7 --- /dev/null +++ b/src/pages/Monitor/SalesOrdersTable.vue @@ -0,0 +1,203 @@ + + + + (workersActiveOptions = data)" + /> + (clientsOptions = data)" + /> + + + + + redirectToOrderSummary(row.id)" + > + + + {{ t('salesOrdersTable.delete') }} + + + + + + {{ toDateFormat(row.date_send) }} + + {{ toDateTimeFormat(row.date_make) }} + + + + + + {{ row.clientName }} + + + {{ row.agencyName }} + + + + + + {{ row.salesPerson }} + + + {{ toCurrency(row.import) }} + + + + + + + + diff --git a/src/pages/Monitor/SalesTicketsTable.vue b/src/pages/Monitor/SalesTicketsTable.vue new file mode 100644 index 000000000..f451123e9 --- /dev/null +++ b/src/pages/Monitor/SalesTicketsTable.vue @@ -0,0 +1,636 @@ + + + + (workersActiveOptions = data)" + /> + (provincesOptions = data)" + /> + (statesOptions = data)" + /> + (zonesOptions = data)" + /> + + + redirectToTicketSummary(row.id)" + > + + + + + + + + + + + + + + + {{ + t('salesTicketsTable.noVerifiedData') + }} + + + {{ + t('salesTicketsTable.purchaseRequest') + }} + + + {{ t('salesTicketsTable.notVisible') }} + + + {{ t('salesTicketsTable.clientFrozen') }} + + + {{ t('salesTicketsTable.risk') }}: + {{ row.risk }} + + + {{ + t('salesTicketsTable.componentLack') + }} + + + {{ t('salesTicketsTable.tooLittle') }} + + + + + + {{ row.id }} + + + + + + {{ row.nickname }} + + + + + + {{ row.userName }} + + + + + + + {{ formatShippedDate(row.shippedDate) }} + + + + + + + {{ row.refFk }} + + + + {{ row.state }} + + + + + + + {{ t('salesTicketsTable.isFragile') }} + + + + + + {{ row.zoneName }} + + + + + + + {{ toCurrency(row.totalWithVat) }} + + + + + + + {{ t('salesTicketsTable.goToLines') }} + + + {{ t('salesTicketsTable.preview') }} + + + + + + + diff --git a/src/pages/Monitor/locale/en.yml b/src/pages/Monitor/locale/en.yml new file mode 100644 index 000000000..f58db7854 --- /dev/null +++ b/src/pages/Monitor/locale/en.yml @@ -0,0 +1,45 @@ +salesMonitor: + clientsOnWebsite: Clients on website + recentOrderActions: Recent order actions + ticketsMonitor: Tickets monitor +salesClientsTable: + from: From + to: To + date: Date + hour: Hour + salesPerson: Salesperson + client: Client +salesOrdersTable: + delete: Delete + date: Date + client: Client + salesPerson: Salesperson + deleteConfirmTitle: Delete selected elements + deleteConfirmMessage: All the selected elements will be deleted. Are you sure you want to continue? +salesTicketsTable: + autoRefresh: Auto-refresh + problems: Problems + noVerifiedData: No verified data + notVisible: Not visible + purchaseRequest: Purchase request + clientFrozen: Client frozen + risk: Risk + componentLack: Component lack + tooLittle: Ticket too little + identifier: Identifier + client: Client + salesPerson: Salesperson + date: Date + theoretical: Theoretical + practical: Practical + province: Province + state: State + isFragile: Is fragile + zone: Zone + goToLines: Go to lines + preview: Preview + total: Total + preparation: Preparation +searchBar: + label: Search tickets + info: Search tickets by id or alias diff --git a/src/pages/Monitor/locale/es.yml b/src/pages/Monitor/locale/es.yml new file mode 100644 index 000000000..918b51813 --- /dev/null +++ b/src/pages/Monitor/locale/es.yml @@ -0,0 +1,45 @@ +salesMonitor: + clientsOnWebsite: Clientes activos en la web + recentOrderActions: Acciones recientes en pedidos + ticketsMonitor: Monitor de tickets +salesClientsTable: + from: Desde + to: Hasta + date: Fecha + hour: Hora + salesPerson: Comercial + client: Cliente +salesOrdersTable: + delete: Eliminar + date: Fecha + client: Cliente + salesPerson: Comercial + deleteConfirmTitle: Eliminar los elementos seleccionados + deleteConfirmMessage: Todos los elementos seleccionados serán eliminados. ¿Seguro que quieres continuar? +salesTicketsTable: + autoRefresh: Auto-refresco + problems: Problemas + noVerifiedData: Sin datos comprobados + notVisible: No visible + purchaseRequest: Petición de compra + clientFrozen: Cliente congelado + risk: Riesgo + componentLack: Faltan componentes + tooLittle: Ticket demasiado pequeño + identifier: Identificador + client: Cliente + salesPerson: Comercial + date: Fecha + theoretical: Teórica + practical: Práctica + province: Provincia + state: Estado + isFragile: Es frágil + zone: Zona + goToLines: Ir a líneas + preview: Vista previa + total: Total + preparation: Preparación +searchBar: + label: Buscar tickets + info: Buscar tickets por identificador o alias diff --git a/src/pages/Order/Card/OrderCard.vue b/src/pages/Order/Card/OrderCard.vue index ef7b30d86..5b6896656 100644 --- a/src/pages/Order/Card/OrderCard.vue +++ b/src/pages/Order/Card/OrderCard.vue @@ -1,7 +1,19 @@ - + + + + + diff --git a/src/pages/Order/Card/OrderSummary.vue b/src/pages/Order/Card/OrderSummary.vue index 6e06be9bf..a674a20d0 100644 --- a/src/pages/Order/Card/OrderSummary.vue +++ b/src/pages/Order/Card/OrderSummary.vue @@ -7,7 +7,6 @@ import { dashIfEmpty, toCurrency, toDateHourMinSec } from 'src/filters'; import VnLv from 'components/ui/VnLv.vue'; import CardSummary from 'components/ui/CardSummary.vue'; import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue'; -import OrderSearchbar from 'pages/Order/Card/OrderSearchbar.vue'; import FetchedTags from 'components/ui/FetchedTags.vue'; const { t } = useI18n(); @@ -53,10 +52,6 @@ const detailsColumns = ref([ - - - - @@ -158,11 +153,7 @@ const detailsColumns = ref([ {{ t('order.summary.details') }} - + {{ t('order.summary.item') }} diff --git a/src/pages/Order/OrderList.vue b/src/pages/Order/OrderList.vue index 203eaccd1..6d36d8b31 100644 --- a/src/pages/Order/OrderList.vue +++ b/src/pages/Order/OrderList.vue @@ -61,6 +61,7 @@ function navigate(id) { :limit="20" :order="['landed DESC', 'clientFk', 'id DESC']" :user-params="{ showEmpty: false }" + :keep-opts="['userParams']" auto-load > diff --git a/src/pages/Parking/Card/ParkingBasicData.vue b/src/pages/Parking/Card/ParkingBasicData.vue index c1a9dcee8..8e3433a5b 100644 --- a/src/pages/Parking/Card/ParkingBasicData.vue +++ b/src/pages/Parking/Card/ParkingBasicData.vue @@ -1,5 +1,5 @@ - + + + + + diff --git a/src/pages/Route/Card/RouteSearchbar.vue b/src/pages/Route/Card/RouteSearchbar.vue index e3833d13c..924280580 100644 --- a/src/pages/Route/Card/RouteSearchbar.vue +++ b/src/pages/Route/Card/RouteSearchbar.vue @@ -1,6 +1,6 @@ diff --git a/src/pages/Route/Card/RouteSummary.vue b/src/pages/Route/Card/RouteSummary.vue index 220f93f30..ac03a8231 100644 --- a/src/pages/Route/Card/RouteSummary.vue +++ b/src/pages/Route/Card/RouteSummary.vue @@ -10,7 +10,6 @@ import { dashIfEmpty, toCurrency, toDate, toHour } from 'src/filters'; import WorkerDescriptorProxy from 'pages/Worker/Card/WorkerDescriptorProxy.vue'; import CustomerDescriptorProxy from 'pages/Customer/Card/CustomerDescriptorProxy.vue'; import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue'; -import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue'; import { openBuscaman } from 'src/utils/buscaman'; const $props = defineProps({ @@ -118,11 +117,6 @@ const ticketColumns = ref([ - - - - - import VnCard from 'components/common/VnCard.vue'; import ShelvingDescriptor from 'pages/Shelving/Card/ShelvingDescriptor.vue'; +import ShelvingFilter from './ShelvingFilter.vue'; +import ShelvingSearchbar from './ShelvingSearchbar.vue'; - + + + + + diff --git a/src/pages/Supplier/Card/SupplierCard.vue b/src/pages/Supplier/Card/SupplierCard.vue index c8c503056..adf0315da 100644 --- a/src/pages/Supplier/Card/SupplierCard.vue +++ b/src/pages/Supplier/Card/SupplierCard.vue @@ -1,14 +1,16 @@ diff --git a/src/pages/Ticket/Card/TicketCard.vue b/src/pages/Ticket/Card/TicketCard.vue index 471bfe490..04363b506 100644 --- a/src/pages/Ticket/Card/TicketCard.vue +++ b/src/pages/Ticket/Card/TicketCard.vue @@ -1,14 +1,16 @@ diff --git a/src/pages/Ticket/Card/TicketSale.vue b/src/pages/Ticket/Card/TicketSale.vue new file mode 100644 index 000000000..02cccaff2 --- /dev/null +++ b/src/pages/Ticket/Card/TicketSale.vue @@ -0,0 +1 @@ +Ticket sale diff --git a/src/pages/Worker/Card/WorkerCard.vue b/src/pages/Worker/Card/WorkerCard.vue index d76ef6f59..fb9ab9666 100644 --- a/src/pages/Worker/Card/WorkerCard.vue +++ b/src/pages/Worker/Card/WorkerCard.vue @@ -1,14 +1,16 @@ diff --git a/src/pages/Worker/Card/WorkerLocker.vue b/src/pages/Worker/Card/WorkerLocker.vue new file mode 100644 index 000000000..171074b20 --- /dev/null +++ b/src/pages/Worker/Card/WorkerLocker.vue @@ -0,0 +1,64 @@ + + + (lockers = data)" + /> + + + + + + diff --git a/src/pages/Worker/locale/es.yml b/src/pages/Worker/locale/es.yml index 86dd9d0d9..a960dffe6 100644 --- a/src/pages/Worker/locale/es.yml +++ b/src/pages/Worker/locale/es.yml @@ -1,2 +1,3 @@ Search worker: Buscar trabajador You can search by worker id or name: Puedes buscar por id o nombre del trabajador +Locker: Taquilla diff --git a/src/pages/Zone/Card/ZoneBasicData.vue b/src/pages/Zone/Card/ZoneBasicData.vue index 5d57b920e..7a2c505fa 100644 --- a/src/pages/Zone/Card/ZoneBasicData.vue +++ b/src/pages/Zone/Card/ZoneBasicData.vue @@ -1,34 +1,24 @@ @@ -36,58 +26,90 @@ const agencyFilter = { :filter="agencyFilter" @on-fetch="(data) => (agencyOptions = data)" auto-load - url="agencies" - /> - (zoneOptions = data)" - auto-load - url="zones" + url="AgencyModes/isActive" /> - - + + - + - - - + + + - - - - - - + - + + + + + + - + es: Name: Nombre diff --git a/src/pages/Zone/Card/ZoneDescriptor.vue b/src/pages/Zone/Card/ZoneDescriptor.vue index 8f0aa9e07..b3a55bbe0 100644 --- a/src/pages/Zone/Card/ZoneDescriptor.vue +++ b/src/pages/Zone/Card/ZoneDescriptor.vue @@ -9,6 +9,7 @@ import { toTimeFormat } from 'src/filters/date'; import { toCurrency } from 'filters/index'; import useCardDescription from 'src/composables/useCardDescription'; +import ZoneDescriptorMenuItems from './ZoneDescriptorMenuItems.vue'; const $props = defineProps({ id: { @@ -59,7 +60,7 @@ const setData = (entity) => { flat dense size="md" - icon="preview" + icon="vn:zone" color="white" class="link" :to="{ name: 'ZoneList' }" @@ -69,11 +70,10 @@ const setData = (entity) => { - + - {{ console.log('entity', entity) }} diff --git a/src/pages/Zone/Card/ZoneSummary.vue b/src/pages/Zone/Card/ZoneSummary.vue index b39d2aaab..d46282c10 100644 --- a/src/pages/Zone/Card/ZoneSummary.vue +++ b/src/pages/Zone/Card/ZoneSummary.vue @@ -32,7 +32,7 @@ const filter = computed(() => { fields: ['name'], }, where: { - id: route.params.id, + id: entityId, }, }; return filter; diff --git a/src/pages/Zone/ZoneCreate.vue b/src/pages/Zone/ZoneCreate.vue index c287bce42..e25ccae3a 100644 --- a/src/pages/Zone/ZoneCreate.vue +++ b/src/pages/Zone/ZoneCreate.vue @@ -1,184 +1,114 @@ - - - - - - - - - - - - - - - - - - - - - - - - {{ t('zone.warnings.noData') }} - - - - - - - - - - - - + (warehousesOptions = data)" + auto-load + /> + (agencyOptions = data)" + auto-load + /> + + + + + + + + + + + + + + + + + + + + + + + + + - - diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml index d0a22ebcd..746d3f2e7 100644 --- a/src/pages/Zone/locale/en.yml +++ b/src/pages/Zone/locale/en.yml @@ -2,6 +2,7 @@ zone: pageTitles: zones: Zone zonesList: Zones + zoneCreate: Create zone deliveryList: Delivery days upcomingList: Upcoming deliveries list: @@ -13,18 +14,19 @@ list: price: Price create: Create zone openSummary: Details - confirmCloneTitle: All it's properties will be copied - confirmCloneSubtitle: Do you want to clone this zone? searchZone: Search zones searchInfo: Search zone by id or name + confirmCloneTitle: All it's properties will be copied + confirmCloneSubtitle: Do you want to clone this zone? create: name: Name + warehouse: Warehouse agency: Agency - close: Close + travelingDays: Traveling days + closingHour: Closing hour price: Price -type: - submit: Save - reset: Reset + bonus: Bonus + volumetric: Volumetric summary: agency: Agency price: Price diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml index ad740d5f7..d9266b150 100644 --- a/src/pages/Zone/locale/es.yml +++ b/src/pages/Zone/locale/es.yml @@ -2,6 +2,7 @@ zone: pageTitles: zones: Zonas zonesList: Zonas + zoneCreate: Nueva zona deliveryList: Días de entrega upcomingList: Próximos repartos list: @@ -13,18 +14,19 @@ list: price: Precio create: Crear zona openSummary: Detalles - confirmCloneTitle: Todas sus propiedades serán copiadas - confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona? searchZone: Buscar zonas searchInfo: Buscar zonas por identificador o nombre + confirmCloneTitle: Todas sus propiedades serán copiadas + confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona? create: name: Nombre + warehouse: Almacén agency: Agencia - close: Cierre + travelingDays: Días de viaje + closingHour: Hora de cierre price: Precio -type: - submit: Guardar - reset: Reiniciar + bonus: Bonificación + volumetric: Volumétrico summary: agency: Agencia price: Precio @@ -38,5 +40,3 @@ summary: filterPanel: name: Nombre agencyModeFk: Agencia -Search zones: Buscar zonas -You can search by zone reference: Puedes buscar por referencia de la zona diff --git a/src/router/modules/index.js b/src/router/modules/index.js index 7fff2f2e5..38bcd54d5 100644 --- a/src/router/modules/index.js +++ b/src/router/modules/index.js @@ -18,6 +18,7 @@ import Parking from './parking'; import Agency from './agency'; import ItemType from './itemType'; import Zone from './zone'; +import Monitor from './monitor'; export default [ Item, @@ -40,4 +41,5 @@ export default [ Agency, ItemType, Zone, + Monitor, ]; diff --git a/src/router/modules/monitor.js b/src/router/modules/monitor.js new file mode 100644 index 000000000..6c388a474 --- /dev/null +++ b/src/router/modules/monitor.js @@ -0,0 +1,36 @@ +import { RouterView } from 'vue-router'; + +export default { + path: '/monitor', + name: 'Monitor', + meta: { + title: 'monitors', + icon: 'grid_view', + moduleName: 'Monitor', + }, + component: RouterView, + redirect: { name: 'MonitorMain' }, + menus: { + main: ['MonitorList'], + card: [], + }, + children: [ + { + path: '', + name: 'MonitorMain', + component: () => import('src/pages/Monitor/MonitorMain.vue'), + redirect: { name: 'MonitorList' }, + children: [ + { + path: 'list', + name: 'MonitorList', + meta: { + title: 'list', + icon: 'grid_view', + }, + component: () => import('src/pages/Monitor/MonitorList.vue'), + }, + ], + }, + ], +}; diff --git a/src/router/modules/ticket.js b/src/router/modules/ticket.js index eb6c1b6d2..6cb7291dc 100644 --- a/src/router/modules/ticket.js +++ b/src/router/modules/ticket.js @@ -12,7 +12,7 @@ export default { redirect: { name: 'TicketMain' }, menus: { main: ['TicketList'], - card: ['TicketBoxing', 'TicketSms'], + card: ['TicketBoxing', 'TicketSms', 'TicketSale'], }, children: [ { @@ -66,6 +66,15 @@ export default { }, component: () => import('src/pages/Ticket/Card/TicketBasicData.vue'), }, + { + name: 'TicketSale', + path: 'sale', + meta: { + title: 'sale', + icon: 'vn:lines', + }, + component: () => import('src/pages/Ticket/Card/TicketSale.vue'), + }, { path: 'boxing', name: 'TicketBoxing', diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index d4d3bc3e7..384978d13 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -22,6 +22,7 @@ export default { 'WorkerCalendar', 'WorkerDms', 'WorkerTimeControl', + 'WorkerLocker', ], departmentCard: ['BasicData'], }, @@ -167,6 +168,15 @@ export default { component: () => import('src/pages/Worker/Card/WorkerTimeControl.vue'), }, + { + name: 'WorkerLocker', + path: 'locker', + meta: { + title: 'locker', + icon: 'lock', + }, + component: () => import('src/pages/Worker/Card/WorkerLocker.vue'), + }, ], }, ], diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index d39ed82d0..9c917c301 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -12,7 +12,7 @@ export default { redirect: { name: 'ZoneMain' }, menus: { main: ['ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'], - card: ['ZoneBasicData'], + card: ['ZoneBasicData', 'ZoneHistory', 'ZoneLocations'], }, children: [ { @@ -48,15 +48,15 @@ export default { }, component: () => import('src/pages/Zone/ZoneCreate.vue'), }, - { - path: 'counter', - name: 'ZoneCounter', - meta: { - title: 'zoneCounter', - icon: 'add_circle', - }, - component: () => import('src/pages/Zone/ZoneCounter.vue'), - }, + // { + // path: 'counter', + // name: 'ZoneCounter', + // meta: { + // title: 'zoneCounter', + // icon: 'add_circle', + // }, + // component: () => import('src/pages/Zone/ZoneCounter.vue'), + // }, ], }, { @@ -74,6 +74,15 @@ export default { }, component: () => import('src/pages/Zone/Card/ZoneSummary.vue'), }, + { + name: 'ZoneLocations', + path: 'location', + meta: { + title: 'locations', + icon: 'vn:greuge', + }, + component: () => import('src/pages/Zone/Card/ZoneLocations.vue'), + }, { name: 'ZoneBasicData', path: 'basic-data', @@ -83,6 +92,16 @@ export default { }, component: () => import('src/pages/Zone/Card/ZoneBasicData.vue'), }, + { + name: 'ZoneHistory', + path: 'history', + meta: { + title: 'log', + icon: 'history', + }, + component: () => import('src/pages/Zone/Card/ZoneLog.vue'), + }, + // { // path: '/zone/delivery', // name: 'ZoneDeliveryMain', diff --git a/src/router/routes.js b/src/router/routes.js index 04780ee17..6a0430d51 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -18,6 +18,7 @@ import roadmap from 'src/router/modules/roadmap'; import parking from 'src/router/modules/parking'; import agency from 'src/router/modules/agency'; import zone from 'src/router/modules/zone'; +import monitor from 'src/router/modules/monitor'; const routes = [ { @@ -65,6 +66,7 @@ const routes = [ shelving, invoiceOut, invoiceIn, + monitor, wagon, order, route, diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js index ee1e04e9b..263a9dec8 100644 --- a/src/stores/useNavigationStore.js +++ b/src/stores/useNavigationStore.js @@ -15,6 +15,7 @@ export const useNavigationStore = defineStore('navigationStore', () => { 'travel', 'invoiceOut', 'invoiceIn', + 'monitor', 'supplier', 'claim', 'route', @@ -31,7 +32,6 @@ export const useNavigationStore = defineStore('navigationStore', () => { for (const module of modules) { const moduleDef = routes.find((route) => toLowerCamel(route.name) === module); if (!moduleDef) continue; - const item = addMenuItem(module, moduleDef, modulesRoutes.value); if (!item) continue; diff --git a/test/cypress/integration/VnLocation.spec.js b/test/cypress/integration/VnLocation.spec.js index f373bad8a..d1cddd0e7 100644 --- a/test/cypress/integration/VnLocation.spec.js +++ b/test/cypress/integration/VnLocation.spec.js @@ -1,13 +1,13 @@ const locationOptions = '[role="listbox"] > div.q-virtual-scroll__content > .q-item'; describe('VnLocation', () => { const dialogInputs = '.q-dialog label input'; - describe('Create', () => { + describe('Worker Create', () => { const inputLocation = - '.q-form .q-card> :nth-child(3) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control'; + '.q-form .q-card > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'; beforeEach(() => { cy.viewport(1280, 720); cy.login('developer'); - cy.visit('/#/worker/create'); + cy.visit('/#/worker/create', { timeout: 5000 }); cy.waitForElement('.q-card'); }); it('Show all options', function () { @@ -25,34 +25,35 @@ describe('VnLocation', () => { cy.get(inputLocation).clear(); cy.get(inputLocation).type('ecuador'); cy.get(locationOptions).should('have.length.at.least', 1); - cy.get(`${locationOptions}:nth-child(1)`).click(); - cy.get(inputLocation + '> :nth-child(2) > .q-icon').click(); + cy.get( + '.q-form .q-card > :nth-child(3) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon' + ).click(); }); }); describe('Fiscal-data', () => { beforeEach(() => { cy.viewport(1280, 720); cy.login('developer'); - cy.visit('/#/supplier/567/fiscal-data', { timeout: 2000 }); - cy.waitForElement('.q-card'); + cy.visit('/#/supplier/567/fiscal-data', { timeout: 7000 }); + cy.waitForElement('.q-form'); }); it('Create postCode', function () { cy.get( - ':nth-child(6) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon' + ':nth-child(6) > .q-field > .q-field__inner > .q-field__control > :nth-child(3) > .q-icon' ).click(); cy.get('.q-card > h1').should('have.text', 'New postcode'); cy.get(dialogInputs).eq(0).clear('12'); cy.get(dialogInputs).eq(0).type('1234453'); cy.selectOption( - '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control ', + '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(4) > .q-select > .q-field__inner > .q-field__control ', 'Valencia' ); cy.selectOption( - '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(5) > :nth-child(1) > .q-field > .q-field__inner > .q-field__control ', + '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(5) > .q-select > .q-field__inner > .q-field__control ', 'Province one' ); cy.selectOption( - '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(5) > :nth-child(2) > .q-field > .q-field__inner > .q-field__control ', + '.q-dialog__inner > .column > #formModel > .q-card > :nth-child(6) > .q-select > .q-field__inner > .q-field__control ', 'España' ); cy.get('.q-mt-lg > .q-btn--standard').click(); diff --git a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js index fc989d6c5..963dda3e2 100644 --- a/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInBasicData.spec.js @@ -1,7 +1,8 @@ /// describe('InvoiceInBasicData', () => { - const selects = '.q-form .q-card>:nth-child(1) > :nth-child(1) > .q-field'; - const appendBtns = 'label button'; + const formInputs = '.q-form > .q-card input'; + const firstFormSelect = '.q-card > .vn-row:nth-child(1) > .q-select'; + const appendBtns = '.q-form label button'; const dialogAppendBtns = '.q-dialog label button'; const dialogInputs = '.q-dialog input'; const dialogActionBtns = '.q-card__actions button'; @@ -12,15 +13,14 @@ describe('InvoiceInBasicData', () => { }); it('should edit the provideer and supplier ref', () => { - cy.selectOption(selects, 'Bros'); - + cy.selectOption(firstFormSelect, 'Bros'); cy.get('[title="Reset"]').click(); cy.get(appendBtns).eq(0).click(); - cy.get('input').eq(2).type(4739); + cy.get(formInputs).eq(1).type(4739); cy.saveCard(); - cy.get(`${selects} input`).eq(0).invoke('val').should('eq', 'Plants nick'); - cy.get('input').eq(2).invoke('val').should('eq', '4739'); + cy.get(`${firstFormSelect} input`).invoke('val').should('eq', 'Plants nick'); + cy.get(formInputs).eq(1).invoke('val').should('eq', '4739'); }); it('should edit the dms data', () => { diff --git a/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js b/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js index f39c80809..124b60c34 100644 --- a/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInDueDay.spec.js @@ -1,6 +1,6 @@ /// describe('InvoiceInDueDay', () => { - const inputs = 'label input'; + const amountInput = 'tbody > tr:nth-child(1) td:nth-child(4)'; const addBtn = '.q-page-sticky > div > .q-btn > .q-btn__content'; beforeEach(() => { @@ -9,7 +9,7 @@ describe('InvoiceInDueDay', () => { }); it('should update the amount', () => { - cy.get(inputs).eq(3).type(23); + cy.get(amountInput).type('{selectall}{backspace}23'); cy.saveCard(); cy.get('.q-notification__message').should('have.text', 'Data saved'); }); diff --git a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js index 306c0b8c0..c87fd4315 100644 --- a/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInIntrastat.spec.js @@ -17,10 +17,7 @@ describe('InvoiceInIntrastat', () => { cy.saveCard(); cy.visit(`/#/invoice-in/1/intrastat`); - cy.getValue(firstLineCode).should( - 'equal', - 'Plantas vivas: Esqueje/injerto, Vid' - ); + cy.getValue(firstLineCode).should('equal', 'Plantas vivas: Esqueje/injerto, Vid'); }); it('should add a new row', () => { @@ -33,6 +30,6 @@ describe('InvoiceInIntrastat', () => { }); it('should remove the first line', () => { - cy.removeRow(1); + cy.removeRow(2); }); }); diff --git a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js index ff891399b..389be671c 100644 --- a/test/cypress/integration/invoiceIn/invoiceInVat.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInVat.spec.js @@ -29,7 +29,7 @@ describe('InvoiceInVat', () => { }); it('should remove the first line', () => { - cy.removeRow(1); + cy.removeRow(2); }); it('should throw an error if there are fields undefined', () => { diff --git a/test/cypress/integration/ticket/ticketDescriptor.spec.js b/test/cypress/integration/ticket/ticketDescriptor.spec.js index 22401f0b4..fc920f346 100644 --- a/test/cypress/integration/ticket/ticketDescriptor.spec.js +++ b/test/cypress/integration/ticket/ticketDescriptor.spec.js @@ -1,6 +1,6 @@ /// describe('Ticket descriptor', () => { - const toCloneOpt = '.q-list > :nth-child(5)'; + const toCloneOpt = '[role="menu"] .q-list > :nth-child(5)'; const warehouseValue = ':nth-child(1) > :nth-child(6) > .value > span'; const summaryHeader = '.summaryHeader > div'; diff --git a/test/cypress/integration/worker/workerLocker.spec.js b/test/cypress/integration/worker/workerLocker.spec.js new file mode 100644 index 000000000..01e74760b --- /dev/null +++ b/test/cypress/integration/worker/workerLocker.spec.js @@ -0,0 +1,19 @@ +describe('WorkerList', () => { + const workerId = 1109; + const lockerCode = '201A'; + const input = '.q-card input'; + const firstOpt = '[role="listbox"] .q-item:nth-child(1)'; + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('productionBoss'); + cy.visit(`/#/worker/${workerId}/locker`); + }); + + it('should allocates a locker', () => { + cy.get(input).click(); + cy.get(input).type(lockerCode); + cy.get(firstOpt).click(); + cy.saveCard(); + cy.get(input).invoke('val').should('eq', lockerCode); + }); +}); diff --git a/test/vitest/__tests__/components/common/VnSearchBar.spec.js b/test/vitest/__tests__/components/common/VnSearchBar.spec.js deleted file mode 100644 index 0938ae9c0..000000000 --- a/test/vitest/__tests__/components/common/VnSearchBar.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest'; -import { createWrapper } from 'app/test/vitest/helper'; -import VnSearchbar from 'components/ui/VnSearchbar.vue'; -// Probar a importar como plugin vue-router en archivo helper -describe('VnSearchBar', () => { - let vm; - let wrapper; - let pushSpy; - - beforeAll(() => { - wrapper = createWrapper(VnSearchbar, { - propsData: { - dataKey: 'CustomerList', - label: 'Search customer', - info: 'Info customer', - }, - }); - vm = wrapper.vm; - vm.router.currentRoute.value.matched = [ - { - path: '/', - }, - { - path: '/customer', - }, - { - path: '/customer/:id', - }, - { - path: '/customer/:id/basic-data', - }, - ]; - - pushSpy = vi.spyOn(vm.router, 'push'); - vi.spyOn(vm.arrayData, 'applyFilter'); - }); - - beforeEach(() => (vm.store.data = [{ id: 1112, name: 'Trash' }])); - afterEach(() => vi.clearAllMocks()); - - it('should be defined', async () => { - expect(vm.searchText).toBeDefined(); - expect(vm.searchText).toEqual(''); - }); - - it('should redirect to list page if there are several results', async () => { - vm.store.data.push({ id: 1, name: 'employee' }); - await vm.search(); - expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/list' }); - }); - - it('should redirect to list page if there is no results', async () => { - vm.store.data.pop(); - await vm.search(); - expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/list' }); - }); - - it('should redirect to basic-data page if there is only one result', async () => { - await vm.search(); - expect(pushSpy).toHaveBeenCalledWith({ path: '/customer/1112/basic-data' }); - }); -}); diff --git a/test/vitest/__tests__/composables/useRedirect.spec.js b/test/vitest/__tests__/composables/useRedirect.spec.js new file mode 100644 index 000000000..ce56189b9 --- /dev/null +++ b/test/vitest/__tests__/composables/useRedirect.spec.js @@ -0,0 +1,52 @@ +import { vi, describe, expect, it, beforeEach, beforeAll } from 'vitest'; +import useRedirect from 'src/composables/useRedirect'; +import { useRouter } from 'vue-router'; + +vi.mock('vue-router'); + +describe('useRedirect', () => { + useRouter.mockReturnValue({ + push: vi.fn(), + currentRoute: { + value: { + matched: [ + { path: '/' }, + { path: '/customer' }, + { path: '/customer/:id' }, + { path: '/customer/:id/basic-data' }, + ], + }, + }, + }); + const data = []; + let navigate; + let spy; + + beforeAll(() => { + const { navigate: navigateFn } = useRedirect(); + navigate = navigateFn; + spy = useRouter().push; + }); + + beforeEach(() => { + data.length = 0; + spy.mockReset(); + }); + + it('should redirect to list page if there are several results', async () => { + data.push({ id: 1, name: 'employee' }, { id: 2, name: 'boss' }); + navigate(data, {}); + expect(spy).toHaveBeenCalledWith({ path: '/customer/' }); + }); + + it('should redirect to list page if there is no results', async () => { + navigate(data, {}); + expect(spy).toHaveBeenCalledWith({ path: '/customer/' }); + }); + + it('should redirect to basic-data page if there is only one result', async () => { + data.push({ id: 1, name: 'employee' }); + navigate(data, {}); + expect(spy).toHaveBeenCalledWith({ path: '/customer/1/basic-data' }); + }); +});
{{ t('order.summary.details') }}