-
Notifications
You must be signed in to change notification settings - Fork 37
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: common admin permission on ship now button if any shipment package require tracking (#281) #289
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9001e2a
Implemented: common admin permission on ship now button if any shipme…
k2maan 25e2d67
Implemented: permission on bulk ship button and honoured tracking req…
k2maan fdf58d1
Improved: removed comment (#281)
k2maan 71f6c62
Improved: permission and variable naming (#281)
k2maan d0f4518
Merge branch 'main' of https://github.com/hotwax/fulfillment-pwa into…
k2maan 0515ff0
Improved: logic to exclude tracking required and missing label orders…
k2maan 74ae56b
Improved: experience by adding toast messages if tracking is required…
k2maan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,8 +41,7 @@ | |
</ion-item> | ||
</div> | ||
<div class="results"> | ||
<ion-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo()" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ translate("Ship") }}</ion-button> | ||
|
||
<ion-button :disabled="!hasPermission(Actions.APP_FORCE_SHIP_ORDER)" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ translate("Ship") }}</ion-button> | ||
<ion-card class="order" v-for="(order, index) in getCompletedOrders()" :key="index"> | ||
<div class="order-header"> | ||
<div class="order-primary-info"> | ||
|
@@ -93,7 +92,7 @@ | |
<!-- TODO: implement functionality to mobile view --> | ||
<div class="mobile-only"> | ||
<ion-item> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="clear" >{{ translate("Ship Now") }}</ion-button> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || (isTrackingRequiredForAnyShipmentPackage(order) && !hasPermission(Actions.APP_FORCE_SHIP_ORDER))" fill="clear" >{{ translate("Ship Now") }}</ion-button> | ||
<ion-button slot="end" fill="clear" color="medium" @click="shippingPopover"> | ||
<ion-icon slot="icon-only" :icon="ellipsisVerticalOutline" /> | ||
</ion-button> | ||
|
@@ -104,7 +103,7 @@ | |
<div class="actions"> | ||
<div class="desktop-only"> | ||
<ion-button v-if="!hasPackedShipments(order)" :disabled="true">{{ translate("Shipped") }}</ion-button> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" @click="shipOrder(order)" v-else>{{ translate("Ship Now") }}</ion-button> | ||
<ion-button v-else :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || (isTrackingRequiredForAnyShipmentPackage(order) && !hasPermission(Actions.APP_FORCE_SHIP_ORDER))" @click="shipOrder(order)">{{ translate("Ship Now") }}</ion-button> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click="regenerateShippingLabel(order)"> | ||
{{ translate("Regenerate Shipping Label") }} | ||
<ion-spinner color="primary" slot="end" v-if="order.isGeneratingShippingLabel" name="crescent" /> | ||
|
@@ -125,9 +124,8 @@ | |
</ion-infinite-scroll> | ||
</div> | ||
</div> | ||
<!-- TODO: make mobile view functional --> | ||
<ion-fab v-if="completedOrders.total" class="mobile-only" vertical="bottom" horizontal="end" slot="fixed"> | ||
<ion-fab-button @click="bulkShipOrders()"> | ||
<ion-fab-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo() || !hasPermission(Actions.APP_FORCE_SHIP_ORDER)" @click="bulkShipOrders()"> | ||
<ion-icon :icon="checkmarkDoneOutline" /> | ||
</ion-fab-button> | ||
</ion-fab> | ||
|
@@ -331,6 +329,21 @@ export default defineComponent({ | |
text: translate("Ship"), | ||
handler: async () => { | ||
let orderList = JSON.parse(JSON.stringify(this.completedOrders.list)) | ||
// orders with tracking required and missing label must be excluded | ||
const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) | ||
let trackingRequiredAndMissingLabelOrders: any | ||
if (trackingRequiredOrders.length) { | ||
// filtering and excluding orders having missing label image with tracking required | ||
trackingRequiredAndMissingLabelOrders = trackingRequiredOrders.filter((order: any) => order.missingLabelImage).map((order: any) => order.orderId) | ||
if (trackingRequiredAndMissingLabelOrders.length) { | ||
orderList = orderList.filter((order: any) => !trackingRequiredAndMissingLabelOrders.includes(order.orderId)) | ||
} | ||
} | ||
|
||
if (!orderList.length) { | ||
showToast(translate("No orders are currently able to be shipped due to missing tracking codes.")) | ||
return; | ||
} | ||
|
||
let shipmentIds = orderList.reduce((shipmentIds: any, order: any) => { | ||
if (order.shipments) { | ||
|
@@ -359,8 +372,10 @@ export default defineComponent({ | |
try { | ||
const resp = await OrderService.bulkShipOrders(payload) | ||
|
||
if(resp.status == 200 && !hasError(resp)) { | ||
showToast(translate('Orders shipped successfully')) | ||
if (resp.status == 200 && !hasError(resp)) { | ||
!trackingRequiredAndMissingLabelOrders.length | ||
? showToast(translate('Orders shipped successfully')) | ||
: showToast(translate('out of cannot be shipped due to missing tracking codes.', { remainingOrders: trackingRequiredAndMissingLabelOrders.length, totalOrders: packedOrdersCount })) | ||
// TODO: handle the case of data not updated correctly | ||
await Promise.all([this.initialiseOrderQuery(), this.fetchShipmentMethods(), this.fetchCarrierPartyIds()]); | ||
} else { | ||
|
@@ -609,6 +624,13 @@ export default defineComponent({ | |
}, | ||
fetchProductStock(productId: string) { | ||
this.store.dispatch('stock/fetchStock', { productId }) | ||
}, | ||
isTrackingRequiredForAnyShipmentPackage(order: any) { | ||
if (!order.shipmentPackages) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check the length of shipment packages. |
||
return false | ||
} | ||
|
||
return order.shipmentPackages.some((shipmentPackage: any) => shipmentPackage.isTrackingRequired === 'Y') | ||
} | ||
}, | ||
setup() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.