Skip to content

Commit

Permalink
Merge pull request #1453 from SFDO-Community/feature/1452-class-sched…
Browse files Browse the repository at this point in the history
…uler-toast-may-fail

Move toast handling out of Modal
  • Loading branch information
aheber authored Apr 13, 2024
2 parents 1e2ade2 + fdb3e04 commit 72769f1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 1 addition & 5 deletions dlrs/main/lwc/classSchedulerModal/classSchedulerModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import LightningModal from "lightning/modal";
// import dlrs from "@salesforce/resourceUrl/dlrs";
// import { loadScript } from "lightning/platformResourceLoader";

import { ShowToastEvent } from "lightning/platformShowToastEvent";
import LightningConfirm from "lightning/confirm";

import getCurrentJobs from "@salesforce/apex/SchedulerController.getCurrentJobs";
Expand Down Expand Up @@ -83,7 +82,6 @@ export default class ClassSchedulerModal extends LightningModal {
// loadScript(this, dlrs + "/js/cronstrue/dist/cronstrue.js")
// .then(() => {
// your code with calls to the JS library
console.log("construe loaded");
this.cronStrings.forEach((v) => {
v.humanReadable = this.cronstrue.toString(v.cronString, {
verbose: true
Expand Down Expand Up @@ -163,12 +161,10 @@ export default class ClassSchedulerModal extends LightningModal {
className: this.className,
newSchedules: this.cronStrings.map((c) => c.cronString)
});
const evt = new ShowToastEvent({
this.close({
title: "Succesfully Added Jobs",
variant: "success"
});
this.dispatchEvent(evt);
this.close();
} catch (error) {
// TODO: handle the error better
console.error(error);
Expand Down
10 changes: 10 additions & 0 deletions dlrs/main/lwc/manageRollups/manageRollups.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
presets: { minutes: ["0", "15", "30", "45"] }
}
]
}).then((results) => {
if (results) {
try {
const evt = new ShowToastEvent(results);
this.dispatchEvent(evt);
} catch (err) {
// known issue with Lighting Locker can cause this to fail
console.error("Failed to create toast with outcome", err);
}
}
});
}

Expand Down
11 changes: 11 additions & 0 deletions dlrs/main/lwc/rollupEditor/rollupEditor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { api, track, wire } from "lwc";

import LightningModal from "lightning/modal";
import { ShowToastEvent } from "lightning/platformShowToastEvent";

import { PATH_STATES } from "c/flexiblePath";

Expand Down Expand Up @@ -296,6 +297,16 @@ export default class RollupEditor extends LightningModal {
presets: { minutes: ["0", "15", "30", "45"] }
}
]
}).then((results) => {
if (results) {
try {
const evt = new ShowToastEvent(results);
this.dispatchEvent(evt);
} catch (err) {
// known issue with Lighting Locker can cause this to fail
console.error("Failed to create toast with outcome", err);
}
}
});
// recalculate Path after Schedule is created
this.configureSteps();
Expand Down

0 comments on commit 72769f1

Please sign in to comment.