From f2bacee21823e0530bd64352ef08ade853f9a59a Mon Sep 17 00:00:00 2001 From: Heber Date: Sun, 21 Jan 2024 13:31:56 -0700 Subject: [PATCH] WIP changing layout, adding path --- dlrs/main/classes/RollupEditorController.cls | 14 +- .../__tests__/flexiblePath.test.js | 25 +++ dlrs/main/lwc/flexiblePath/flexiblePath.css | 3 + dlrs/main/lwc/flexiblePath/flexiblePath.html | 105 ++++++++++ dlrs/main/lwc/flexiblePath/flexiblePath.js | 43 +++++ .../lwc/flexiblePath/flexiblePath.js-meta.xml | 5 + dlrs/main/lwc/manageRollups/manageRollups.css | 3 + .../main/lwc/manageRollups/manageRollups.html | 19 +- dlrs/main/lwc/manageRollups/manageRollups.js | 36 +++- .../main/lwc/objectSelector/objectSelector.js | 4 + dlrs/main/lwc/rollupEditor/rollupEditor.html | 181 ++++++++++-------- dlrs/main/lwc/rollupEditor/rollupEditor.js | 43 ++++- 12 files changed, 385 insertions(+), 96 deletions(-) create mode 100644 dlrs/main/lwc/flexiblePath/__tests__/flexiblePath.test.js create mode 100644 dlrs/main/lwc/flexiblePath/flexiblePath.css create mode 100644 dlrs/main/lwc/flexiblePath/flexiblePath.html create mode 100644 dlrs/main/lwc/flexiblePath/flexiblePath.js create mode 100644 dlrs/main/lwc/flexiblePath/flexiblePath.js-meta.xml create mode 100644 dlrs/main/lwc/manageRollups/manageRollups.css diff --git a/dlrs/main/classes/RollupEditorController.cls b/dlrs/main/classes/RollupEditorController.cls index 0ae34965..fd399dcd 100644 --- a/dlrs/main/classes/RollupEditorController.cls +++ b/dlrs/main/classes/RollupEditorController.cls @@ -27,9 +27,13 @@ public with sharing class RollupEditorController { @AuraEnabled public String type; + @AuraEnabled + public List referencesTo; + public SelectOption(String value, String label) { this.value = value; this.label = label; + this.referencesTo = new List(); } } @@ -50,8 +54,16 @@ public with sharing class RollupEditorController { String fieldName = fr.getName(); String label = fr.getLabel(); - SelectOption option = new SelectOption(fieldName, label); + SelectOption option = new SelectOption( + fieldName, + String.format('{0} ({1})', new List{ label, fieldName }) + ); option.type = String.valueof(fr.getType()); + List types = fr.getReferenceTo(); + // if this fields points to a single SObject, pass that up + for (Schema.sObjectType t : types) { + option.referencesTo.add(types[0].getDescribe().getName()); + } options.add(option); } diff --git a/dlrs/main/lwc/flexiblePath/__tests__/flexiblePath.test.js b/dlrs/main/lwc/flexiblePath/__tests__/flexiblePath.test.js new file mode 100644 index 00000000..4e62098d --- /dev/null +++ b/dlrs/main/lwc/flexiblePath/__tests__/flexiblePath.test.js @@ -0,0 +1,25 @@ +import { createElement } from 'lwc'; +import FlexiblePath from 'c/flexiblePath'; + +describe('c-flexible-path', () => { + afterEach(() => { + // The jsdom instance is shared across test cases in a single file so reset the DOM + while (document.body.firstChild) { + document.body.removeChild(document.body.firstChild); + } + }); + + it('TODO: test case generated by CLI command, please fill in test logic', () => { + // Arrange + const element = createElement('c-flexible-path', { + is: FlexiblePath + }); + + // Act + document.body.appendChild(element); + + // Assert + // const div = element.shadowRoot.querySelector('div'); + expect(1).toBe(1); + }); +}); \ No newline at end of file diff --git a/dlrs/main/lwc/flexiblePath/flexiblePath.css b/dlrs/main/lwc/flexiblePath/flexiblePath.css new file mode 100644 index 00000000..eda2cc9a --- /dev/null +++ b/dlrs/main/lwc/flexiblePath/flexiblePath.css @@ -0,0 +1,3 @@ +* { + --slds-c-icon-color-foreground-default: white; +} diff --git a/dlrs/main/lwc/flexiblePath/flexiblePath.html b/dlrs/main/lwc/flexiblePath/flexiblePath.html new file mode 100644 index 00000000..9a677ba6 --- /dev/null +++ b/dlrs/main/lwc/flexiblePath/flexiblePath.html @@ -0,0 +1,105 @@ + diff --git a/dlrs/main/lwc/flexiblePath/flexiblePath.js b/dlrs/main/lwc/flexiblePath/flexiblePath.js new file mode 100644 index 00000000..ef8dcb9a --- /dev/null +++ b/dlrs/main/lwc/flexiblePath/flexiblePath.js @@ -0,0 +1,43 @@ +import { LightningElement, api } from "lwc"; + +/** + * @typedef step + * @property {string} label + * @property {"complete"|"current"|"incomplete"|"failed"} status + */ + +export default class FlexiblePath extends LightningElement { + /** @type {step[]} */ + @api + get steps() { + return this._steps; + } + + set steps(val) { + this._steps = val.map((v) => ({ + ...v, + ["is" + v.status.charAt(0).toUpperCase() + v.status.slice(1)]: true + })); + } + + get nextActionLabel() { + if (!this.steps) { + return "unknown"; + } + let nextLabel = this.steps.find((s) => s.status === "current")?.label; + if (!nextLabel) { + nextLabel = this.steps.find((s) => s.status === "incomplete")?.label; + } + return nextLabel; + } + + handleNextActionClick() { + this.dispatchEvent( + new CustomEvent("nextactionclick", { + detail: { + label: this.nextActionLabel + } + }) + ); + } +} diff --git a/dlrs/main/lwc/flexiblePath/flexiblePath.js-meta.xml b/dlrs/main/lwc/flexiblePath/flexiblePath.js-meta.xml new file mode 100644 index 00000000..6127d855 --- /dev/null +++ b/dlrs/main/lwc/flexiblePath/flexiblePath.js-meta.xml @@ -0,0 +1,5 @@ + + + 59.0 + false + \ No newline at end of file diff --git a/dlrs/main/lwc/manageRollups/manageRollups.css b/dlrs/main/lwc/manageRollups/manageRollups.css new file mode 100644 index 00000000..7660a111 --- /dev/null +++ b/dlrs/main/lwc/manageRollups/manageRollups.css @@ -0,0 +1,3 @@ +* { + transition: width 500ms; +} diff --git a/dlrs/main/lwc/manageRollups/manageRollups.html b/dlrs/main/lwc/manageRollups/manageRollups.html index 3fe66639..0e4b4764 100644 --- a/dlrs/main/lwc/manageRollups/manageRollups.html +++ b/dlrs/main/lwc/manageRollups/manageRollups.html @@ -1,7 +1,13 @@ diff --git a/dlrs/main/lwc/manageRollups/manageRollups.js b/dlrs/main/lwc/manageRollups/manageRollups.js index d7d1aa5c..906e37e0 100644 --- a/dlrs/main/lwc/manageRollups/manageRollups.js +++ b/dlrs/main/lwc/manageRollups/manageRollups.js @@ -57,6 +57,10 @@ export default class ManageRollups extends LightningElement { } ]; + editorWidth = 1; + tableWidth = 12; + 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, @@ -104,9 +108,15 @@ export default class ManageRollups extends LightningElement { const row = event.detail.row; switch (action.name) { case "rollup_select": - this.template - .querySelector("c-rollup-editor") - .loadRollup(row.DeveloperName); + this.showEditor = true; + // eslint-disable-next-line @lwc/lwc/no-async-operation + setTimeout(() => { + this.template + .querySelector("c-rollup-editor") + .loadRollup(row.DeveloperName); + this.tableWidth = 6; + this.editorWidth = 6; + }, 0); break; case "rollup_delete": this.requestDelete(row.DeveloperName); @@ -134,6 +144,16 @@ 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.tableWidth = 6; + this.editorWidth = 6; + }, 0); + } + handleInputChange() { this.searchFilter = this.template .querySelector("lightning-input") @@ -145,6 +165,16 @@ export default class ManageRollups extends LightningElement { this.requestDelete(event.detail.rollupName); } + handleCancelRequest() { + this.tableWidth = 12; + this.editorWidth = 1; + + // eslint-disable-next-line @lwc/lwc/no-async-operation + setTimeout(() => { + this.showEditor = false; + }, 500); + } + disconnectedCallback() { this.handleUnsubscribe(); } diff --git a/dlrs/main/lwc/objectSelector/objectSelector.js b/dlrs/main/lwc/objectSelector/objectSelector.js index 4cb3ab53..6157370a 100644 --- a/dlrs/main/lwc/objectSelector/objectSelector.js +++ b/dlrs/main/lwc/objectSelector/objectSelector.js @@ -83,6 +83,10 @@ export default class ObjectSelector extends LightningElement { const matches = iconNameRegEx.exec(o.iconUrl); if (matches) { o.iconName = `${matches[1]}:${matches[2]}`; + // We just got a new icon for the selected image! + if (o.fullName === this._currentSelection) { + this.selectedRecordIconName = o.iconName; + } } } }); diff --git a/dlrs/main/lwc/rollupEditor/rollupEditor.html b/dlrs/main/lwc/rollupEditor/rollupEditor.html index 9929b2a0..9d9084fd 100644 --- a/dlrs/main/lwc/rollupEditor/rollupEditor.html +++ b/dlrs/main/lwc/rollupEditor/rollupEditor.html @@ -2,19 +2,20 @@
+ -
+ + + + + @@ -64,7 +73,6 @@ placeholder="My Rollup Name" value={rollup.Label} > - @@ -112,29 +120,27 @@ - - + +

- Pick the Parent object you want to roll up to, and then the - Child object that you want to roll up from + Pick the child object, the field that holds your data, and the + field that holds the reference to the parent.

-
- - + - -
- - - + + + + + +

+ Pick the parent object you want to roll up to and the field that + will hold the resulting value +

+
+
+ + + + + + + + + + + +
+ + -

- Select what field you want to rollup, the type of rollup, and - what field on the Parent object to store the result. -

+

Select the type and configuration of the rollup action

@@ -229,16 +278,21 @@ large-device-size="6" class="slds-form-element_stacked" > - +
+
+ - - - - Aggregate All Rows type="checkbox" name="rollup_AggregateAllRows__c" data-name="rollup_AggregateAllRows__c" - label="Include Deleted & Archived" + label="Include Deleted & Archived Records" value={rollup.AggregateAllRows__c} > Aggregate All Rows > - - - - - -