diff --git a/.pmdruleset.xml b/.pmdruleset.xml
index c293e4b5..21217767 100644
--- a/.pmdruleset.xml
+++ b/.pmdruleset.xml
@@ -1,470 +1,222 @@
-
- Time Warp configuration of PMD for Apex.
+ Quickstart configuration of PMD for Salesforce.com Apex. Includes the rules that are most likely to apply everywhere.
3
-
-
-
-
3
-
-
-
-
-
+
3
-
-
-
-
3
-
-
-
-
3
-
-
-
-
-
+
3
-
-
-
-
3
-
-
-
-
3
-
-
-
-
3
-
-
-
-
-
-
-
+
+ 3
+
+
+
+
+
+
+ 3
+
+
+
+
+
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
-
-
-
-
-
-
3
-
-
-
-
-
-
+
+
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
-
-
-
+
+
+
+
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
3
-
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/force-app/main/default/classes/TimelineService.cls b/force-app/main/default/classes/TimelineService.cls
index d460cdbe..28dcbdb0 100644
--- a/force-app/main/default/classes/TimelineService.cls
+++ b/force-app/main/default/classes/TimelineService.cls
@@ -110,6 +110,8 @@ public with sharing class TimelineService {
'Active__c, ' +
'Icon__c, ' +
'Icon_Background_Colour__c, ' +
+ 'Icon_Field__c, ' +
+ 'Icon_Background_Colour_Field__c, ' +
'Position_Date_Field__c, ' +
'Object_Name__c, ' +
'Type_Field__c, ' +
@@ -136,13 +138,14 @@ public with sharing class TimelineService {
}
Map mapOfTimelineConfigurationRecords = new Map();
- Map mapOfFields = new Map();
for (Timeline_Configuration__mdt timelineConfigurationRecord : listOfTimelineConfigurations) {
TimelineRecord timelineRecord = new timelineRecord();
timelineRecord.relationshipName = timelineConfigurationRecord.Relationship_Name__c;
timelineRecord.icon = timelineConfigurationRecord.Icon__c;
timelineRecord.iconBackground = timelineConfigurationRecord.Icon_Background_Colour__c;
+ timelineRecord.iconField = timelineConfigurationRecord.Icon_Field__c;
+ timelineRecord.iconBackgroundField = timelineConfigurationRecord.Icon_Background_Colour_Field__c;
timelineRecord.detailField = timelineConfigurationRecord.Detail_Field__c;
timelineRecord.objectName = timelineConfigurationRecord.Object_Name__c;
timelineRecord.type = timelineConfigurationRecord.Type_Field__c;
@@ -152,17 +155,11 @@ public with sharing class TimelineService {
timelineRecord.tooltipObject = timelineConfigurationRecord.Tooltip_Object_Name__c;
timelineRecord.drilldownIdField = timelineConfigurationRecord.Drilldown_Id_Field__c;
timelineRecord.inclusionField = timelineConfigurationRecord.Inclusion_Field__c;
-
+
mapOfTimelineConfigurationRecords.put(
timelineRecord.objectName + timelineRecord.relationshipName,
timelineRecord
);
- mapOfFields.put(timelineRecord.detailField, timelineRecord.objectName);
- mapOfFields.put(timelineRecord.positionDateField, timelineRecord.objectName);
- mapOfFields.put(timelineRecord.fallbackTooltipField, timelineRecord.objectName);
- mapOfFields.put(timelineRecord.tooltipIdField, timelineRecord.objectName);
- mapOfFields.put(timelineRecord.drilldownIdField, timelineRecord.objectName);
- mapOfFields.put(timelineRecord.type, timelineRecord.objectName);
}
Map childObjects = getChildObjects(parentObjectType);
@@ -178,6 +175,8 @@ public with sharing class TimelineService {
String tooltipIdField = String.valueOf(tcr.tooltipIdField);
String drilldownIdField = String.valueOf(tcr.drilldownIdField);
String typeField = String.valueOf(tcr.type);
+ String iconField = String.valueOf(tcr.iconField);
+ String iconColourField = String.valueOf(tcr.iconBackgroundField);
String selectStatement = '(SELECT Id, ' + tcr.detailField + ', ' + tcr.positionDateField + '';
@@ -216,6 +215,14 @@ public with sharing class TimelineService {
selectStatement = selectStatement + ', ' + tcr.tooltipIdField + '';
}
+ if (iconField != null && iconField != '' ) {
+ selectStatement = selectStatement + ', ' + tcr.iconField + '';
+ }
+
+ if (iconColourField != null && iconColourField != '' ) {
+ selectStatement = selectStatement + ', ' + tcr.iconBackgroundField + '';
+ }
+
String relationship = tcr.relationshipName;
String optionalFilter = '';
@@ -310,6 +317,16 @@ public with sharing class TimelineService {
eachCh,
tr.objectName
);
+ Map iconValues = getFieldValues(
+ tr.iconField,
+ eachCh,
+ tr.objectName
+ );
+ Map iconColourValues = getFieldValues(
+ tr.iconBackgroundField,
+ eachCh,
+ tr.objectName
+ );
Map typeValues = getFieldValues(tr.type, eachCh, tr.objectName);
@@ -339,8 +356,20 @@ public with sharing class TimelineService {
mapData.put('tooltipObject', tr.tooltipObject);
mapData.put('fallbackTooltipValue', fallbackValues.get('value'));
mapData.put('type', typeValues.get('value'));
- mapData.put('icon', tr.icon);
- mapData.put('iconBackground', tr.iconBackground);
+
+ if (iconValues.get('value') != null && iconValues.get('value') != '') {
+ mapData.put('icon', iconValues.get('value'));
+ }
+ else {
+ mapData.put('icon', tr.icon);
+ }
+
+ if (iconColourValues.get('value') != null && iconColourValues.get('value') != '') {
+ mapData.put('iconBackground', iconColourValues.get('value'));
+ }
+ else {
+ mapData.put('iconBackground', tr.iconBackground);
+ }
if (positionValues.get('value') != null && positionValues.get('value') != '') {
listOfTimelineData.add(mapData);
@@ -393,7 +422,7 @@ public with sharing class TimelineService {
String fieldValue = '';
String fieldLabel = '';
String objectCheck = '';
- String fieldCheck = '';
+ //String fieldCheck = '';
String fieldStripped = '';
Boolean fieldCanAccess = true;
@@ -601,6 +630,8 @@ public with sharing class TimelineService {
private String detailFieldLabel;
private String icon;
private String iconBackground;
+ private String iconField;
+ private String iconBackgroundField;
private String positionDateField;
private String positionDateValue;
private String objectName;
diff --git a/force-app/main/default/layouts/Timeline_Configuration__mdt-Timeline Configuration Layout.layout-meta.xml b/force-app/main/default/layouts/Timeline_Configuration__mdt-Timeline Configuration Layout.layout-meta.xml
index 51ae0b82..1c5c90e6 100644
--- a/force-app/main/default/layouts/Timeline_Configuration__mdt-Timeline Configuration Layout.layout-meta.xml
+++ b/force-app/main/default/layouts/Timeline_Configuration__mdt-Timeline Configuration Layout.layout-meta.xml
@@ -77,12 +77,20 @@
Required
Icon__c
+
+ Edit
+ Icon_Field__c
+
Required
Icon_Background_Colour__c
+
+ Edit
+ Icon_Background_Colour_Field__c
+
@@ -167,7 +175,7 @@
false
false
- 00hN0000002I148
+ 00h8I000002GgBp
4
0
Default
diff --git a/force-app/main/default/lwc/timeline/timeline.js b/force-app/main/default/lwc/timeline/timeline.js
index e891a5b8..f646519d 100755
--- a/force-app/main/default/lwc/timeline/timeline.js
+++ b/force-app/main/default/lwc/timeline/timeline.js
@@ -42,8 +42,7 @@ export default class timeline extends NavigationMixin(LightningElement) {
@api latestRange; //How far into the future to go
@api zoomTo; //Zoom to current dat or latest activity
@api daysToShow; //number of days to plot for the default zoom
- @api showToday; //should today's date be plotted
- @api showTodayColour; //if today's date is shown - what colour
+ @api showToday; //should today's date be plotted and in what colour
//Component calculated attributes
@api recordId; //current record id of lead, case, opportunity, contact or account
@@ -99,7 +98,17 @@ export default class timeline extends NavigationMixin(LightningElement) {
illustrationSubHeader; //Sub Header to display when an info box appears
illustrationType; //Type of illustration to display, 'error' or 'no data'
- todaysColour;
+ todayColourMap = {
+ Blue: "#107cad",
+ Green: "#2e844a",
+ Black: "#444444",
+ Purple: "#9050e9",
+ Indigo: "#5867e8",
+ Teal: "#0b827c",
+ Pink: "#e3066a",
+ Red: "#ea001e",
+ No: "#107cad"
+ };
label = {
DAYS,
@@ -131,6 +140,14 @@ export default class timeline extends NavigationMixin(LightningElement) {
_timelineData = null;
_timelineHeight = null;
+ heightMap = {
+ "1 - Smallest": 125,
+ "2 - Small": 200,
+ "3 - Default": 275,
+ "4 - Big": 350,
+ "5 - Biggest": 425,
+ };
+
//These are the objects holding individual instances of the timeline
_d3timelineCanvas = null;
_d3timelineCanvasAxis = null;
@@ -210,7 +227,7 @@ export default class timeline extends NavigationMixin(LightningElement) {
}
connectedCallback() {
- this._timelineHeight = this.getPreferredHeight();
+ this._timelineHeight = this.heightMap[this.preferredHeight];
}
renderedCallback() {
@@ -223,7 +240,7 @@ export default class timeline extends NavigationMixin(LightningElement) {
}
if (!this._d3Rendered) {
- this.todaysColour = this.getTodaysColour();
+ this.todaysColour = this.todayColourMap[this.showToday];
//set the height of the component as the height is dynamic based on the attributes
let timelineDIV = this.template.querySelector('div.timeline-canvas');
this.currentParentField = this.timelineParent;
@@ -505,7 +522,7 @@ export default class timeline extends NavigationMixin(LightningElement) {
let currentDate = new Date();
- if ( this.showToday === "Yes" ) {
+ if ( this.showToday !== "No" ) {
let today = timelineCanvas.append('g')
.attr('class', 'timeline-canvas-current-date')
.attr('transform', 'translate(' + timelineCanvas.x(currentDate) + ')' );
@@ -874,69 +891,6 @@ export default class timeline extends NavigationMixin(LightningElement) {
}
}
- getTodaysColour() {
- let colour;
-
- switch (this.showTodayColour) {
- case "Blue":
- colour = "#107cad";
- break;
- case "Green":
- colour = "#2e844a";
- break;
- case "Black":
- colour = "#444444";
- break;
- case "Purple":
- colour = "#9050e9";
- break;
- case "Indigo":
- colour = "#5867e8";
- break;
- case "Teal":
- colour = "#0b827c";
- break;
- case "Pink":
- colour = "#e3066a";
- break;
- case "Red":
- colour = "#ea001e";
- break;
- default:
- colour = "#107cad";
- break;
- }
-
- return colour;
- }
-
- getPreferredHeight() {
- let height;
-
- switch (this.preferredHeight) {
- case '1 - Smallest':
- height = 125;
- break;
- case '2 - Small':
- height = 200;
- break;
- case '3 - Default':
- height = 275;
- break;
- case '4 - Big':
- height = 350;
- break;
- case '5 - Biggest':
- height = 425;
- break;
- default:
- height = 275;
- break;
- }
-
- return height;
- }
-
timelineMap() {
const me = this;
@@ -963,7 +917,7 @@ export default class timeline extends NavigationMixin(LightningElement) {
let currentDate = new Date();
- if ( this.showToday === "Yes" ) {
+ if ( this.showToday !== "No" ) {
let today = timelineMap.append('g')
.attr('class', 'timeline-map-current-date')
.attr('transform', 'translate(' + timelineMap.x(currentDate) + ')' );
diff --git a/force-app/main/default/lwc/timeline/timeline.js-meta.xml b/force-app/main/default/lwc/timeline/timeline.js-meta.xml
index a1f66aab..c80b452e 100755
--- a/force-app/main/default/lwc/timeline/timeline.js-meta.xml
+++ b/force-app/main/default/lwc/timeline/timeline.js-meta.xml
@@ -18,9 +18,7 @@
-
-
-
+
@@ -36,6 +34,7 @@
+
diff --git a/force-app/main/default/objects/Timeline_Configuration__mdt/fields/Icon_Background_Colour_Field__c.field-meta.xml b/force-app/main/default/objects/Timeline_Configuration__mdt/fields/Icon_Background_Colour_Field__c.field-meta.xml
new file mode 100644
index 00000000..28e714fe
--- /dev/null
+++ b/force-app/main/default/objects/Timeline_Configuration__mdt/fields/Icon_Background_Colour_Field__c.field-meta.xml
@@ -0,0 +1,12 @@
+
+
+ Icon_Background_Colour_Field__c
+ false
+ SubscriberControlled
+ The background colour for the icon based on a formula field allowing different colours
+
+ 180
+ false
+ Text
+ false
+
diff --git a/force-app/main/default/objects/Timeline_Configuration__mdt/fields/Icon_Field__c.field-meta.xml b/force-app/main/default/objects/Timeline_Configuration__mdt/fields/Icon_Field__c.field-meta.xml
new file mode 100644
index 00000000..fe020502
--- /dev/null
+++ b/force-app/main/default/objects/Timeline_Configuration__mdt/fields/Icon_Field__c.field-meta.xml
@@ -0,0 +1,12 @@
+
+
+ Icon_Field__c
+ false
+ SubscriberControlled
+ The icon to use based on a formula field allowing you to dynamically select an icon
+
+ 180
+ false
+ Text
+ false
+