Skip to content

Commit

Permalink
Add vf links
Browse files Browse the repository at this point in the history
  • Loading branch information
aheber committed Jan 23, 2024
1 parent f2bacee commit c73a370
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 22 deletions.
21 changes: 21 additions & 0 deletions dlrs/main/classes/RollupEditorController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,27 @@ public with sharing class RollupEditorController {
}
}

@AuraEnabled(cacheable=true)
public static String getManageTriggerPageUrl(Id rollupId) {
PageReference pageRef = Page.managetriggermdt;
pageRef.getParameters().put('id', rollupId);
return pageRef.getUrl();
}

@AuraEnabled(cacheable=true)
public static String getFullCalculatePageUrl(Id rollupId) {
PageReference pageRef = Page.rollupcalculatemdt;
pageRef.getParameters().put('id', rollupId);
return pageRef.getUrl();
}

@AuraEnabled(cacheable=true)
public static String getScheduleCalculatePageUrl(Id rollupId) {
PageReference pageRef = Page.rollupscheduledcalculatemdt;
pageRef.getParameters().put('id', rollupId);
return pageRef.getUrl();
}

private static Map<String, List<String>> collectErrors(RollupSummary rollup) {
Map<String, List<String>> errorMap = new Map<String, List<String>>();
if (rollup.Error != null) {
Expand Down
13 changes: 11 additions & 2 deletions dlrs/main/lwc/manageRollups/manageRollups.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<template>
<lightning-layout pull-to-boundary="small">
<lightning-layout-item size={tableWidth} padding="around-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-card title="Rollups">
<div slot="actions">
<lightning-button
Expand Down Expand Up @@ -30,7 +36,10 @@
</lightning-layout-item>
<lightning-layout-item
lwc:if={showEditor}
size={editorWidth}
size={editorSize.size}
small-device-size={editorSize.sizeSmall}
medium-device-size={editorSize.sizeMedium}
large-device-size={editorSize.sizeLarge}
padding="around-small"
>
<c-rollup-editor
Expand Down
69 changes: 55 additions & 14 deletions dlrs/main/lwc/manageRollups/manageRollups.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,52 @@ 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 = [
{
type: "button",
label: "Name",
fieldName: "Label"
typeAttributes: {
label: { fieldName: "Label" },
name: "rollup_select",
iconName: "utility:edit",
title: "Edit",
value: "edit",
iconPosition: "right",
variant: "base"
}
},
{
label: "Parent",
Expand Down Expand Up @@ -47,18 +88,18 @@ export default class ManageRollups extends LightningElement {
fieldName: "Active__c"
},
{
type: "action",
type: "button-icon",
typeAttributes: {
rowActions: [
{ label: "Edit", name: "rollup_select" },
{ label: "Delete", name: "rollup_delete" }
]
name: "rollup_delete",
iconName: "action:delete",
value: "delete",
variant: "natrual"
}
}
];

editorWidth = 1;
tableWidth = 12;
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
Expand Down Expand Up @@ -114,8 +155,8 @@ export default class ManageRollups extends LightningElement {
this.template
.querySelector("c-rollup-editor")
.loadRollup(row.DeveloperName);
this.tableWidth = 6;
this.editorWidth = 6;
this.tableSize = DISPLAY_SIZES.table.editorOpen;
this.editorSize = DISPLAY_SIZES.editor.editorOpen;
}, 0);
break;
case "rollup_delete":
Expand Down Expand Up @@ -149,8 +190,8 @@ export default class ManageRollups extends LightningElement {
// eslint-disable-next-line @lwc/lwc/no-async-operation
setTimeout(() => {
this.template.querySelector("c-rollup-editor").loadRollup(null);
this.tableWidth = 6;
this.editorWidth = 6;
this.tableSize = DISPLAY_SIZES.table.editorOpen;
this.editorSize = DISPLAY_SIZES.editor.editorOpen;
}, 0);
}

Expand All @@ -166,8 +207,8 @@ export default class ManageRollups extends LightningElement {
}

handleCancelRequest() {
this.tableWidth = 12;
this.editorWidth = 1;
this.tableSize = DISPLAY_SIZES.table.editorClosed;
this.editorSize = DISPLAY_SIZES.editor.editorClosed;

// eslint-disable-next-line @lwc/lwc/no-async-operation
setTimeout(() => {
Expand Down
26 changes: 21 additions & 5 deletions dlrs/main/lwc/rollupEditor/rollupEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@
lwc:if={rollup.Id}
onclick={cloneClickHandler}
></lightning-menu-item>
<lightning-menu-item
label="Manage Triggers"
lwc:if={supportsTrigger}
onclick={manageTriggerHandler}
></lightning-menu-item>
<lightning-menu-item
label="Recalculate Now"
lwc:if={rollup.Id}
onclick={recalculateNowHandler}
></lightning-menu-item>
<lightning-menu-item
label="Schedule Reclaculation"
lwc:if={rollup.Id}
onclick={schedulRecalculateHandler}
></lightning-menu-item>
<lightning-menu-item
label="Delete"
lwc:if={rollup.Id}
Expand Down Expand Up @@ -160,7 +175,7 @@
</lightning-layout-item>
<lightning-layout-item
size="12"
medium-device-size="6"
large-device-size="6"
class="slds-form-element_stacked"
>
<c-autocomplete-combobox
Expand Down Expand Up @@ -227,7 +242,10 @@
name="Relationship"
label="Relationship Criteria"
>
<lightning-layout class="slds-p-horizontal_medium">
<lightning-layout multiple-rows class="slds-p-horizontal_medium">
<lightning-layout-item size="12" class="slds-form-element_stacked">
<p>Define how child records will be qualified for the rollup</p>
</lightning-layout-item>
<lightning-layout-item size="12" class="slds-form-element_stacked">
<lightning-textarea
name="rollup_RelationshipCriteria__c"
Expand All @@ -241,11 +259,9 @@
errors={errors.RelationshipCriteria__c}
></c-rollup-editor-error>
</lightning-layout-item>
</lightning-layout>
<lightning-layout class="slds-p-horizontal_medium">
<lightning-layout-item
size="12"
medium-device-size="8"
large-device-size="8"
class="slds-form-element_stacked"
>
<lightning-textarea
Expand Down
43 changes: 42 additions & 1 deletion dlrs/main/lwc/rollupEditor/rollupEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import getRollupConfig from "@salesforce/apex/RollupEditorController.getRollupCo
import validateRollupConfig from "@salesforce/apex/RollupEditorController.validateRollupConfig";
import saveRollupConfig from "@salesforce/apex/RollupEditorController.saveRollupConfig";
import getFieldOptions from "@salesforce/apex/RollupEditorController.getFieldOptions";
import getManageTriggerPageUrl from "@salesforce/apex/RollupEditorController.getManageTriggerPageUrl";
import getFullCalculatePageUrl from "@salesforce/apex/RollupEditorController.getFullCalculatePageUrl";
import getScheduleCalculatePageUrl from "@salesforce/apex/RollupEditorController.getScheduleCalculatePageUrl";
import { NavigationMixin } from "lightning/navigation";

const DEFAULT_ROLLUP_VALUES = Object.freeze({
Active__c: false,
CalculationMode__c: "Scheduled",
CalculationSharingMode__c: "System"
});

export default class RollupEditor extends LightningElement {
export default class RollupEditor extends NavigationMixin(LightningElement) {
isLoading = false;

openAccordianSections = [
Expand Down Expand Up @@ -155,6 +159,36 @@ export default class RollupEditor extends LightningElement {
console.log("Path clicked", event.detail.label);
}

async manageTriggerHandler() {
const url = await getManageTriggerPageUrl({ rollupId: this.rollup.Id });
this[NavigationMixin.Navigate]({
type: "standard__webPage",
attributes: {
url
}
});
}

async recalculateNowHandler() {
const url = await getFullCalculatePageUrl({ rollupId: this.rollup.Id });
this[NavigationMixin.Navigate]({
type: "standard__webPage",
attributes: {
url
}
});
}

async schedulRecalculateHandler() {
const url = await getScheduleCalculatePageUrl({ rollupId: this.rollup.Id });
this[NavigationMixin.Navigate]({
type: "standard__webPage",
attributes: {
url
}
});
}

onLabelBlurHandler(event) {
const devNameElem = this.template.querySelector(
'[data-name="rollup_DeveloperName"]'
Expand Down Expand Up @@ -252,6 +286,13 @@ export default class RollupEditor extends LightningElement {
this.getParentRelationshipFieldOptions();
}

get supportsTrigger() {
return (
this.rollup.Id &&
["Scheduled", "Realtime"].includes(this.rollup.CalculationMode__c)
);
}

get aggregateOptions() {
return [
{ label: "Sum", value: "Sum" },
Expand Down

0 comments on commit c73a370

Please sign in to comment.