From cbe2e6906bd85eed2bb67becbc193ca6a34aaef3 Mon Sep 17 00:00:00 2001 From: tschug Date: Mon, 6 Nov 2023 21:30:49 -0500 Subject: [PATCH 1/7] Stable version multiple-extension matching --- force-app/main/default/classes/Cmdt.cls | 1 + .../default/classes/IndicatorController.cls | 4 + .../lwc/indicatorBundle/indicatorBundle.js | 137 ++++++++++-------- .../fields/Display_Multiple__c.field-meta.xml | 10 ++ 4 files changed, 94 insertions(+), 58 deletions(-) create mode 100644 force-app/main/default/objects/Indicator_Item__mdt/fields/Display_Multiple__c.field-meta.xml diff --git a/force-app/main/default/classes/Cmdt.cls b/force-app/main/default/classes/Cmdt.cls index 5d2d7ac..1bf3b4f 100644 --- a/force-app/main/default/classes/Cmdt.cls +++ b/force-app/main/default/classes/Cmdt.cls @@ -15,6 +15,7 @@ public with sharing class Cmdt { Active__c, Advanced_Field__c, Advanced_Field_Label__c, + Display_Multiple__c, Empty_Static_Text_Behavior__c, Field__c, Field__r.QualifiedApiName, Hover_Text__c, diff --git a/force-app/main/default/classes/IndicatorController.cls b/force-app/main/default/classes/IndicatorController.cls index 2567d25..2b6646c 100644 --- a/force-app/main/default/classes/IndicatorController.cls +++ b/force-app/main/default/classes/IndicatorController.cls @@ -42,6 +42,8 @@ public with sharing class IndicatorController { public class IndicatorItem { @AuraEnabled public Boolean IsActive {get; set;} + @AuraEnabled + public Boolean DisplayMultiple {get; set;} @AuraEnabled public String FieldLabel { get; set;} @AuraEnabled @@ -188,6 +190,7 @@ public with sharing class IndicatorController { } item.IsActive = indicatorItem.Active__c; + item.DisplayMultiple = indicatorItem.Display_Multiple__c; item.IconName = indicatorItem.Icon_Value__c; item.TextValue = indicatorItem.Static_Text__c; item.EmptyStaticBehavior = indicatorItem.Empty_Static_Text_Behavior__c; @@ -284,6 +287,7 @@ public with sharing class IndicatorController { } item.IsActive = indicatorItem.Active__c; + item.DisplayMultiple = indicatorItem.Display_Multiple__c; item.IconName = indicatorItem.Icon_Value__c; item.TextValue = indicatorItem.Static_Text__c; item.EmptyStaticBehavior = indicatorItem.Empty_Static_Text_Behavior__c; diff --git a/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js b/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js index 72f4b31..873fb5e 100644 --- a/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js +++ b/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js @@ -176,6 +176,7 @@ export default class IndicatorBundle extends LightningElement { this.bundle.Items.forEach( item => { + let anyMatch = false; if(item.IsActive){ // console.dir(item); // Retain for debug purposes @@ -249,6 +250,23 @@ export default class IndicatorBundle extends LightningElement { "IconForeground" : extension.ForegroundColor }; + if(item.DisplayMultiple){ + anyMatch = true; + matchingFields.push( + { + fName: item.FieldApiName, + fTextValue: dataValue, + fImageURL: matchedExtension.ImageUrl, + fHoverValue: (matchedExtension && matchedExtension.HoverValue) ? matchedExtension.HoverValue : assignedHoverValue, + fShowAvatar: true, + fIconName : matchedExtension.IconName, + fIconBackground : matchedExtension.IconBackground, + fIconForeground : matchedExtension.IconForeground, + fTextShown: matchedExtension.TextValue + } + ); + } + // console.dir(matchedExtension); } } // End-If extension.IsActive @@ -257,69 +275,72 @@ export default class IndicatorBundle extends LightningElement { ) } - - matchingFields.push( - { - fName: item.FieldApiName, // Retain for debug purposes - fTextValue: dataValue, // Retain for debug purposes - ...dataValue || dataValue === 0 ? { - fImageURL: matchedExtension ? matchedExtension.ImageUrl : item.ImageUrl - } : { - fImageURL: item.DisplayFalse ? item.FalseImageUrl : '' - }, - // ! If value is false, the false hover will be set. - ...dataValue || dataValue === 0 ? { - fHoverValue: (matchedExtension && matchedExtension.HoverValue) ? matchedExtension.HoverValue : assignedHoverValue - } : { - fHoverValue: item.DisplayFalse ? item.FalseHoverValue : '' - }, - //If False Icon is not entered AND the boolean value is False or text value is empty, then do not display the Avatar - ...dataValue || dataValue === 0 ? { - fShowAvatar : matchedExtension ? true : showDefault - } : { - fShowAvatar: item.DisplayFalse - }, - //If the value is false, the false icon will be set. - ...dataValue || dataValue === 0 ? { - fIconName : matchedExtension ? matchedExtension.IconName : item.IconName - } : { - fIconName: item.DisplayFalse ? item.FalseIcon : '' - }, - ...dataValue || dataValue === 0 ? { - fIconBackground : matchedExtension ? matchedExtension.IconBackground : item.BackgroundColor - } : { - fIconBackground: item.DisplayFalse? item.InverseBackgroundColor : item.BackgroundColor - }, - ...dataValue || dataValue === 0 ? { - fIconForeground : matchedExtension ? matchedExtension.IconForeground : item.ForegroundColor - } : { - fIconForeground: item.DisplayFalse? item.InverseForegroundColor : item.ForegroundColor - }, - //If the False Icon and False Text is entered and the Boolean is False or text value is empty, then set the False Text - //If the Icon Text is entered then show that - //If no Icon Text is entered if the field is a Boolean then show the icon otherwise show the field value - ...dataValue || dataValue === 0 ? { - ...matchedExtension ? { - fTextShown: matchedExtension.TextValue + + if (anyMatch != true || item.DisplayMultiple != true) { + + matchingFields.push( + { + fName: item.FieldApiName, // Retain for debug purposes + fTextValue: dataValue, // Retain for debug purposes + ...dataValue || dataValue === 0 ? { + fImageURL: matchedExtension ? matchedExtension.ImageUrl : item.ImageUrl + } : { + fImageURL: item.DisplayFalse ? item.FalseImageUrl : '' + }, + // ! If value is false, the false hover will be set. + ...dataValue || dataValue === 0 ? { + fHoverValue: (matchedExtension && matchedExtension.HoverValue) ? matchedExtension.HoverValue : assignedHoverValue + } : { + fHoverValue: item.DisplayFalse ? item.FalseHoverValue : '' + }, + //If False Icon is not entered AND the boolean value is False or text value is empty, then do not display the Avatar + ...dataValue || dataValue === 0 ? { + fShowAvatar : matchedExtension ? true : showDefault + } : { + fShowAvatar: item.DisplayFalse + }, + //If the value is false, the false icon will be set. + ...dataValue || dataValue === 0 ? { + fIconName : matchedExtension ? matchedExtension.IconName : item.IconName + } : { + fIconName: item.DisplayFalse ? item.FalseIcon : '' + }, + ...dataValue || dataValue === 0 ? { + fIconBackground : matchedExtension ? matchedExtension.IconBackground : item.BackgroundColor } : { - ...dataValue && item.TextValue ? { - fTextShown : item.TextValue + fIconBackground: item.DisplayFalse? item.InverseBackgroundColor : item.BackgroundColor + }, + ...dataValue || dataValue === 0 ? { + fIconForeground : matchedExtension ? matchedExtension.IconForeground : item.ForegroundColor + } : { + fIconForeground: item.DisplayFalse? item.InverseForegroundColor : item.ForegroundColor + }, + //If the False Icon and False Text is entered and the Boolean is False or text value is empty, then set the False Text + //If the Icon Text is entered then show that + //If no Icon Text is entered if the field is a Boolean then show the icon otherwise show the field value + ...dataValue || dataValue === 0 ? { + ...matchedExtension ? { + fTextShown: matchedExtension.TextValue } : { - ...item.EmptyStaticBehavior === 'Use Icon Only' ? { - fTextShown : '' - } : { - fTextShown : typeof(dataValue) === 'boolean' ? '' : String(dataValue).toUpperCase().substring(0,3) - } + ...dataValue && item.TextValue ? { + fTextShown : item.TextValue + } : { + ...item.EmptyStaticBehavior === 'Use Icon Only' ? { + fTextShown : '' + } : { + fTextShown : typeof(dataValue) === 'boolean' ? '' : String(dataValue).toUpperCase().substring(0,3) + } + } } - } - } : { - ...(dataValue === false || dataValue === null || dataValue === '') && item.DisplayFalse ? { - fTextShown : item.FalseTextValue ? item.FalseTextValue : '' } : { - fTextShown : '' + ...(dataValue === false || dataValue === null || dataValue === '') && item.DisplayFalse ? { + fTextShown : item.FalseTextValue ? item.FalseTextValue : '' + } : { + fTextShown : '' + } } - } - }); + }); + } } // End-If item.IsActive }); this.results = matchingFields; diff --git a/force-app/main/default/objects/Indicator_Item__mdt/fields/Display_Multiple__c.field-meta.xml b/force-app/main/default/objects/Indicator_Item__mdt/fields/Display_Multiple__c.field-meta.xml new file mode 100644 index 0000000..acb9378 --- /dev/null +++ b/force-app/main/default/objects/Indicator_Item__mdt/fields/Display_Multiple__c.field-meta.xml @@ -0,0 +1,10 @@ + + + Display_Multiple__c + false + false + SubscriberControlled + Display multiple Extensions when matched, helpful with multi-select picklists. + + Checkbox + From 3d6da8bf0d59b17a35cfbcd6c6a1f4b5f8b0defb Mon Sep 17 00:00:00 2001 From: JodieM Date: Wed, 8 Nov 2023 03:31:12 +0000 Subject: [PATCH 2/7] Layout --- .../Indicator_Item__mdt-Indicator Item Layout.layout-meta.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/force-app/main/default/layouts/Indicator_Item__mdt-Indicator Item Layout.layout-meta.xml b/force-app/main/default/layouts/Indicator_Item__mdt-Indicator Item Layout.layout-meta.xml index 5658203..736f6e3 100644 --- a/force-app/main/default/layouts/Indicator_Item__mdt-Indicator Item Layout.layout-meta.xml +++ b/force-app/main/default/layouts/Indicator_Item__mdt-Indicator Item Layout.layout-meta.xml @@ -138,6 +138,10 @@ Edit Inverse_Icon_Foreground__c + + Edit + Display_Multiple__c + From 46b89e876657857c3846293cba6087869f07105b Mon Sep 17 00:00:00 2001 From: tschug Date: Sun, 7 Jan 2024 20:16:22 -0500 Subject: [PATCH 3/7] Reflected branch with update from Main to reflect fixes from another merge --- .../lwc/indicatorBundle/indicatorBundle.js | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js b/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js index 873fb5e..086a84f 100644 --- a/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js +++ b/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js @@ -107,7 +107,7 @@ export default class IndicatorBundle extends LightningElement { this.hasHeader = true; } - if(this.bundle.CardIconBackground || this.bundle.CardIconCoreground ){ + if(this.bundle.CardIconBackground || this.bundle.CardIconForeground ){ this.card.iconClass = 'cardIcon slds-var-m-right_xx-small '; } else { this.card.iconClass = 'slds-var-m-right_xx-small '; @@ -211,13 +211,24 @@ export default class IndicatorBundle extends LightningElement { if(extension.IsActive){ let match = false; - let stringValue = JSON.stringify(dataValue); // If the extension uses a String search, check if there is a match if(extension.ContainsText) { // console.log('Value',dataValue + ' ' + extension.ContainsText); // Retain for debug purposes - if(stringValue.includes(extension.ContainsText)){ - match = true; + let fieldValue = dataValue.toLowerCase(); + let compareValue = extension.ContainsText.toLowerCase(); + + // console.log('Value',dataValue + ' ' + extension.TextOperator + ' ' + compareValue); // Retain for debug purposes + if(extension.TextOperator === 'Contains'){ + match = fieldValue.includes(compareValue); + } else if (extension.TextOperator === 'Does Not Equal') { + match = fieldValue != compareValue; + } else if (extension.TextOperator === 'Equals') { + match = fieldValue === compareValue; + } else if (extension.TextOperator === 'Starts With'){ + match = fieldValue.startsWith(compareValue); + } else { + match = fieldValue.includes(compareValue); } } // Else if the extension uses a Minimum boundary @@ -239,7 +250,7 @@ export default class IndicatorBundle extends LightningElement { // console.log('Match Status', match); // Retain for debug purposes if(match) { - // If there is a match for an Extension, assign the extension's override values + // If there is a match for an Extension, assign the extension's override values and these will be used later matchedExtension = { "IconName" : extension.ExtensionIconValue, "TextValue" : extension.ExtensionTextValue, @@ -250,6 +261,7 @@ export default class IndicatorBundle extends LightningElement { "IconForeground" : extension.ForegroundColor }; + // However, if multiple matching is enabled, immediately assign the Extension for use in the Bundle. if(item.DisplayMultiple){ anyMatch = true; matchingFields.push( @@ -276,6 +288,9 @@ export default class IndicatorBundle extends LightningElement { } + // If multiple matching is enabled and did not find a single match + // or if multiple matching is not enabled + // proceed to assign the indicator properties based on Indicator Item values if (anyMatch != true || item.DisplayMultiple != true) { matchingFields.push( @@ -320,10 +335,10 @@ export default class IndicatorBundle extends LightningElement { //If no Icon Text is entered if the field is a Boolean then show the icon otherwise show the field value ...dataValue || dataValue === 0 ? { ...matchedExtension ? { - fTextShown: matchedExtension.TextValue + fTextShown: matchedExtension.TextValue ? matchedExtension.TextValue.toUpperCase().substring(0,3) : '' } : { ...dataValue && item.TextValue ? { - fTextShown : item.TextValue + fTextShown : item.TextValueitem.TextValue.toUpperCase().substring(0,3) } : { ...item.EmptyStaticBehavior === 'Use Icon Only' ? { fTextShown : '' @@ -334,7 +349,7 @@ export default class IndicatorBundle extends LightningElement { } } : { ...(dataValue === false || dataValue === null || dataValue === '') && item.DisplayFalse ? { - fTextShown : item.FalseTextValue ? item.FalseTextValue : '' + fTextShown : item.FalseTextValue ? item.FalseTextValue.toUpperCase().substring(0,3) : '' } : { fTextShown : '' } From 56eb58704b55410adab7d3e7116cfc076b618c56 Mon Sep 17 00:00:00 2001 From: tschug Date: Sun, 7 Jan 2024 22:03:07 -0500 Subject: [PATCH 4/7] Fix bug from merge. --- force-app/main/default/lwc/indicatorBundle/indicatorBundle.js | 1 - 1 file changed, 1 deletion(-) diff --git a/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js b/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js index 5e0f42f..2bb92c5 100644 --- a/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js +++ b/force-app/main/default/lwc/indicatorBundle/indicatorBundle.js @@ -107,7 +107,6 @@ export default class IndicatorBundle extends LightningElement { this.hasHeader = true; } - if(this.bundle.CardIconBackground || this.bundle.CardIconForeground ){ if(this.bundle.CardIconBackground || this.bundle.CardIconForeground ){ this.card.iconClass = 'cardIcon slds-var-m-right_xx-small '; } else { From 63d29c488621462fecbcc151eaf33da07c5f4b48 Mon Sep 17 00:00:00 2001 From: tschug Date: Sun, 7 Jan 2024 23:53:07 -0500 Subject: [PATCH 5/7] Added help text to key for Display Multiple --- force-app/main/default/lwc/key/key.html | 11 ++++++++++- force-app/main/default/lwc/key/key.js | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/force-app/main/default/lwc/key/key.html b/force-app/main/default/lwc/key/key.html index a56a534..ee1ae93 100644 --- a/force-app/main/default/lwc/key/key.html +++ b/force-app/main/default/lwc/key/key.html @@ -198,7 +198,16 @@

Item is not active. No indicators will be shown, even if they are active. - Display Criteria + Display Criteria +