Skip to content

Commit

Permalink
Implemented: Added sorting options for "Due Date" and "Count Name" wi…
Browse files Browse the repository at this point in the history
…thin Filters (#531)
  • Loading branch information
R-Sourabh committed Dec 16, 2024
1 parent 08a0a23 commit ec3f98d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/components/Filters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<ion-checkbox :value="query.noFacility" @ionChange="updateQuery('noFacility', $event.detail.checked)">{{ translate("No facility") }}</ion-checkbox>
</ion-item>

<ion-item lines="none">
<ion-icon slot="start" :icon="swapVerticalOutline" />
<ion-select :label="translate('Sort by')" :value="query.sortBy" @ionChange="updateQuery('sortBy', $event.detail.value)" interface="popover">
<ion-select-option value="dueDate desc">{{ translate("Due date - Newest to oldest") }}</ion-select-option>
<ion-select-option value="dueDate asc">{{ translate("Due date - Oldest to newest") }}</ion-select-option>
<ion-select-option value="countImportName asc">{{ translate("Name - A to Z") }}</ion-select-option>
<ion-select-option value="countImportName desc">{{ translate("Name - Z to A") }}</ion-select-option>
</ion-select>
</ion-item>

<template v-if="showAdditionalFilters().selectedFacilities">
<ion-item v-for="facilityId in query.facilityIds" :key="facilityId">
<ion-label>{{ getFacilityName(facilityId) }}</ion-label>
Expand Down Expand Up @@ -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";
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
"Current on hand": "Current on hand",
"Defaults to 'Draft'": "Defaults to 'Draft'",
"Due date": "Due date",
"Due date - Newest to oldest": "Due date - Newest to oldest",
"Due date - Oldest to newest": "Due date - Oldest to newest",
"Date": "Date",
"Discard": "Discard",
"Discard re-count": "Discard re-count",
Expand Down Expand Up @@ -152,6 +154,8 @@
"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",
"No cycle counts found": "No cycle counts found",
Expand Down Expand Up @@ -260,6 +264,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",
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/count/CountState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default interface CountState {
query: {
facilityIds: Array<string>,
noFacility: boolean,
queryString: any
queryString: any,
sortBy: any
},
stats: any;
cycleCounts: any;
Expand Down
6 changes: 6 additions & 0 deletions src/store/modules/count/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const actions: ActionTree<CountState, RootState> = {
const params = {
...payload,
}
// 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"
Expand All @@ -36,6 +38,10 @@ const actions: ActionTree<CountState, RootState> = {
}
}

if(state.query.sortBy) {
params["orderByField"] = state.query.sortBy
}

try {
const resp = await CountService.fetchCycleCounts(params);
if(!hasError(resp) && resp.data.length > 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/count/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const countModule: Module<CountState, RootState> = {
query: {
facilityIds: [],
noFacility: false,
queryString: ''
queryString: '',
sortBy: 'dueDate desc'
},
stats: {},
cycleCountImportSystemMessages:[],
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/count/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const mutations: MutationTree <CountState> = {
state.query = {
facilityIds: [],
noFacility: false,
queryString: ''
queryString: '',
sortBy: ''
}
},
[types.COUNT_STATS_UPDATED](state, payload) {
Expand Down

0 comments on commit ec3f98d

Please sign in to comment.