Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: support to display a spinner on document printing buttons(#176) #184

Merged
merged 3 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ const actions: ActionTree<OrderState, RootState> = {
items: order.doclist.docs,
shipmentId: orderItem.shipmentId,
shipmentMethodTypeId: orderItem.shipmentMethodTypeId,
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc,
isGeneratingShippingLabel: false,
isGeneratingPackingSlip: false
}
})

Expand Down
28 changes: 26 additions & 2 deletions src/views/Completed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" @click="shipOrder(order)" v-else>{{ $t("Ship Now") }}</ion-button>
<!-- TODO: implemented support to make the buttons functional -->
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" v-if="order.missingLabelImage" fill="outline" @click="retryShippingLabel(order)">{{ $t("Retry Generate Label") }}</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" v-else fill="outline" @click="printShippingLabel(order)">{{ $t("Print Shipping Label") }}</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click="printPackingSlip(order)">{{ $t("Print Customer Letter") }}</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" v-else fill="outline" @click="printShippingLabel(order)">
{{ $t("Print Shipping Label") }}
<ion-spinner color="primary" slot="end" v-if="order.isGeneratingShippingLabel" name="crescent" />
</ion-button>
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click="printPackingSlip(order)">
{{ $t("Print Customer Letter") }}
<ion-spinner color="primary" slot="end" v-if="order.isGeneratingPackingSlip" name="crescent" />
</ion-button>
</div>
<div class="desktop-only">
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || !hasPackedShipments(order)" fill="outline" color="danger" @click="unpackOrder(order)">{{ $t("Unpack") }}</ion-button>
Expand Down Expand Up @@ -144,6 +150,7 @@ import {
IonMenuButton,
IonPage,
IonSearchbar,
IonSpinner,
IonThumbnail,
IonTitle,
IonToolbar,
Expand Down Expand Up @@ -187,6 +194,7 @@ export default defineComponent({
IonMenuButton,
IonPage,
IonSearchbar,
IonSpinner,
IonThumbnail,
IonTitle,
IonToolbar,
Expand Down Expand Up @@ -537,12 +545,28 @@ export default defineComponent({
}
},
async printPackingSlip(order: any) {
// if the request to print packing slip is not yet completed, then clicking multiple times on the button
// should not do anything
if(order.isGeneratingPackingSlip) {
return;
}

const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
order.isGeneratingPackingSlip = true;
await OrderService.printPackingSlip(shipmentIds);
order.isGeneratingPackingSlip = false;
},
async printShippingLabel(order: any) {
// if the request to print shipping label is not yet completed, then clicking multiple times on the button
// should not do anything
if(order.isGeneratingShippingLabel) {
return;
}

const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
order.isGeneratingShippingLabel = true;
await OrderService.printShippingLabel(shipmentIds)
order.isGeneratingShippingLabel = false;
}
},
setup() {
Expand Down
16 changes: 12 additions & 4 deletions src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
{{ picklist.pickersName }}
<p>{{ picklist.date }}</p>
</ion-label>
<ion-button fill="outline" slot="end" @click="printPicklist(picklist.id)"><ion-icon :icon="printOutline" /></ion-button>
<ion-spinner color="primary" slot="end" v-if="picklist.isGeneratingPicklist" name="crescent" />
<ion-button v-else fill="outline" slot="end" @click="printPicklist(picklist)">
<ion-icon :icon="printOutline" />
</ion-button>
</ion-item>
</div>

Expand Down Expand Up @@ -181,6 +184,7 @@ import {
IonSelect,
IonSelectOption,
IonSkeletonText,
IonSpinner,
IonThumbnail,
IonTitle,
IonToolbar,
Expand Down Expand Up @@ -229,6 +233,7 @@ export default defineComponent({
IonSelect,
IonSelectOption,
IonSkeletonText,
IonSpinner,
IonThumbnail,
IonTitle,
IonToolbar,
Expand Down Expand Up @@ -615,7 +620,8 @@ export default defineComponent({
picklists.push({
id: picklist.picklistId,
pickersName: pickersName.join(', '),
date: DateTime.fromMillis(picklist.picklistDate).toLocaleString(DateTime.TIME_SIMPLE)
date: DateTime.fromMillis(picklist.picklistDate).toLocaleString(DateTime.TIME_SIMPLE),
isGeneratingPicklist: false // used to display the spinner on the button when trying to generate picklist
})

return picklists
Expand Down Expand Up @@ -756,8 +762,10 @@ export default defineComponent({
async initialiseOrderQuery() {
await this.updateOrderQuery(process.env.VUE_APP_VIEW_SIZE, '')
},
async printPicklist(picklistId: string) {
await OrderService.printPicklist(picklistId)
async printPicklist(picklist: any) {
picklist.isGeneratingPicklist = true;
await OrderService.printPicklist(picklist.id)
picklist.isGeneratingPicklist = false;
}
},
async mounted () {
Expand Down
Loading