Skip to content

Commit

Permalink
Move editor to modal
Browse files Browse the repository at this point in the history
  • Loading branch information
aheber committed Jan 30, 2024
1 parent 3e6d68b commit f359c36
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 107 deletions.
6 changes: 2 additions & 4 deletions dlrs/main/classes/LookupRollupStatusCheckController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -88,9 +88,7 @@ public with sharing class LookupRollupStatusCheckController {
new Set<String>{ ChildTrigger }
);

if (loadTriggers.size() > 0) {
return true;
}
return loadTriggers.containsKey(ChildTrigger);
}
} catch (Exception e) {
}
Expand Down
1 change: 1 addition & 0 deletions dlrs/main/lwc/flexiblePath/flexiblePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LightningElement, api } from "lwc";
*/

export default class FlexiblePath extends LightningElement {
_steps;
/** @type {step[]} */
@api
get steps() {
Expand Down
21 changes: 1 addition & 20 deletions dlrs/main/lwc/manageRollups/manageRollups.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
<template>
<lightning-layout pull-to-boundary="small">
<lightning-layout-item
size={tableSize.size}
small-device-size={tableSize.sizeSmall}
medium-device-size={tableSize.sizeMedium}
large-device-size={tableSize.sizeLarge}
padding="around-small"
>
<lightning-layout-item size="12" padding="around-small">
<lightning-card title="Rollups">
<div slot="actions">
<lightning-button
Expand Down Expand Up @@ -34,18 +28,5 @@
</div>
</lightning-card>
</lightning-layout-item>
<lightning-layout-item
lwc:if={showEditor}
size={editorSize.size}
small-device-size={editorSize.sizeSmall}
medium-device-size={editorSize.sizeMedium}
large-device-size={editorSize.sizeLarge}
padding="around-small"
>
<c-rollup-editor
onrequestdelete={handleRequestDelete}
oncancel={handleCancelRequest}
></c-rollup-editor>
</lightning-layout-item>
</lightning-layout>
</template>
83 changes: 19 additions & 64 deletions dlrs/main/lwc/manageRollups/manageRollups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = [
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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}`,
Expand All @@ -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() {
Expand All @@ -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();
}
Expand Down Expand Up @@ -297,15 +251,16 @@ 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;
});
}

// 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
});
}
Expand Down
10 changes: 5 additions & 5 deletions dlrs/main/lwc/rollupEditor/rollupEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
variant="destructive"
onclick={cancelClickHandler}
></lightning-button>
<lightning-button
label="Deactivate"
onclick={deactivateClickHandler}
if:true={rollupCanBeDeactivated}
></lightning-button>
<lightning-button-menu
alternative-text="Show more"
menu-alignment="right"
lwc:if={rollup.Id}
>
<lightning-menu-item
label="Deactiveate"
if:true={rollupCanBeDeactivated}
onclick={deactivateClickHandler}
></lightning-menu-item>
<lightning-menu-item
label="Clone"
lwc:if={rollup.Id}
Expand Down
Loading

0 comments on commit f359c36

Please sign in to comment.