Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This configures your org to essentially allow applications to run that call out

---
## Release Notes
10/14/20 - Eric Smith - Version 2.47 -
09/22/20 - Eric Smith - Version 2.47 -
Bug Fix: Display correct icon for Table Header (was always showing standard:account icon)

10/07/20 - Eric Smith - Version 2.46 -
Expand Down
9 changes: 7 additions & 2 deletions force-app/main/default/classes/SObjectController2.cls
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public with sharing class SObjectController2 {
Map<String, String> objNameFieldMap;
Map<String, Map<String,String>> picklistFieldMap; // Field API Name, <Picklist Value, Picklist Label>
List<String> percentFieldList;
List<String> numberFieldList;
List<String> noEditFieldList;
list<String> timeFieldList;
list<String> picklistFieldList;
Expand All @@ -78,6 +79,7 @@ public with sharing class SObjectController2 {
curRR.lookupFieldData = '{}';
curRR.lookupFieldList = emptyList;
curRR.percentFieldList = emptyList;
curRR.numberFieldList = emptyList;
curRR.noEditFieldList = emptyList;
curRR.timeFieldList = emptyList;
curRR.picklistFieldList = emptyList;
Expand All @@ -88,7 +90,7 @@ public with sharing class SObjectController2 {
String objName = records[0].getSObjectType().getDescribe().getName();
curRR = getColumnData(curRR, fieldNames, objName);
curRR = getLookupData(curRR, records, curRR.lookupFieldList, objName);
curRR = getRowData(curRR, records, curRR.dataMap, curRR.objNameFieldMap, curRR.lookupFieldList, curRR.percentFieldList, objName, curRR.noEditFieldList);
curRR = getRowData(curRR, records, curRR.dataMap, curRR.objNameFieldMap, curRR.lookupFieldList, curRR.percentFieldList, curRR.numberFieldList, objName, curRR.noEditFieldList);
curRR.objectName = objName;
}
curRR.timezoneOffset = getTimezoneOffset().format();
Expand All @@ -111,6 +113,7 @@ public with sharing class SObjectController2 {
String lookupFieldData = '';
List<String> lookupFields = new List<String>();
List<String> percentFields = new List<String>();
List<String> numberFields = new List<String>();
List<String> noEditFields = new List<String>();
List<String> timeFields = new List<String>();
List<String> picklistFields = new List<String>();
Expand Down Expand Up @@ -162,6 +165,7 @@ public with sharing class SObjectController2 {
}
}
when 'CURRENCY', 'DECIMAL', 'DOUBLE', 'INTEGER', 'LONG' {
numberFields.add(fieldName);
// *** create scale attrib in datatableColumnFieldDescriptor and pass the getScale() values in that way. ***
}
when 'TIME' {
Expand All @@ -188,6 +192,7 @@ public with sharing class SObjectController2 {
curRR.lookupFieldData = lookupFieldData;
curRR.lookupFieldList = lookupFields;
curRR.percentFieldList = percentFields;
curRR.numberFieldList = numberFields;
curRR.noEditFieldList = noEditFields;
curRR.timeFieldList = timeFields;
curRR.picklistFieldList = picklistFields;
Expand Down Expand Up @@ -236,7 +241,7 @@ public with sharing class SObjectController2 {
}

@AuraEnabled
public static ReturnResults getRowData(ReturnResults curRR, List<SObject> records, Map<String, Map<Id, SObject>> dataMap, Map<String, String> objNameFieldMap, List<String> lookupFields, List<String> percentFields, String objName, List<String> noEditFields) {
public static ReturnResults getRowData(ReturnResults curRR, List<SObject> records, Map<String, Map<Id, SObject>> dataMap, Map<String, String> objNameFieldMap, List<String> lookupFields, List<String> percentFields, List<String> numberFields, String objName, List<String> noEditFields) {
// Update object to include values for the "Name" field referenced by Lookup fields
String lookupFieldData = '';
Map<String,Boolean> firstRecord = new Map<String,Boolean>();
Expand Down
47 changes: 44 additions & 3 deletions force-app/main/default/lwc/datatableV2/datatableV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export default class DatatableV2 extends LightningElement {
@api lookupFieldArray = [];
@api columnArray = [];
@api percentFieldArray = [];
@api numberFieldArray = [];
@api noEditFieldArray = [];
@api timeFieldArray = [];
@api picklistFieldArray = [];
Expand Down Expand Up @@ -183,6 +184,8 @@ export default class DatatableV2 extends LightningElement {

connectedCallback() {

console.log('outputSelectedRows: ', this.outputSelectedRows);

console.log("VERSION_NUMBER", VERSION_NUMBER);

// JSON input attributes
Expand All @@ -199,6 +202,7 @@ export default class DatatableV2 extends LightningElement {
this.preSelectedRows = (this.preSelectedRowsString.length > 0) ? JSON.parse(this.preSelectedRowsString) : [];
}


// Restrict the number of records handled by this component
let min = Math.min(MAXROWCOUNT, this.maxNumberOfRows);
if (this.tableData.length > min) {
Expand All @@ -208,6 +212,8 @@ export default class DatatableV2 extends LightningElement {
// Set roundValue for setting Column Widths in Config Mode
this.roundValueLabel = "Round to Nearest " + ROUNDWIDTH;



// Get array of column field API names
this.columnArray = (this.columnFields.length > 0) ? this.columnFields.replace(/\s/g, '').split(',') : [];
this.columnFieldParameter = this.columnArray.join(', ');
Expand All @@ -225,6 +231,7 @@ export default class DatatableV2 extends LightningElement {
})
}


// Parse Column Alignment attribute
const parseAlignments = (this.columnAlignments.length > 0) ? this.columnAlignments.replace(/\s/g, '').split(',') : [];
this.attribCount = (parseAlignments.findIndex(f => f.search(':') != -1) != -1) ? 0 : 1;
Expand Down Expand Up @@ -277,6 +284,7 @@ export default class DatatableV2 extends LightningElement {
this.filterAttribType = 'all';
}


// Parse Column Icon attribute
const parseIcons = (this.columnIcons.length > 0) ? this.columnIcons.replace(/\s/g, '').split(',') : [];
this.attribCount = (parseIcons.findIndex(f => f.search(':') != -1) != -1) ? 0 : 1;
Expand All @@ -297,6 +305,7 @@ export default class DatatableV2 extends LightningElement {
});
});


if (this.isUserDefinedObject) {

// JSON Version - Parse Column Scale attribute
Expand All @@ -323,6 +332,7 @@ export default class DatatableV2 extends LightningElement {
});
}


// Parse Column Width attribute
const parseWidths = (this.columnWidths.length > 0) ? this.columnWidths.replace(/\s/g, '').split(',') : [];
this.attribCount = (parseWidths.findIndex(f => f.search(':') != -1) != -1) ? 0 : 1;
Expand All @@ -343,6 +353,7 @@ export default class DatatableV2 extends LightningElement {
});
});


// Parse Column Other Attributes attribute (Because multiple attributes use , these are separated by ;)
const parseOtherAttribs = (this.columnOtherAttribs.length > 0) ? this.removeSpaces(this.columnOtherAttribs).split(';') : [];
this.attribCount = 0; // These attributes must specify a column number or field API name
Expand All @@ -363,6 +374,7 @@ export default class DatatableV2 extends LightningElement {
});
});


