Skip to content

Commit ef73dce

Browse files
authored
Merge pull request #1634 from alexed1/Datatable-4.3.6
Datatable 4.3.6
2 parents 9274829 + e5df529 commit ef73dce

File tree

5 files changed

+99
-62
lines changed

5 files changed

+99
-62
lines changed

flow_screen_components/datatable/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ https://unofficialsf.com/flow-action-and-screen-component-basepacks/
5151

5252
---
5353
**Install Datatable**
54-
[Version 4.3.5 (Production or Developer)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fzBFQAY)
55-
[Version 4.3.5 (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fzBFQAY)
54+
[Version 4.3.6 (Production or Developer)](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fzCcQAI)
55+
[Version 4.3.6 (Sandbox)](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5G000004fzCcQAI)
5656

5757
---
5858
**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.**
@@ -71,6 +71,17 @@ A Permission Set (**USF Flow Screen Component - Datatable**) is included with th
7171

7272
---
7373
# Release Notes
74+
75+
## 2/28/25 - Eric Smith - Version 4.3.6
76+
**Updates:**
77+
**Bug Fixes:**
78+
- Fixed bug where table gets reset after removing the last row
79+
- Fixed bug introduced in v4.3.3 affecting percent fields when inline editing
80+
- Fixed bug where clearing a column filter crashed when a row action column was enabled
81+
- Fixed bug where row action button preview was showing an incorrect icon
82+
- Fixed Filter/Search bug introduced in 4.3.5 when a Date field column was present
83+
- NOTE: Enter dates in the search box in the YYYY-MM-DD format
84+
7485
## 1/25/25 - Eric Smith - Version 4.3.5
7586
**Updates:**
7687
- Added a Standard Row Action in addition to the existing Remove Row action

flow_screen_components/datatable/force-app/main/default/lwc/datatable/datatable.js

Lines changed: 76 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ export default class Datatable extends LightningElement {
134134
@api rowActionButtonIconPosition;
135135
@api rowActionButtonVariant;
136136

137+
// v4.3.6 Fix for not clearing removed rows after last one is removed
138+
haveProcessedReactivity = false;
139+
137140
@api
138141
get outputActionedRow() {
139142
return this._outputActionedRow;
@@ -155,6 +158,10 @@ export default class Datatable extends LightningElement {
155158

156159
rowActionColNum;
157160

161+
get rowActionColumnOffset() { // v4.3.6 - for selecting correct filter column when action is on the left
162+
return (this.hasRowAction && this.rowActionLeftOrRight == "Left") ? 1 : 0;
163+
}
164+
158165
@api
159166
get isRemoveRowAction() {
160167
return (this.cb_isRemoveRowAction == CB_TRUE) ? true : false;
@@ -1290,9 +1297,8 @@ export default class Datatable extends LightningElement {
12901297
// Custom column processing
12911298
this.updateColumns();
12921299

1293-
const firstCol = (this.hasRowAction && this.rowActionLeftOrRight == "Left") ? 1 : 0;
1294-
if(this.cols[firstCol]?.fieldName.endsWith('_lookup')) {
1295-
this.sortedBy = this.cols[0].fieldName;
1300+
if(this.cols[this.rowActionColumnOffset]?.fieldName.endsWith('_lookup')) {
1301+
this.sortedBy = this.cols[this.rowActionColumnOffset].fieldName;
12961302
this.doSort(this.sortedBy, 'asc');
12971303
}
12981304

@@ -1389,13 +1395,16 @@ export default class Datatable extends LightningElement {
13891395
}
13901396

13911397
// Other processing for reactivity
1392-
this.outputRemovedRows = [];
1393-
this.numberOfRowsRemoved = 0;
1394-
this.outputRemainingRows = [];
1395-
this.dispatchEvent(new FlowAttributeChangeEvent('outputRemovedRows', this.outputRemovedRows));
1396-
this.dispatchEvent(new FlowAttributeChangeEvent('numberOfRowsRemoved', this.numberOfRowsRemoved));
1397-
this.dispatchEvent(new FlowAttributeChangeEvent('outputRemainingRows', this._outputRemainingRows));
1398-
1398+
if (!this.haveProcessedReactivity) {
1399+
this.outputRemovedRows = [];
1400+
this.numberOfRowsRemoved = 0;
1401+
this.outputRemainingRows = [];
1402+
this.dispatchEvent(new FlowAttributeChangeEvent('outputRemovedRows', this.outputRemovedRows));
1403+
this.dispatchEvent(new FlowAttributeChangeEvent('numberOfRowsRemoved', this.numberOfRowsRemoved));
1404+
this.dispatchEvent(new FlowAttributeChangeEvent('outputRemainingRows', this._outputRemainingRows));
1405+
this.haveProcessedReactivity = true;
1406+
}
1407+
13991408
// Clear all existing column filters
14001409
this.columnFilterValues = [];
14011410
this.showClearFilterButton = false;
@@ -2224,7 +2233,11 @@ export default class Datatable extends LightningElement {
22242233
if (sdraft != undefined) {
22252234
let sfieldNames = Object.keys(sdraft);
22262235
sfieldNames.forEach(sf => {
2227-
sitem[sf] = sdraft[sf];
2236+
if (this.percentFieldArray.indexOf(sf) != -1) {
2237+
sitem[sf] = parseFloat(sdraft[sf])/100;
2238+
} else {
2239+
sitem[sf] = sdraft[sf];
2240+
}
22282241
});
22292242
}
22302243
return sitem;
@@ -2369,7 +2382,7 @@ export default class Datatable extends LightningElement {
23692382

23702383
// Reapply filters (none in place)
23712384
this.filterColumnData();// v4.3.3 promise/resolve clears selected rows
2372-
this.isWorking = true;
2385+
// this.isWorking = true;
23732386
// new Promise((resolve, reject) => {
23742387
// setTimeout(() => {
23752388
// this.filterColumnData();
@@ -2380,15 +2393,16 @@ export default class Datatable extends LightningElement {
23802393
// () => this.isWorking = false
23812394
// );
23822395

2383-
colNumber = 0;
2384-
this.columns.forEach(col => { // Disable all column Clear header actions and reset Labels
2385-
this.columns[colNumber].actions.find(a => a.name == 'clear_'+colNumber).disabled = true;
2396+
// Disable all column Clear header actions and reset Labels
2397+
let colCount = this.columns.length - ((this.hasRowAction) ? 1 : 0);
2398+
for (colNumber = this.rowActionColumnOffset; colNumber < colCount; colNumber++) {
2399+
let actionColRef = colNumber-this.rowActionColumnOffset; // *** v4.3.6 fix ***
2400+
this.columns[colNumber].actions.find(a => a.name == 'clear_'+actionColRef).disabled = true;
23862401
this.columns[colNumber].label = this.columns[colNumber].label.split(' [')[0];
2387-
colNumber++;
2388-
});
2402+
}
23892403

23902404
// Re-Sort the data
2391-
if (this.sortedBy != undefined) {
2405+
if (this.sortedBy) {
23922406
this.doSort(this.sortedBy, this.sortDirection);
23932407
}
23942408
}
@@ -2405,7 +2419,6 @@ export default class Datatable extends LightningElement {
24052419
}
24062420

24072421
doSort(sortField, sortDirection) {
2408-
24092422
// Determine if column type will allow field values to be converted to lower case
24102423
let isString = false;
24112424
if (this.isCaseInsensitiveSort) {
@@ -2447,7 +2460,7 @@ export default class Datatable extends LightningElement {
24472460
})
24482461
.then(
24492462
() => this.isWorking = false
2450-
);
2463+
);
24512464
}
24522465

24532466
handleHeaderAction(event) {
@@ -2459,7 +2472,7 @@ export default class Datatable extends LightningElement {
24592472
this.isFiltered = false;
24602473
const colDef = event.detail.columnDefinition;
24612474
this.filterColumns = JSON.parse(JSON.stringify([...this.columns]));
2462-
this.columnNumber = Number(colDef.actions[0].name.split("_")[1]);
2475+
this.columnNumber = Number(colDef.actions[0].name.split("_")[1]) + this.rowActionColumnOffset; // v4.3.6 Use correct column when a left side row action is present
24632476
this.baseLabel = this.filterColumns[this.columnNumber].label.split(' [')[0];
24642477
const prompt = (this.isConfigMode) ? this.label.LabelHeader : this.label.FilterHeader;
24652478
this.inputLabel = this.label.ColumnHeader + ' ' + prompt + ': ' + this.baseLabel;
@@ -2563,7 +2576,7 @@ export default class Datatable extends LightningElement {
25632576
if (this.isConfigMode) {
25642577
this.updateLabelParam();
25652578
}
2566-
2579+
25672580
this.filterColumnData(); // v4.3.3 promise/resolve clears selected rows
25682581
// this.isWorking = true;
25692582
// new Promise((resolve, reject) => {
@@ -2576,8 +2589,9 @@ export default class Datatable extends LightningElement {
25762589
// () => this.isWorking = false
25772590
// );
25782591

2579-
this.filterColumns[this.columnNumber].actions.find(a => a.name == 'clear_'+this.columnNumber).disabled = true;
2580-
if (this.sortedBy != undefined) {
2592+
let actionColRef = this.columnNumber-this.rowActionColumnOffset; // *** v4.3.6 fix ***
2593+
this.filterColumns[this.columnNumber].actions.find(a => a.name == 'clear_'+actionColRef).disabled = true;
2594+
if (this.sortedBy) {
25812595
this.doSort(this.sortedBy, this.sortDirection); // Re-Sort the data
25822596
}
25832597
break;
@@ -2769,6 +2783,7 @@ export default class Datatable extends LightningElement {
27692783
}
27702784
}
27712785
this.columnFilterValues[this.columnNumber] = this.columnFilterValue;
2786+
27722787
// Force a redisplay of the datatable with the filter value shown in the column header
27732788
this.columns = [...this.filterColumns];
27742789
}
@@ -2794,9 +2809,11 @@ export default class Datatable extends LightningElement {
27942809
const rows = [...this._savePreEditData];
27952810
const cols = this.columnFilterValues;
27962811
let filteredRows = [];
2812+
let colCount = cols.length;
27972813
rows.forEach(row => {
27982814
let match = true;
2799-
for (let col = 0; col < cols.length; col++) {
2815+
for (let col = this.rowActionColumnOffset; col < colCount; col++) {
2816+
let actionColRef = col-this.rowActionColumnOffset; // *** v4.3.6 fix ***
28002817
let fieldName = this.filterColumns[col].fieldName;
28012818
if (fieldName.endsWith('_lookup')) {
28022819
fieldName = fieldName.slice(0,fieldName.lastIndexOf('_lookup')) + '_name';
@@ -2818,20 +2835,20 @@ export default class Datatable extends LightningElement {
28182835
break;
28192836
}
28202837
break;
2821-
case 'date-local':
2822-
let dl = row[fieldName];
2823-
let dtf = new Intl.DateTimeFormat('en', {
2824-
year: 'numeric',
2825-
month: '2-digit',
2826-
day: '2-digit'
2827-
});
2828-
const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dl);
2829-
let formatedDate = `${ye}-${mo}-${da}`;
2830-
if (formatedDate != this.columnFilterValues[col]) { // Check for date match on date & time fields
2831-
match = false;
2832-
break;
2833-
}
2834-
break;
2838+
case 'date-local': // v4.3.6 - Handle like regular date due to changes made in v4.3.5
2839+
// let dl = row[fieldName];
2840+
// let dtf = new Intl.DateTimeFormat('en', {
2841+
// year: 'numeric',
2842+
// month: '2-digit',
2843+
// day: '2-digit'
2844+
// });
2845+
// const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dl);
2846+
// let formatedDate = `${ye}-${mo}-${da}`;
2847+
// if (formatedDate != this.columnFilterValues[col]) { // Check for date match on date & time fields
2848+
// match = false;
2849+
// break;
2850+
// }
2851+
// break;
28352852
case 'date':
28362853
case 'datetime':
28372854
case 'time':
@@ -2862,10 +2879,10 @@ export default class Datatable extends LightningElement {
28622879
}
28632880
}
28642881
this.isFiltered = true;
2865-
this.filterColumns[col].actions.find(a => a.name == 'clear_'+col).disabled = false;
2882+
this.filterColumns[col].actions.find(a => a.name == 'clear_'+actionColRef).disabled = false;
28662883
} else {
28672884
if (this.filterColumns[col].actions && this.filterColumns[col].actions != null) { // *** v4.2.1 fix ***
2868-
this.filterColumns[col].actions.find(a => a.name == 'clear_'+col).disabled = true;
2885+
this.filterColumns[col].actions.find(a => a.name == 'clear_'+actionColRef).disabled = true;
28692886
}
28702887
}
28712888
}
@@ -2901,9 +2918,11 @@ export default class Datatable extends LightningElement {
29012918
const rows = this._filteredData.length > 0 ? [...this._filteredData] : [...this._savePreEditData];
29022919
const cols = this.columns;
29032920
let filteredRows = [];
2921+
let colCount = cols.length;
29042922
rows.forEach(row => {
29052923
let match = false;
2906-
for (let col = 0; col < cols.length; col++) {
2924+
// for (let col = this.rowActionColumnOffset; col < colCount; col++) {
2925+
for (let col = 0; col < colCount; col++) {
29072926
let fieldName = cols[col].fieldName;
29082927
if (fieldName?.endsWith('_lookup')) {
29092928
fieldName = fieldName.slice(0,fieldName.lastIndexOf('_lookup')) + '_name';
@@ -2922,20 +2941,20 @@ export default class Datatable extends LightningElement {
29222941
break;
29232942
}
29242943
break;
2925-
case 'date-local':
2926-
let dl = row[fieldName];
2927-
let dtf = new Intl.DateTimeFormat('en', {
2928-
year: 'numeric',
2929-
month: '2-digit',
2930-
day: '2-digit'
2931-
});
2932-
const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dl);
2933-
let formatedDate = `${ye}-${mo}-${da}`;
2934-
if (formatedDate == searchTerm) { // Check for date match on date & time fields
2935-
match = true;
2936-
break;
2937-
}
2938-
break;
2944+
case 'date-local': // v4.3.6 - Handle like regular date due to changes made in v4.3.5
2945+
// let dl = row[fieldName]";
2946+
// let dtf = new Intl.DateTimeFormat('en', {
2947+
// year: 'numeric',
2948+
// month: '2-digit',
2949+
// day: '2-digit'
2950+
// });
2951+
// const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dl);
2952+
// let formatedDate = `${ye}-${mo}-${da}`;
2953+
// if (formatedDate == searchTerm) { // Check for date match on date & time fields
2954+
// match = true;
2955+
// break;
2956+
// }
2957+
// break;
29392958
case 'date':
29402959
case 'datetime':
29412960
case 'time':
@@ -2950,7 +2969,7 @@ export default class Datatable extends LightningElement {
29502969
break;
29512970
default:
29522971
let fieldValue = row[fieldName].toString();
2953-
let filterValue = searchTerm?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // v4.3.5 escape special characters
2972+
let filterValue = searchTerm?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // v4.3.5 escape special characters
29542973
if (!this.matchCaseOnFilters) {
29552974
fieldValue = fieldValue.toLowerCase();
29562975
filterValue = filterValue.toLowerCase();

flow_screen_components/datatable/force-app/main/default/lwc/ers_datatableCPE/ers_datatableCPE.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,9 @@ export default class ers_datatableCPE extends LightningElement {
10021002
if ((curInputParam.name == 'rowActionButtonIcon') && this.inputValues.rowActionDisplay.value == 'Button') {
10031003
this.inputValues.rowActionButtonIcon.value = "";
10041004
}
1005+
if ((curInputParam.name == 'rowActionDisplay') && curInputParam.value == 'Button') {
1006+
this.inputValues.rowActionButtonIcon.value = "";
1007+
}
10051008

10061009
// Handle Wizard Attributes
10071010
let wizName = defaults.wizardAttributePrefix + curInputParam.name;
@@ -1062,6 +1065,9 @@ export default class ers_datatableCPE extends LightningElement {
10621065
if (this.inputValues.maxRemovedRows.value == null) {
10631066
this.inputValues.maxRemovedRows.value = 0;
10641067
}
1068+
if (this.inputValues.rowActionDisplay.value == 'Button') {
1069+
this.inputValues.rowActionButtonIcon.value = "";
1070+
}
10651071
}
10661072

10671073
updateActionDefaults(actionType) {

flow_screen_components/datatable/force-app/main/default/lwc/ers_datatableUtils/ers_datatableUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ console.log("DATATABLE: isCommunity, isFlowBuilder:", isCommunity, isFlowBuilder
3939

4040
const getConstants = () => {
4141
return {
42-
VERSION_NUMBER : '4.3.5', // Current Source Code Version #
42+
VERSION_NUMBER : '4.3.6', // Current Source Code Version #
4343
MAXROWCOUNT : 2000, // Limit the total number of records to be handled by this component
4444
ROUNDWIDTH : 5, // Used to round off the column widths during Config Mode to nearest value
4545
WIZROWCOUNT : 6, // Number of records to display in the Column Wizard datatable

0 commit comments

Comments
 (0)