From fdb3e04a63384bfda3c2e2cbbbfb419ac621ecfc Mon Sep 17 00:00:00 2001 From: Heber Date: Sat, 13 Apr 2024 13:36:12 -0600 Subject: [PATCH] Move toast handling --- .../lwc/classSchedulerModal/classSchedulerModal.js | 6 +----- dlrs/main/lwc/manageRollups/manageRollups.js | 10 ++++++++++ dlrs/main/lwc/rollupEditor/rollupEditor.js | 11 +++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/dlrs/main/lwc/classSchedulerModal/classSchedulerModal.js b/dlrs/main/lwc/classSchedulerModal/classSchedulerModal.js index 1cded9a6..3657a7b5 100644 --- a/dlrs/main/lwc/classSchedulerModal/classSchedulerModal.js +++ b/dlrs/main/lwc/classSchedulerModal/classSchedulerModal.js @@ -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"; @@ -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 @@ -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); diff --git a/dlrs/main/lwc/manageRollups/manageRollups.js b/dlrs/main/lwc/manageRollups/manageRollups.js index ee08c9d6..a930a1a9 100644 --- a/dlrs/main/lwc/manageRollups/manageRollups.js +++ b/dlrs/main/lwc/manageRollups/manageRollups.js @@ -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); + } + } }); } diff --git a/dlrs/main/lwc/rollupEditor/rollupEditor.js b/dlrs/main/lwc/rollupEditor/rollupEditor.js index 57d2d8a0..b146de1b 100644 --- a/dlrs/main/lwc/rollupEditor/rollupEditor.js +++ b/dlrs/main/lwc/rollupEditor/rollupEditor.js @@ -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"; @@ -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();