Skip to content

Commit

Permalink
Merge pull request #1556 from alexed1/v4.2.1Datatable
Browse files Browse the repository at this point in the history
V4.2.1 datatable
  • Loading branch information
ericrsmith35 authored Jul 22, 2024
2 parents d3fd8fd + fdbe73d commit bda9c56
Show file tree
Hide file tree
Showing 12 changed files with 782 additions and 273 deletions.
22 changes: 19 additions & 3 deletions flow_screen_components/datatable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Additional components packaged with this LWC:
**Documentation:** https://unofficialsf.com/datatable-lightning-web-component-for-flow-screens-2/

**Created by:** Eric Smith
**Date:** 2019 - 2023
**Date:** 2019 - 2024

LinkedIn: https://www.linkedin.com/in/ericrsmith2
Salesforce: https://trailblazer.me/id/ericsmith
Expand All @@ -51,8 +51,8 @@ https://unofficialsf.com/flow-action-and-screen-component-basepacks/

---
**Install Datatable**
[Version 4.2.0 (Production or Developer)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004XZlHQAW)
[Version 4.2.0 (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004XZlHQAW)
[Version 4.2.1 (Production or Developer)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fz7wQAA)
[Version 4.2.1 (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fz7wQAA)

---
**Starting with the Winter '21 Release, Salesforce requires that a User's Profile or Permission Set is given specific permission to access any @AuraEnabled Apex Method.**
Expand All @@ -72,6 +72,22 @@ A Permission Set (**USF Flow Screen Component - Datatable**) is included with th
---
# Release Notes

## 07/09/24 - Eric Smith - Version 4.2.1
**Updates:**
- New Feature: Add a Remove Row action as the first or last column in a Datatable.
- New outputs include a collection and a count of the removed rows.
- You can specify the icon and color for the action button.
- You can specify the maximum number of rows that can be removed.
- Selected Rows are now persistent when Paginating, Searching, Filtering, Sorting, and Removing!
- A new output attribute (outputRemainingRows) will provide all records passed into the table with all edits made to those records, less all records (if any) that were removed
- Implemented a default setting (SHOW_DEBUG_INFO = false) to hide record details from console and debug logs
- Source code changes in ers_datatableUtils.js, ers_DatatableController.cls & ers_QueryNRecords.cls
- Console.log statements are now identified with the Datatable's header label

**Bug Fixes:**
- Fixed bug where hyperlinks would open the flow rather than the referenced record
- Fixed bug where a column filter would hang if there was no filter on the first column

## 04/06/24 - Eric Smith - Version 4.2.0
**Updates:**
- Added optional pagination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
public with sharing class ers_DatatableController {
@TestVisible
private static Boolean isMultiCurrencyOrganization = UserInfo.isMultiCurrencyOrganization();
private static Boolean SHOW_DEBUG_INFO = false;
private static String DEBUG_INFO_PREFIX = 'DATATABLE: ';

/**
* this is just a convenient way to return multiple unique pieces of data to the component
Expand Down Expand Up @@ -98,7 +100,9 @@ public with sharing class ers_DatatableController {
cpeRR.objectLabel = objDescribe.getLabel();
cpeRR.objectPluralLabel = objDescribe.getLabelPlural();
cpeRR.objectIconName = getIconName(objName);
System.debug(LoggingLevel.INFO, 'cpeRR - ' + JSON.serializePretty(cpeRR));
if (SHOW_DEBUG_INFO) {
System.debug(LoggingLevel.INFO, 'cpeRR - ' + JSON.serializePretty(cpeRR));
}
return JSON.serialize(cpeRR);
}

Expand All @@ -108,9 +112,11 @@ public with sharing class ers_DatatableController {
String fieldNames,
Boolean suppressCurrencyConversion
) {
System.debug(LoggingLevel.INFO, 'records-' + records);
System.debug(LoggingLevel.INFO, 'fieldNames-' + fieldNames);
System.debug(LoggingLevel.INFO, 'suppressCurrencyConversion-' + suppressCurrencyConversion);
if (SHOW_DEBUG_INFO) {
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'records-' + records);
}
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'fieldNames-' + fieldNames);
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'suppressCurrencyConversion-' + suppressCurrencyConversion);
ReturnResults curRR = new ReturnResults();
if (records.isEmpty()) {
// throw new MyApexException ('The datatable record collection is empty');
Expand Down Expand Up @@ -151,7 +157,9 @@ public with sharing class ers_DatatableController {
curRR.objectName = objName;
}
curRR.timezoneOffset = getTimezoneOffset().format();
System.debug(LoggingLevel.INFO, 'curRR - ' + JSON.serializePretty(curRR));
if (SHOW_DEBUG_INFO) {
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'curRR - ' + JSON.serializePretty(curRR));
}
return JSON.serialize(curRR);
}

Expand Down Expand Up @@ -183,7 +191,7 @@ public with sharing class ers_DatatableController {
List<String> numberFields = new List<String>();
Map<String, Map<String, String>> picklistFieldLabels = new Map<String, Map<String, String>>();
String objectLinkField = getNameUniqueField(objName); // Name (link) Field for the Datatable SObject
System.debug(LoggingLevel.INFO, '*** OBJ/LINK' + objName + '/' + objectLinkField);
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + '*** OBJ/LINK' + objName + '/' + objectLinkField);

Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();

Expand Down Expand Up @@ -272,7 +280,7 @@ public with sharing class ers_DatatableController {
picklistFieldLabels.put(dfr.getName(), valueLabelPair);
}
when else {
System.debug('No field type match');
System.debug(DEBUG_INFO_PREFIX + 'No field type match: ' + dfr.getType().name());
}
}
}
Expand Down Expand Up @@ -345,7 +353,7 @@ public with sharing class ers_DatatableController {
SObject[] recs = Database.query(
'SELECT Id, ' + nameField + ' FROM ' + obj + ' WHERE Id IN :ids'
); //NOPMD
System.debug(LoggingLevel.INFO, 'Name Field: ' + obj + ' - ' + nameField);
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'Name Field: ' + obj + ' - ' + nameField);
Map<Id, SObject> somap = new Map<Id, SObject>();
for (SObject so : recs) {
somap.put((Id) so.get('Id'), so);
Expand Down Expand Up @@ -586,7 +594,7 @@ public with sharing class ers_DatatableController {
// Thanks to Satya.2020 (https://developer.salesforce.com/forums/?id=9062I000000IQ3eQAG)
@TestVisible
private static String getIconName(String sObjectName) {
System.debug(LoggingLevel.INFO, 'Getting Icon for: ' + sObjectName);
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'Getting Icon for: ' + sObjectName);
String iconName;
List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
List<Schema.DescribeTabResult> tabDesc = new List<Schema.DescribeTabResult>();
Expand All @@ -613,7 +621,7 @@ public with sharing class ers_DatatableController {
break;
}
}
System.debug(LoggingLevel.INFO, 'iconName: ' + iconName);
System.debug(LoggingLevel.INFO, DEBUG_INFO_PREFIX + 'iconName: ' + iconName);
return iconName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
*/
@SuppressWarnings('PMD.ClassNamingConventions')
public inherited sharing class ers_QueryNRecords {

private static Boolean SHOW_DEBUG_INFO = false;
private static String DEBUG_INFO_PREFIX = 'DATATABLE: ';

/**
* Class definition for throwing custom exceptions
*/
Expand All @@ -34,18 +38,20 @@ public inherited sharing class ers_QueryNRecords {
queryParam.objectApiName +
' LIMIT ' +
queryParam.numberOfRecords;
System.debug('QUERY: ' + query);
System.debug(DEBUG_INFO_PREFIX + 'QUERY: ' + query);
try {
sObject[] recordList = database.query(query); //NOPMD
System.debug(recordList);
if (SHOW_DEBUG_INFO) {
System.debug(DEBUG_INFO_PREFIX + 'Record List:' + recordList);
}

// Make sure there are the requested # of records
if (!recordList.isEmpty() && recordList.size() < 10) {
for (Integer i = recordList.size(); i < queryParam.numberOfRecords; i++) {
recordList.add(recordList[0]);
}
}
System.debug('Number of Records: ' + recordList.size());
System.debug(DEBUG_INFO_PREFIX + 'Number of Records: ' + recordList.size());

// Include null fields in the serialized result
List<Map<String, Object>> records = new List<Map<String, Object>>();
Expand Down Expand Up @@ -77,7 +83,7 @@ public inherited sharing class ers_QueryNRecords {
// qr.recordString = JSON.serialize(recordList);
result.add(qr);
} catch (Exception e) {
System.debug('ers_QueryNRecords Error: ' + e);
System.debug(DEBUG_INFO_PREFIX + 'ers_QueryNRecords Error: ' + e);
throw e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h3 class="slds-text-heading_medium">Interact with this sample datatable to conf
sorted-by={sortedBy}
sorted-direction={sortDirection}
max-row-selection={maxRowSelection}
selected-rows={selectedRows}
selected-rows={visibleSelectedRowIds}
show-row-number-column={showRowNumbers}
hide-checkbox-column={hideCheckboxColumn}
suppress-bottom-bar={suppressBottomBar}
Expand Down Expand Up @@ -259,7 +259,7 @@ <h3 class="slds-text-heading_medium">Interact with this sample datatable to conf
sorted-by={sortedBy}
sorted-direction={sortDirection}
max-row-selection={maxRowSelection}
selected-rows={selectedRows}
selected-rows={visibleSelectedRowIds}
show-row-number-column={showRowNumbers}
hide-checkbox-column={hideCheckboxColumn}
suppress-bottom-bar={suppressBottomBar}
Expand Down
Loading

0 comments on commit bda9c56

Please sign in to comment.