-
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
Changes from 3 commits
9001e2a
25e2d67
fdf58d1
71f6c62
d0f4518
0515ff0
74ae56b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +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()">{{ $t("Ship") }}</ion-button> | ||
<ion-button :disabled="!hasAnyPackedShipment() || hasAnyMissingInfo() || !hasPermission(Actions.APP_SHIP_ORDER)" expand="block" class="bulk-action desktop-only" fill="outline" size="large" @click="bulkShipOrders()">{{ $t("Ship") }}</ion-button> | ||
|
||
<ion-card class="order" v-for="(order, index) in getCompletedOrders()" :key="index"> | ||
<div class="order-header"> | ||
|
@@ -93,7 +93,7 @@ | |
<!-- TODO: implement functionality to mobile view --> | ||
<div class="mobile-only"> | ||
<ion-item> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="clear" >{{ $t("Ship Now") }}</ion-button> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || (isTrackingRequiredForAnyShipmentPackage(order) && !hasPermission(Actions.APP_SHIP_ORDER))" fill="clear" >{{ $t("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 +104,7 @@ | |
<div class="actions"> | ||
<div class="desktop-only"> | ||
<ion-button v-if="!hasPackedShipments(order)" :disabled="true">{{ $t("Shipped") }}</ion-button> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" @click="shipOrder(order)" v-else>{{ $t("Ship Now") }}</ion-button> | ||
<ion-button v-else :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo || (isTrackingRequiredForAnyShipmentPackage(order) && !hasPermission(Actions.APP_SHIP_ORDER))" @click="shipOrder(order)">{{ $t("Ship Now") }}</ion-button> | ||
<ion-button :disabled="order.hasMissingShipmentInfo || order.hasMissingPackageInfo" fill="outline" @click="regenerateShippingLabel(order)"> | ||
{{ $t("Regenerate Shipping Label") }} | ||
<ion-spinner color="primary" slot="end" v-if="order.isGeneratingShippingLabel" name="crescent" /> | ||
|
@@ -125,9 +125,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_SHIP_ORDER)" @click="bulkShipOrders()"> | ||
<ion-icon :icon="checkmarkDoneOutline" /> | ||
</ion-fab-button> | ||
</ion-fab> | ||
|
@@ -332,6 +331,15 @@ export default defineComponent({ | |
handler: async () => { | ||
let orderList = JSON.parse(JSON.stringify(this.completedOrders.list)) | ||
|
||
// if there are orders with tracking required and label image present | ||
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. Here we only need to exclude those orders for which tracking is required but the shipping label is missing. Please correct the logic. |
||
const trackingRequiredOrders = orderList.filter((order: any) => this.isTrackingRequiredForAnyShipmentPackage(order)) | ||
if (trackingRequiredOrders.length) { | ||
const orderHasMissingLabelImage = orderList.some((order: any) => order.missingLabelImage) | ||
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. I think the terminology here should be around "trackingCode" so that even if label image is missing but user puts tracking code on shipment the variable still makes semantic sense. |
||
if (!orderHasMissingLabelImage) { | ||
orderList = trackingRequiredOrders | ||
} | ||
} | ||
|
||
let shipmentIds = orderList.reduce((shipmentIds: any, order: any) => { | ||
if (order.shipments) { | ||
order.shipments.reduce((shipmentIds: any, shipment: any) => { | ||
|
@@ -609,6 +617,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() { | ||
|
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.
permission name should also include that this is "forceful" like "APP_FORCE_SHIP_ORDER" because for normal orders anyone is allowed to ship them