Skip to content

Commit

Permalink
Implemented: confirmation alert when disabling a schedule(hotwax#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Feb 2, 2024
1 parent 76269da commit 0b47874
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
6 changes: 4 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"Connection configuration is missing for oms.": "Connection configuration is missing for oms.",
"Description": "Description",
"Disable": "Disable",
"Disabling this schedule will cancel this occurrence and all following occurrences. This schedule will have to be re-enabled manually to run it again.": "Disabling this schedule will cancel this occurrence and all following occurrences. This schedule will have to be re-enabled manually to run it again.",
"Don't cancel": "Don't cancel",
"duration": "duration",
"Edit": "Edit",
"Error getting user profile": "Error getting user profile",
Expand All @@ -36,7 +38,7 @@
"Failed to create order routing": "Failed to create order routing",
"Failed to identify selected inventory rule, please select a rule or refresh": "Failed to identify selected inventory rule, please select a rule or refresh",
"Failed to update group information": "Failed to update group information",
"Failed to update job": "Failed to update job",
"Failed to update schedule": "Failed to update schedule",
"Failed to schedule service": "Failed to schedule service",
"Fetching filters and inventory rules": "Fetching filters and inventory rules",
"Fetching groups": "Fetching groups",
Expand All @@ -51,7 +53,6 @@
"Inventory Filters": "Inventory Filters",
"Inventory rule created successfully": "Inventory rule created successfully",
"Inventory Sort": "Inventory Sort",
"Job disabled": "Job disabled",
"Job updated": "Job updated",
"kms": "kms",
"LEAVE": "LEAVE",
Expand Down Expand Up @@ -108,6 +109,7 @@
"Save Changes": "Save Changes",
"Save changes": "Save changes",
"Schedule": "Schedule",
"Schedule disabled": "Schedule disabled",
"Scheduler": "Scheduler",
"Search time zones": "Search time zones",
"Select": "Select",
Expand Down
46 changes: 30 additions & 16 deletions src/views/BrokeringRoute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</ion-card>
<div class="actions desktop-only">
<div>
<ion-button :disabled="typeof isOmsConnectionExist === 'boolean' && !isOmsConnectionExist" size="small" fill="outline" color="danger" @click="disable">{{ translate("Disable") }}</ion-button>
<ion-button :disabled="job.paused === 'Y' || typeof isOmsConnectionExist === 'boolean' && !isOmsConnectionExist" size="small" fill="outline" color="danger" @click="disable">{{ translate("Disable") }}</ion-button>
</div>
<div>
<ion-button :disabled="typeof isOmsConnectionExist === 'boolean' && !isOmsConnectionExist" size="small" fill="outline" @click="saveChanges()">{{ translate("Save changes") }}</ion-button>
Expand Down Expand Up @@ -250,22 +250,36 @@ async function saveChanges() {
}
async function disable() {
const payload = {
routingGroupId: props.routingGroupId,
paused: "Y" // setting Y to disable the job
}
const alert = await alertController
.create({
header: translate("Disable"),
message: translate("Disabling this schedule will cancel this occurrence and all following occurrences. This schedule will have to be re-enabled manually to run it again."),
buttons: [{
text: translate("Don't cancel"),
role: "cancel"
}, {
text: translate("Cancel"),
handler: async () => {
const payload = {
routingGroupId: props.routingGroupId,
paused: "Y" // setting Y to disable the schedule
}
try {
const resp = await OrderRoutingService.scheduleBrokering(payload)
if(!hasError(resp)){
showToast(translate("Job disabled"))
} else {
throw resp.data
}
} catch(err) {
showToast(translate("Failed to update job"))
logger.error(err)
}
try {
const resp = await OrderRoutingService.scheduleBrokering(payload)
if(!hasError(resp)){
showToast(translate("Schedule disabled"))
} else {
throw resp.data
}
} catch(err) {
showToast(translate("Failed to update schedule"))
logger.error(err)
}
}
}],
});
return alert.present();
}
async function runNow() {
Expand Down

0 comments on commit 0b47874

Please sign in to comment.