// Set table height
this.tableHeight = 'height:' + this.tableHeight;
console.log('tableHeight',this.tableHeight);
Expand Down Expand Up @@ -444,7 +456,11 @@ export default class DatatableV2 extends LightningElement {
case 'percent':
this.percentFieldArray.push(this.basicColumns[t.column].fieldName);
this.basicColumns[t.column].type = 'percent';
break;
break;
case 'number':
this.numberFieldArray.push(this.basicColumns[t.column].fieldName);
this.basicColumns[t.column].type = 'number';
break;
case 'time':
this.timeFieldArray.push(this.basicColumns[t.column].fieldName);
this.basicColumns[t.column].type = 'time';
Expand All @@ -457,7 +473,9 @@ export default class DatatableV2 extends LightningElement {
case 'richtext':
this.lookupFieldArray.push(this.basicColumns[t.column].fieldName);
this.lookups.push(this.basicColumns[t.column].fieldName);
this.basicColumns[t.column].type = 'richtext';
this.basicColumns[t.column].type = 'richtext';
break;

}
});

Expand Down Expand Up @@ -488,6 +506,7 @@ export default class DatatableV2 extends LightningElement {
// Assign return results from the Apex callout
this.recordData = [...returnResults.rowData];
this.lookups = returnResults.lookupFieldList;
this.numberFieldArray = (returnResults.numberFieldList.length > 0) ? returnResults.numberFieldList.toString().split(',') : [];
this.percentFieldArray = (returnResults.percentFieldList.length > 0) ? returnResults.percentFieldList.toString().split(',') : [];
this.timeFieldArray = (returnResults.timeFieldList.length > 0) ? returnResults.timeFieldList.toString().split(',') : [];
this.picklistFieldArray = (returnResults.picklistFieldList.length > 0) ? returnResults.picklistFieldList.toString().split(',') : [];
Expand All @@ -496,6 +515,7 @@ export default class DatatableV2 extends LightningElement {
this.objectName = returnResults.objectName;
this.objectLinkField = returnResults.objectLinkField;
this.lookupFieldArray = JSON.parse('[' + returnResults.lookupFieldData + ']');

this.timezoneOffset = returnResults.timezoneOffset.replace(/,/g, '');

// Check for differences in picklist API Values vs Labels
Expand Down Expand Up @@ -545,12 +565,17 @@ export default class DatatableV2 extends LightningElement {
let lookupFields = this.lookups;
let lufield = '';
let timeFields = this.timeFieldArray;
let numberFields = this.numberFieldArray;
let percentFields = this.percentFieldArray;
let picklistFields = this.picklistFieldArray;
let lookupFieldObject = '';

data.forEach(record => {

numberFields.forEach(nb => {
record[nb] = parseFloat(record[nb]);
})

// Prepend a date to the Time field so it can be displayed and calculate offset based on User's timezone
timeFields.forEach(time => {
if (record[time]) {
Expand All @@ -563,7 +588,8 @@ export default class DatatableV2 extends LightningElement {

// Store percent field data as value/100
percentFields.forEach(pct => {
record[pct] = record[pct]/100;
record[pct] = parseFloat(record[pct]);
console.log('PCT:' + typeof(record[pct]) + ' - NB:' + pct + ' - record NB:' + record[pct]);
});

// Flatten returned data
Expand Down Expand Up @@ -952,6 +978,19 @@ export default class DatatableV2 extends LightningElement {
});
this.outputEditedRows = [...otherEditedRows];
}

// Correct the data formatting, so that decimal numbers are recognized no matter the Country-related decimal-format
let field = eitem
let numberFields = this.numberFieldArray;
numberFields.forEach(nb => {
field[nb] = parseFloat(field[nb]);
});
let pctfield = this.percentFieldArray;
pctfield.forEach(pct => {
console.log('PCTCPCTCPCZC', field[pct]);
field[pct] = parseFloat(field[pct]);
});

this.outputEditedRows = [...this.outputEditedRows,eitem]; // Add to output attribute collection
if (this.isUserDefinedObject) {
this.outputEditedRowsString = JSON.stringify(this.outputEditedRows); //JSON Version
Expand Down Expand Up @@ -1189,6 +1228,8 @@ export default class DatatableV2 extends LightningElement {
case 'percent':
// return 'percent-fixed'; // This would be to enter 35 to get 35% (0.35)
return 'percent';
case 'number':
return 'number';
default:
return null;
}
Expand Down