diff --git a/src/components/Filters.vue b/src/components/Filters.vue index 7e5daf04..77bf3ef4 100644 --- a/src/components/Filters.vue +++ b/src/components/Filters.vue @@ -22,6 +22,16 @@ {{ translate("No facility") }} + + + + {{ translate("Farthest due") }} + {{ translate("Nearest due") }} + {{ translate("Name - A to Z") }} + {{ translate("Name - Z to A") }} + + + {{ getFacilityName(facilityId) }} @@ -137,7 +147,7 @@ import { IonToolbar } from "@ionic/vue"; import { computed, ref } from "vue"; -import { closeCircleOutline, businessOutline, gitBranchOutline, gitPullRequestOutline, locateOutline } from "ionicons/icons"; +import { closeCircleOutline, businessOutline, gitBranchOutline, gitPullRequestOutline, locateOutline, swapVerticalOutline } from "ionicons/icons"; import { translate } from '@/i18n' import store from "@/store"; import router from "@/router"; diff --git a/src/locales/en.json b/src/locales/en.json index deffc6c0..3c59b012 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -116,6 +116,7 @@ "Failed to submit cycle count for review": "Failed to submit cycle count for review", "Failed to update items": "Failed to update items", "Failed to update cycle count information": "Failed to update cycle count information", + "Farthest due": "Farthest due", "Fetching cycle counts...": "Fetching cycle counts...", "Field mapping name": "Field mapping name", "File uploaded successfully.": "File uploaded successfully.", @@ -161,8 +162,11 @@ "Make sure you've reviewed the products and their counts before uploading them for review": "Make sure you've reviewed the products and their counts before uploading them for review", "Map all required fields": "Map all required fields", "Mapping name": "Mapping name", + "Name - A to Z": "Name - A to Z", + "Name - Z to A": "Name - Z to A", "New Count": "New Count", "New mapping": "New mapping", + "Nearest due": "Nearest due", "No cycle counts found": "No cycle counts found", "No data found": "No data found", "No items found": "No items found", @@ -272,6 +276,7 @@ "Something went wrong": "Something went wrong", "Something went wrong, please try again": "Something went wrong, please try again", "Something went wrong while login. Please contact administrator": "Something went wrong while login. Please contact administrator.", + "Sort by": "Sort by", "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.": "Specify which facility you want to operate from. Order, inventory and other configuration data will be specific to the facility you select.", "Status": "Status", "STAY": "STAY", diff --git a/src/store/modules/count/CountState.ts b/src/store/modules/count/CountState.ts index 4b52658b..84710bc4 100644 --- a/src/store/modules/count/CountState.ts +++ b/src/store/modules/count/CountState.ts @@ -1,9 +1,12 @@ export default interface CountState { list: Array, total: number, + isScrollable: boolean, query: { facilityIds: Array, - noFacility: boolean + noFacility: boolean, + queryString: string, + sortBy: string }, stats: any; cycleCounts: any; diff --git a/src/store/modules/count/actions.ts b/src/store/modules/count/actions.ts index 357257d4..7dfb0283 100644 --- a/src/store/modules/count/actions.ts +++ b/src/store/modules/count/actions.ts @@ -4,7 +4,6 @@ import CountState from "./CountState" import * as types from "./mutation-types" import { CountService } from "@/services/CountService" import { hasError, showToast } from "@/utils" -import emitter from "@/event-bus" import { translate } from "@/i18n" import router from "@/router" import logger from "@/logger"; @@ -12,12 +11,17 @@ import { DateTime } from "luxon" const actions: ActionTree = { async fetchCycleCounts({ commit, dispatch, state }, payload) { - emitter.emit("presentLoader", { message: "Fetching cycle counts...", backdropDismiss: false }) - let counts: Array = [], total = 0; + let counts = state.list ? JSON.parse(JSON.stringify(state.list)) : [], total = 0; + let isScrollable = true const params = { ...payload, - pageSize: 200 + } + // TODO: Currently, the search functionality works only on the count name. Once the API supports searching across + // multiple fields, we should include the count ID in the search parameters. + if(state.query.queryString.length) { + params["countImportName"] = state.query.queryString + params["countImportName_op"] = "contains" } if(state.query.facilityIds.length) { @@ -34,22 +38,32 @@ const actions: ActionTree = { } } + if(state.query.sortBy) { + params["orderByField"] = state.query.sortBy + } + try { const resp = await CountService.fetchCycleCounts(params); - if(!hasError(resp) && resp.data.length > 0) { - counts = resp.data + if(payload.pageIndex && payload.pageIndex > 0) { + counts = counts.concat(resp.data) + } else { + counts = resp.data + } total = resp.data.length - - dispatch("fetchCycleCountStats", counts.map((count) => count.inventoryCountImportId)) + dispatch("fetchCycleCountStats", counts.map((count: any) => count.inventoryCountImportId)) + // Determine if more data can be fetched + isScrollable = resp.data.length >= payload.pageSize } else { + if (payload.pageIndex > 0) isScrollable = false throw "Failed to fetch the counts" } } catch(err) { + isScrollable = false + if(payload.pageIndex == 0) counts = [] logger.error(err) } - commit(types.COUNT_LIST_UPDATED, { counts, total }) - emitter.emit("dismissLoader") + commit(types.COUNT_LIST_UPDATED, { counts, total , isScrollable }) }, async fetchCycleCountStats({ commit }, inventoryCountImportIds) { @@ -116,7 +130,11 @@ const actions: ActionTree = { } else if(router.currentRoute.value.name === "Closed") { statusId = "INV_COUNT_COMPLETED" } - dispatch("fetchCycleCounts", { statusId }) + dispatch("fetchCycleCounts", { pageSize: process.env.VUE_APP_VIEW_SIZE, pageIndex: 0, statusId }) + }, + + async updateQueryString({ commit }, payload) { + commit(types.COUNT_QUERY_UPDATED, payload) }, async clearQuery({ commit }) { diff --git a/src/store/modules/count/getters.ts b/src/store/modules/count/getters.ts index e0590556..6030cf26 100644 --- a/src/store/modules/count/getters.ts +++ b/src/store/modules/count/getters.ts @@ -15,6 +15,9 @@ const getters: GetterTree = { getCycleCountsList(state) { return state.cycleCounts.list ? JSON.parse(JSON.stringify(state.cycleCounts.list)) : [] }, + isCycleCountListScrollable(state) { + return state.isScrollable + }, isCycleCountScrollable(state) { return state.cycleCounts.isScrollable }, diff --git a/src/store/modules/count/index.ts b/src/store/modules/count/index.ts index 65ab3272..097625d1 100644 --- a/src/store/modules/count/index.ts +++ b/src/store/modules/count/index.ts @@ -10,9 +10,12 @@ const countModule: Module = { state: { list: [], total: 0, + isScrollable: true, query: { facilityIds: [], - noFacility: false + noFacility: false, + queryString: '', + sortBy: 'dueDate desc' }, stats: {}, cycleCountImportSystemMessages:[], diff --git a/src/store/modules/count/mutations.ts b/src/store/modules/count/mutations.ts index d1a128bc..1f49894c 100644 --- a/src/store/modules/count/mutations.ts +++ b/src/store/modules/count/mutations.ts @@ -6,6 +6,7 @@ const mutations: MutationTree = { [types.COUNT_LIST_UPDATED](state, payload) { state.list = payload.counts state.total = payload.total + state.isScrollable = payload.isScrollable; }, [types.COUNT_QUERY_UPDATED](state, payload) { (state.query as any)[payload.key] = payload.value @@ -13,7 +14,9 @@ const mutations: MutationTree = { [types.COUNT_QUERY_CLEARED](state) { state.query = { facilityIds: [], - noFacility: false + noFacility: false, + queryString: '', + sortBy: 'dueDate desc' } }, [types.COUNT_STATS_UPDATED](state, payload) { diff --git a/src/theme/variables.css b/src/theme/variables.css index 1e68d4c3..c1fc6fb9 100644 --- a/src/theme/variables.css +++ b/src/theme/variables.css @@ -242,6 +242,11 @@ http://ionicframework.com/docs/theming/ */ .list-item { padding: var(--spacer-sm) 0; } + + ion-searchbar.searchbar { + padding-top: var(--spacer-base); + padding-inline: var(--spacer-sm) + } } .empty-state { diff --git a/src/views/Assigned.vue b/src/views/Assigned.vue index e5fa20d2..f28fbbaf 100644 --- a/src/views/Assigned.vue +++ b/src/views/Assigned.vue @@ -12,7 +12,8 @@ - + + {{ translate("No cycle counts found") }} @@ -47,31 +48,80 @@ + + + +
{{ translate("No cycle counts found") }}