From 20f4ad8c744ec5235f048d9dfb8d2fe3339ac080 Mon Sep 17 00:00:00 2001
From: Aaron George <79060613+octatau@users.noreply.github.com>
Date: Mon, 27 May 2024 02:54:23 -0400
Subject: [PATCH] Initial implementation of datatable column filters
---
.../main/lwc/manageRollups/manageRollups.html | 3 +-
dlrs/main/lwc/manageRollups/manageRollups.js | 60 ++++++++++++++++++-
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/dlrs/main/lwc/manageRollups/manageRollups.html b/dlrs/main/lwc/manageRollups/manageRollups.html
index a4c17446..25064995 100644
--- a/dlrs/main/lwc/manageRollups/manageRollups.html
+++ b/dlrs/main/lwc/manageRollups/manageRollups.html
@@ -32,13 +32,14 @@
diff --git a/dlrs/main/lwc/manageRollups/manageRollups.js b/dlrs/main/lwc/manageRollups/manageRollups.js
index 967703e5..4ebe9ac3 100644
--- a/dlrs/main/lwc/manageRollups/manageRollups.js
+++ b/dlrs/main/lwc/manageRollups/manageRollups.js
@@ -68,19 +68,44 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
{
label: "Rollup Type",
fieldName: "aggregateOperation",
- sortable: true
+ sortable: true,
+ actions: [
+ { label: 'All', checked: true, name: 'All' },
+ { label: "Sum", checked: false, name: "Sum" },
+ { label: "Max", checked: false, name: "Max" },
+ { label: "Min", checked: false, name: "Min" },
+ { label: "Avg", checked: false, name: "Avg" },
+ { label: "Count", checked: false, name: "Count" },
+ { label: "Count Distinct", checked: false, name: "Count Distinct" },
+ { label: "Concatenate", checked: false, name: "Concatenate" },
+ { label: "Concatenate Distinct", checked: false, name: "Concatenate Distinct" },
+ { label: "First", checked: false, name: "First" },
+ { label: "Last", checked: false, name: "Last" }
+ ]
},
{
label: "Calc Mode",
fieldName: "calculationMode",
- sortable: true
+ sortable: true,
+ actions: [
+ { label: 'All', checked: true, name: 'All' },
+ { label: "Watch for Changes and Process Later", checked: false, name: "Watch and Process" },
+ { label: "Realtime", checked: false, name: "Realtime" },
+ { label: "Invocable by Automation", checked: false, name: "Process Builder" },
+ { label: "Developer", checked: false, name: "Developer" }
+ ]
},
{
label: "Active",
fieldName: "active",
initialWidth: 75,
type: "boolean",
- sortable: true
+ sortable: true,
+ actions: [
+ { label: 'All', checked: true, name: 'All' },
+ { label: 'Active', checked: false, name: 'checked' },
+ { label: 'Inactive', checked: false, name: 'unchecked' },
+ ]
},
{
type: "button-icon",
@@ -109,6 +134,7 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
searchFilter = "";
isLoading = true;
selectedRollup = undefined;
+ filters = {};
connectedCallback() {
this.refreshRollups();
@@ -117,6 +143,22 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
this.handleSubscribe();
}
+ get visibleRollups() {
+ return this.rollupList.filter(rollup => {
+ let filteredFieldNames = Object.keys(this.filters).filter(fieldName => this.filters[fieldName].value !== 'All');
+
+ return filteredFieldNames.every(fieldName => {
+ switch (this.filters[fieldName].type) {
+ case 'boolean':
+ return rollup[fieldName] === (this.filters[fieldName].value === 'checked' ? true : false)
+
+ default:
+ return rollup[fieldName] === this.filters[fieldName].value
+ }
+ })
+ });
+ }
+
async refreshRollups() {
this.isLoading = true;
this.rollups = await getAllRollupConfigs();
@@ -280,6 +322,18 @@ export default class ManageRollups extends NavigationMixin(LightningElement) {
this.calcRollupList();
}
+ handleHeaderAction(event) {
+ let filters = {
+ ...this.filters,
+ [event.detail.columnDefinition.fieldName]: {
+ type: event.detail.columnDefinition.type,
+ value: event.detail.action.name
+ }
+ }
+
+ this.filters = filters;
+ }
+
disconnectedCallback() {
this.handleUnsubscribe();
}