Skip to content

Commit

Permalink
Implemented: picklist sorting on the picklist details page (hotwax#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Dec 6, 2023
1 parent 25144fe commit 792f598
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 7 deletions.
90 changes: 90 additions & 0 deletions src/components/PicklistSortMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<template>
<ion-menu type="overlay" side="end">
<ion-header>
<ion-toolbar>
<ion-title>{{ $t("Sort by") }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-list>
<ion-radio-group :value="picklistItemSortBy" @ionChange="updateSortBy($event)">
<ion-item>
<ion-radio slot="start" value="productName"/>
<ion-label>{{ $t("Product name") }}</ion-label>
</ion-item>
<ion-item>
<ion-radio slot="start" value="locationSeqId"/>
<ion-label>{{ $t("Location ID") }}</ion-label>
</ion-item>
<ion-item>
<ion-radio slot="start" value="picklistBinId"/>
<ion-label>{{ $t("Bin ID") }}</ion-label>
</ion-item>
</ion-radio-group>
</ion-list>
</ion-content>
</ion-menu>
</template>

<script lang="ts">
import {
IonContent,
IonHeader,
IonItem,
IonLabel,
IonList,
IonMenu,
IonRadio,
IonRadioGroup,
IonTitle,
IonToolbar,
menuController
} from '@ionic/vue'
import { idCardOutline, toggleOutline } from 'ionicons/icons'
import { defineComponent } from 'vue';
import { mapGetters, useStore } from 'vuex';
import { translate } from '@hotwax/dxp-components'
import emitter from '@/event-bus';
export default defineComponent({
name: 'FilterMenu',
components: {
IonContent,
IonHeader,
IonItem,
IonLabel,
IonList,
IonMenu,
IonRadio,
IonRadioGroup,
IonTitle,
IonToolbar,
},
computed: {
...mapGetters({
picklistItemSortBy: 'user/getPicklistItemSortBy'
})
},
methods: {
closeMenu() {
menuController.close()
},
async updateSortBy(event: CustomEvent) {
await this.store.dispatch('user/updateSortBy', event.detail.value)
emitter.emit('sortPicklists')
menuController.close()
}
},
setup() {
const store = useStore();
return {
idCardOutline,
store,
toggleOutline,
translate
};
}
})
</script>
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Authenticating": "Authenticating",
"Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?",
"Back to Launchpad": "Back to Launchpad",
"Bin ID": "Bin ID",
"Camera permission denied.": "Camera permission denied.",
"Cancel": "Cancel",
"Change": "Change",
Expand All @@ -23,6 +24,7 @@
"Hide completed picklists": "Hide completed picklists",
"In progress": "In progress",
"Loading": "Loading",
"Location ID": "Location ID",
"Login": "Login",
"Login failed": "Login failed",
"Logging in": "Logging in",
Expand All @@ -41,6 +43,7 @@
"Picklists": "Picklists",
"Please allow camera access in your settings": "Please allow camera access in your settings",
"product barcode": "product barcode",
"Product name": "Product name",
"Product not found": "Product not found",
"Product not found in remaining items": "Product not found in remaining items",
"Reason:": "Reason:",
Expand Down
29 changes: 22 additions & 7 deletions src/views/Picklist-Detail.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<template>
<ion-page>
<PicklistSortMenu content-id="main-content" />

<ion-header :translucent="true">
<ion-toolbar>
<ion-back-button default-href="/" slot="start" />
<ion-title>{{ id }}</ion-title>
<ion-buttons v-if="picklist.statusId !== 'PICKLIST_COMPLETED'" slot="end">
<ion-button @click="selectAll" >{{ $t ("Select all") }}</ion-button>
<ion-buttons slot="end">
<ion-button @click="selectAll" v-if="picklist.statusId !== 'PICKLIST_COMPLETED'">{{ $t ("Select all") }}</ion-button>
<ion-menu-button>
<ion-icon :icon="swapVerticalOutline" />
</ion-menu-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-content id="main-content">
<ion-item class="scanner">
<ion-label>{{ $t("Scan") }}</ion-label>
<ion-input @ionFocus="selectSearchBarText($event)" :placeholder="$t('product barcode')" @keyup.enter="$event.target.value && selectProduct($event.target.value.trim()); $event.target.value = ''"/>
Expand Down Expand Up @@ -54,20 +59,23 @@ import {
IonItemGroup,
IonLabel,
IonList,
IonMenuButton,
IonPage,
IonTitle,
IonToolbar,
alertController,
modalController
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { barcodeOutline, checkmarkDone } from 'ionicons/icons';
import { barcodeOutline, checkmarkDone, swapVerticalOutline } from 'ionicons/icons';
import PicklistDetailItem from '@/components/Picklist-detail-item.vue';
import { mapGetters, useStore } from 'vuex';
import { translate } from '@/i18n'
import { showToast } from '@/utils';
import Scanner from '@/components/Scanner'
import { useRouter, onBeforeRouteLeave } from 'vue-router';
import PicklistSortMenu from '@/components/PicklistSortMenu.vue';
import emitter from '@/event-bus';
export default defineComponent({
name: 'PicklistDetail',
Expand All @@ -85,10 +93,12 @@ export default defineComponent({
IonItemGroup,
IonLabel,
IonList,
IonMenuButton,
IonPage,
IonTitle,
IonToolbar,
PicklistDetailItem
PicklistDetailItem,
PicklistSortMenu
},
computed: {
...mapGetters({
Expand All @@ -105,7 +115,11 @@ export default defineComponent({
props: ['id'],
async mounted () {
await this.store.dispatch('picklist/setCurrentPicklist', { id: this.id })
this.sortPickists()
this.sortPicklists()
emitter.on('sortPicklists', this.sortPicklists)
},
unmounted() {
emitter.off('sortPicklists', this.sortPicklists)
},
methods: {
async completePicklist() {
Expand Down Expand Up @@ -187,7 +201,7 @@ export default defineComponent({
showToast(translate("Camera permission denied."));
}
},
sortPickists() {
sortPicklists() {
// Sort picklist products based on the sorting parameter selected
this.picklist.pickingItemList.sort((a, b) => a[this.picklistItemSortBy].localeCompare(b[this.picklistItemSortBy], { sensitivity: 'base' }));
const data = this.picklist.pickingItemList.reduce((r, e) => {
Expand All @@ -212,6 +226,7 @@ export default defineComponent({
barcodeOutline,
checkmarkDone,
store,
swapVerticalOutline,
router
}
}
Expand Down

0 comments on commit 792f598

Please sign in to comment.