From 7cf81eb24e2c3465e0a7ada65c7efe58bd422b3b Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Thu, 21 Nov 2024 14:44:34 +0530 Subject: [PATCH 1/3] Improved: Show TO filters if the facet has orders; disable if none.(#673) --- src/components/TransferOrderFilters.vue | 68 +---------------------- src/views/TransferOrders.vue | 72 +++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 71 deletions(-) diff --git a/src/components/TransferOrderFilters.vue b/src/components/TransferOrderFilters.vue index c231ae70..319b9138 100644 --- a/src/components/TransferOrderFilters.vue +++ b/src/components/TransferOrderFilters.vue @@ -49,10 +49,6 @@ import { import { defineComponent, computed } from "vue"; import { albumsOutline, banOutline, barChartOutline, calendarNumberOutline, checkmarkDoneOutline, closeOutline, filterOutline, iceCreamOutline, libraryOutline, pulseOutline, settings, shirtOutline, ticketOutline } from "ionicons/icons"; import { mapGetters, useStore } from 'vuex' -import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'; -import { UtilService } from '@/services/UtilService'; -import { hasError } from '@/adapter'; -import logger from '@/logger'; import { translate, useUserStore } from '@hotwax/dxp-components'; export default defineComponent({ @@ -68,24 +64,14 @@ export default defineComponent({ IonTitle, IonToolbar }, - props: ["queryString"], - data () { - return { - shipmentMethods: [] as Array, - statuses: [] as Array - } - }, + props: ["queryString", "shipmentMethods", "statuses"], computed: { ...mapGetters({ transferOrders: 'transferorder/getTransferOrders', getStatusDesc: 'util/getStatusDesc', getShipmentMethodDesc: 'util/getShipmentMethodDesc', - currentEComStore: 'user/getCurrentEComStore', }) }, - async mounted() { - await this.fetchFilters(); - }, unmounted() { this.store.dispatch('transferorder/clearTransferOrderFilters'); }, @@ -116,58 +102,6 @@ export default defineComponent({ transferOrdersQuery.viewIndex = 0; await this.store.dispatch('transferorder/updateTransferOrderQuery', { ...transferOrdersQuery }) }, - async fetchFilters() { - let resp: any; - const payload = prepareOrderQuery({ - docType: "ORDER", - queryFields: 'orderId', - viewSize: '0', // passed viewSize as 0 to not fetch any data - filters: { - '-orderStatusId': { value: 'ORDER_CREATED' }, - orderTypeId: { value: 'TRANSFER_ORDER' }, - facilityId: { value: escapeSolrSpecialChars(this.currentFacility?.facilityId) }, - productStoreId: { value: this.currentEComStore.productStoreId } - }, - facet: { - "shipmentMethodTypeIdFacet":{ - "excludeTags":"shipmentMethodTypeIdFilter", - "field":"shipmentMethodTypeId", - "mincount":1, - "limit":-1, - "sort":"index", - "type":"terms", - "facet": { - "ordersCount": "unique(orderId)" - } - }, - "orderStatusIdFacet":{ - "excludeTags":"orderStatusIdFilter", - "field":"orderStatusId", - "mincount":1, - "limit":-1, - "sort":"index", - "type":"terms", - "facet": { - "ordersCount": "unique(orderId)" - } - } - } - }) - - try { - resp = await UtilService.fetchTransferOrderFacets(payload); - if (resp.status == 200 && !hasError(resp) && resp.data.facets?.count > 0) { - this.shipmentMethods = resp.data.facets.shipmentMethodTypeIdFacet.buckets - this.statuses = resp.data.facets.orderStatusIdFacet.buckets - this.store.dispatch('util/fetchShipmentMethodTypeDesc', this.shipmentMethods.map((shipmentMethod: any) => shipmentMethod.val)) - this.store.dispatch('util/fetchStatusDesc', this.statuses.map((status: any) => status.val)) - } else { - throw resp.data; - } - } catch(err) { - logger.error('Failed to fetch transfer order filters.', err) - } - }, }, setup() { const store = useStore(); diff --git a/src/views/TransferOrders.vue b/src/views/TransferOrders.vue index 1b77234a..86f11283 100644 --- a/src/views/TransferOrders.vue +++ b/src/views/TransferOrders.vue @@ -1,6 +1,6 @@