From f359c36f0f402b690d811337f667a3396a6d1d3d Mon Sep 17 00:00:00 2001 From: Heber Date: Tue, 30 Jan 2024 14:49:46 -0700 Subject: [PATCH] Move editor to modal --- .../LookupRollupStatusCheckController.cls | 6 +- dlrs/main/lwc/flexiblePath/flexiblePath.js | 1 + .../main/lwc/manageRollups/manageRollups.html | 21 +--- dlrs/main/lwc/manageRollups/manageRollups.js | 83 +++--------- dlrs/main/lwc/rollupEditor/rollupEditor.html | 10 +- dlrs/main/lwc/rollupEditor/rollupEditor.js | 118 +++++++++++++++--- .../rollupEditorModal/rollupEditorModal.html | 10 ++ .../rollupEditorModal/rollupEditorModal.js | 14 +++ .../rollupEditorModal.js-meta.xml | 5 + 9 files changed, 161 insertions(+), 107 deletions(-) create mode 100644 dlrs/main/lwc/rollupEditorModal/rollupEditorModal.html create mode 100644 dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js create mode 100644 dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js-meta.xml diff --git a/dlrs/main/classes/LookupRollupStatusCheckController.cls b/dlrs/main/classes/LookupRollupStatusCheckController.cls index 01d6d745..79828cd9 100644 --- a/dlrs/main/classes/LookupRollupStatusCheckController.cls +++ b/dlrs/main/classes/LookupRollupStatusCheckController.cls @@ -70,7 +70,7 @@ public with sharing class LookupRollupStatusCheckController { /** * Check if the rollup has a child/parent trigger */ - @AuraEnabled(Cacheable=true) + @AuraEnabled public static Boolean hasChildTriggerDeployed(String lookupID) { try { LookupRollupSummary = (LookupRollupSummary2__mdt) new RollupSummariesSelector.CustomMetadataSelector( @@ -88,9 +88,7 @@ public with sharing class LookupRollupStatusCheckController { new Set{ ChildTrigger } ); - if (loadTriggers.size() > 0) { - return true; - } + return loadTriggers.containsKey(ChildTrigger); } } catch (Exception e) { } diff --git a/dlrs/main/lwc/flexiblePath/flexiblePath.js b/dlrs/main/lwc/flexiblePath/flexiblePath.js index ef8dcb9a..dc7966ba 100644 --- a/dlrs/main/lwc/flexiblePath/flexiblePath.js +++ b/dlrs/main/lwc/flexiblePath/flexiblePath.js @@ -7,6 +7,7 @@ import { LightningElement, api } from "lwc"; */ export default class FlexiblePath extends LightningElement { + _steps; /** @type {step[]} */ @api get steps() { diff --git a/dlrs/main/lwc/manageRollups/manageRollups.html b/dlrs/main/lwc/manageRollups/manageRollups.html index 03f3fd2c..13d60fd4 100644 --- a/dlrs/main/lwc/manageRollups/manageRollups.html +++ b/dlrs/main/lwc/manageRollups/manageRollups.html @@ -1,12 +1,6 @@ diff --git a/dlrs/main/lwc/manageRollups/manageRollups.js b/dlrs/main/lwc/manageRollups/manageRollups.js index a479d9aa..6dbb84cf 100644 --- a/dlrs/main/lwc/manageRollups/manageRollups.js +++ b/dlrs/main/lwc/manageRollups/manageRollups.js @@ -4,6 +4,7 @@ import LightningConfirm from "lightning/confirm"; import getAllRollupConfigs from "@salesforce/apex/RollupEditorController.getAllRollupConfigs"; import deleteRollupConfig from "@salesforce/apex/RollupEditorController.deleteRollupConfig"; import USER_ID from "@salesforce/user/Id"; +import RollupEditorModal from "c/rollupEditorModal"; import { subscribe, @@ -12,38 +13,6 @@ import { isEmpEnabled } from "lightning/empApi"; -// used to manage the two column widths -const DISPLAY_SIZES = { - table: { - editorOpen: { - size: 3, - sizeSmall: 3, - sizeMedium: 6, - sizeLarge: 6 - }, - editorClosed: { - size: 12, - sizeSmall: 12, - sizeMedium: 12, - sizeMarge: 12 - } - }, - editor: { - editorOpen: { - size: 9, - sizeSmall: 9, - sizeMedium: 6, - sizeLarge: 6 - }, - editorClosed: { - size: 1, - sizeSmall: 1, - sizeMedium: 1, - sizeLarge: 1 - } - } -}; - export default class ManageRollups extends LightningElement { dtColumns = [ { @@ -98,10 +67,6 @@ export default class ManageRollups extends LightningElement { } ]; - editorSize = DISPLAY_SIZES.editor.editorClosed; - tableSize = DISPLAY_SIZES.table.editorClosed; - showEditor = false; - // We only want events for which we've been assigned as the recipient channelName = `/event/UserNotification__e?Recipient__c='${USER_ID.substring( 1, @@ -149,15 +114,7 @@ export default class ManageRollups extends LightningElement { const row = event.detail.row; switch (action.name) { case "rollup_select": - this.showEditor = true; - // eslint-disable-next-line @lwc/lwc/no-async-operation - setTimeout(() => { - this.template - .querySelector("c-rollup-editor") - .loadRollup(row.DeveloperName); - this.tableSize = DISPLAY_SIZES.table.editorOpen; - this.editorSize = DISPLAY_SIZES.editor.editorOpen; - }, 0); + this.openEditor(row.DeveloperName); break; case "rollup_delete": this.requestDelete(row.DeveloperName); @@ -167,6 +124,19 @@ export default class ManageRollups extends LightningElement { } } + async openEditor(rollupName) { + const result = await RollupEditorModal.open({ + // `label` is not included here in this example. + // it is set on lightning-modal-header instead + size: "large", + description: "Rollup Config Editor", + rollupName + }); + if (result?.action === "delete") { + this.requestDelete(result.rollupName); + } + } + async requestDelete(rollupName) { const confirmed = await LightningConfirm.open({ message: `Are you sure you want to delete the rollup named: ${rollupName}`, @@ -186,13 +156,7 @@ export default class ManageRollups extends LightningElement { } runCreateNew() { - this.showEditor = true; - // eslint-disable-next-line @lwc/lwc/no-async-operation - setTimeout(() => { - this.template.querySelector("c-rollup-editor").loadRollup(null); - this.tableSize = DISPLAY_SIZES.table.editorOpen; - this.editorSize = DISPLAY_SIZES.editor.editorOpen; - }, 0); + this.openEditor(null); } handleInputChange() { @@ -206,16 +170,6 @@ export default class ManageRollups extends LightningElement { this.requestDelete(event.detail.rollupName); } - handleCancelRequest() { - this.tableSize = DISPLAY_SIZES.table.editorClosed; - this.editorSize = DISPLAY_SIZES.editor.editorClosed; - - // eslint-disable-next-line @lwc/lwc/no-async-operation - setTimeout(() => { - this.showEditor = false; - }, 500); - } - disconnectedCallback() { this.handleUnsubscribe(); } @@ -297,6 +251,7 @@ export default class ManageRollups extends LightningElement { // Invoke subscribe method of empApi. Pass reference to messageCallback subscribe(this.channelName, -1, messageCallback).then((response) => { // Response contains the subscription information on subscribe call + console.log("EmpAPI Subscribe", JSON.stringify(response)); this.subscription = response; }); } @@ -304,8 +259,8 @@ export default class ManageRollups extends LightningElement { // Handles unsubscribe button click handleUnsubscribe() { // Invoke unsubscribe method of empApi - unsubscribe(this.subscription, (/*response*/) => { - // console.log("unsubscribe() response: ", JSON.stringify(response)); + unsubscribe(this.subscription, (response) => { + console.log("unsubscribe() response: ", JSON.stringify(response)); // Response is true for successful unsubscribe }); } diff --git a/dlrs/main/lwc/rollupEditor/rollupEditor.html b/dlrs/main/lwc/rollupEditor/rollupEditor.html index e84ed8b3..34745302 100644 --- a/dlrs/main/lwc/rollupEditor/rollupEditor.html +++ b/dlrs/main/lwc/rollupEditor/rollupEditor.html @@ -16,16 +16,16 @@ variant="destructive" onclick={cancelClickHandler} > - + 0 + ? PATH_VALUES.complete + : PATH_VALUES.incomplete; + } + if (s.label === "Activate") { + s.status = this.rollup.Active__c + ? PATH_VALUES.complete + : PATH_VALUES.incomplete; + } + newSteps.push(s); + } + + // TODO: mark first incomplete as current + // TODO: reorder to all complete are on left + this.steps = newSteps; + console.log("New Steps", JSON.stringify(this.steps)); + } + async getChildRelationshipFieldOptions() { if (this.rollup.ChildObject__c) { this.childRFieldOptions = await getFieldOptions({ @@ -129,7 +195,6 @@ export default class RollupEditor extends NavigationMixin(LightningElement) { cancelClickHandler() { const evt = new CustomEvent("cancel"); this.dispatchEvent(evt); - this.rollupName = undefined; } cloneClickHandler() { @@ -142,7 +207,6 @@ export default class RollupEditor extends NavigationMixin(LightningElement) { detail: { rollupName: this.rollup.DeveloperName } }); this.dispatchEvent(evt); - this.rollupName = undefined; } activateClickHandler() { @@ -157,9 +221,25 @@ export default class RollupEditor extends NavigationMixin(LightningElement) { pathClickHandler(event) { console.log("Path clicked", event.detail.label); + switch (event.detail.label) { + case "Deploy Trigger": + this.manageTriggerHandler(); + break; + + case "Activate": + this.activateClickHandler(); + break; + case "Schedule Job": + console.error("Job Schedule UI not implemented"); + break; + default: + console.error("Unexpected action", event.detail.label); + break; + } } async manageTriggerHandler() { + // TODO: return to this page, maybe to this rollup?? const url = await getManageTriggerPageUrl({ rollupId: this.rollup.Id }); this[NavigationMixin.Navigate]({ type: "standard__webPage", @@ -170,6 +250,7 @@ export default class RollupEditor extends NavigationMixin(LightningElement) { } async recalculateNowHandler() { + // TODO: return to this page, maybe to this rollup?? const url = await getFullCalculatePageUrl({ rollupId: this.rollup.Id }); this[NavigationMixin.Navigate]({ type: "standard__webPage", @@ -180,6 +261,7 @@ export default class RollupEditor extends NavigationMixin(LightningElement) { } async schedulRecalculateHandler() { + // TODO: return to this page, maybe to this rollup?? const url = await getScheduleCalculatePageUrl({ rollupId: this.rollup.Id }); this[NavigationMixin.Navigate]({ type: "standard__webPage", @@ -230,6 +312,14 @@ export default class RollupEditor extends NavigationMixin(LightningElement) { variant: "info" }); this.dispatchEvent(evt); + this.dispatchEvent( + new CustomEvent("deploystarted", { + detail: { + rollup: this.rollup, + jobId + } + }) + ); this.isLoading = false; } diff --git a/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.html b/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.html new file mode 100644 index 00000000..13f82f7b --- /dev/null +++ b/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.html @@ -0,0 +1,10 @@ + diff --git a/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js b/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js new file mode 100644 index 00000000..b1b0f402 --- /dev/null +++ b/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js @@ -0,0 +1,14 @@ +import { api } from "lwc"; +import LightningModal from "lightning/modal"; + +export default class RollupEditorModal extends LightningModal { + @api rollupName; + + handleCancelRequest() { + this.close(); + } + + handleRequestDelete() { + this.close({ action: "delete", rollupName: this.rollupName }); + } +} diff --git a/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js-meta.xml b/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js-meta.xml new file mode 100644 index 00000000..6127d855 --- /dev/null +++ b/dlrs/main/lwc/rollupEditorModal/rollupEditorModal.js-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + false + \ No newline at end of file