Skip to content

Commit

Permalink
Merge pull request #1549 from StreckerCM/master
Browse files Browse the repository at this point in the history
Object And Field picklist updates
  • Loading branch information
alexed1 authored Sep 21, 2024
2 parents 401970d + c09df12 commit 3d6b3b5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<template>
<div class="field-picker">
<template if:true={isError}>
<div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme--error" role="alert">
<h2> {errorMessage} </h2>
<!-- Christopher Strecker 06/06/2024 - Added missing section for the master label -->
<div class="slds-grid">
<div class="slds-col slds-grow-none">
<label class="slds-form-element__legend slds-form-element__label">
<abbr class="slds-required" title="required">{requiredSymbol}</abbr>{masterLabel}</label>
</div>
</template>
<template if:true={isError}>
<div class="slds-col slds-notify slds-notify_alert slds-theme_alert-texture slds-theme--error" role="alert">
<h2> {errorMessage} </h2>
</div>
</template>
</div>
<template if:false={hideObjectPicklist}>
<lightning-combobox
name="objectTypeField"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ export default class fsc_pickObjectAndField extends LightningElement {
@api hideObjectPicklist = false;
@api hideFieldPicklist = false;
@api displayFieldType = false;
@api testproperty;
//@api testproperty; // Christopher Strecker 06/06/2024 - Removed this was not being used anywhere

@api allowFieldMultiselect = false;

@api required = false;

@track _objectType;
@track _fields;
@track _field;
@track objectTypes = standardObjectOptions;
@track fields;
Expand Down Expand Up @@ -61,6 +62,10 @@ export default class fsc_pickObjectAndField extends LightningElement {
return this._field;
}

get requiredSymbol() {
return this.required ? '*' : '';
}

set field(value) {
this._field = value;
this.fieldDataType = getDataType(value);
Expand Down Expand Up @@ -96,6 +101,36 @@ console.log("🚀 ~ file: fsc_pickObjectAndField.js ~ line 75 ~ fsc_pickObjectAn
} else if (data) {
let fields = data.fields;
let fieldResults = [];

// Christopher Strecker 06/06/2024 - Removed from for loop and updated to support multi select
if (this.fieldList && this.fieldList.length > 0) {

let foundFields = [];

let missingFields = [];

this.fieldList.forEach(fieldName => {

if(fieldName && !isReference(fieldName) && !Object.prototype.hasOwnProperty.call(fields, fieldName)) {
missingFields.push(fieldName)
} else {
foundFields.push(fieldName);
}

});

if(foundFields && foundFields.length > 0) {
this._field = foundFields.join(",");
} else {
this._field = null;
}

if(missingFields && missingFields.length > 0) {
this.errors.push(this.labels.fieldNotSupported + missingFields.join(","));
}

}

for (let field in this.fields = fields) {
if (Object.prototype.hasOwnProperty.call(fields, field)) {
if (this.isTypeSupported(fields[field]) && this.isFieldTypeSupported(fields[field])) {
Expand All @@ -111,10 +146,10 @@ console.log("🚀 ~ file: fsc_pickObjectAndField.js ~ line 75 ~ fsc_pickObjectAn
});
}
}
if (this._field && !isReference(this._field) && !Object.prototype.hasOwnProperty.call(fields, this._field)) {
this.errors.push(this.labels.fieldNotSupported + this._field);
this._field = null;
}
// if (this._field && !isReference(this._field) && !Object.prototype.hasOwnProperty.call(fields, this._field)) {
// this.errors.push(this.labels.fieldNotSupported + this._field);
// this._field = null;
// }
}
this.fields = fieldResults;
if (this.fields) {
Expand Down Expand Up @@ -171,6 +206,23 @@ console.log("🚀 ~ file: fsc_pickObjectAndField.js ~ line 75 ~ fsc_pickObjectAn
}
}

// Christopher Strecker 06/06/2024 - Added function to return this._field
// as a list in order to support multi select input
get fieldList() {

if (this._field) {

if(this.allowFieldMultiselect) {
return this.splitValues(this._field);
} else {
return [this._field];
}

}

return [];
}

get isError() {
return this.errors.length > 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>46.0</apiVersion>
<apiVersion>60.0</apiVersion>
<description>Pick Object And Field v3</description>
<isExposed>true</isExposed>
<masterLabel>Pick Object And Field v3</masterLabel>
Expand All @@ -22,7 +22,8 @@
<property name="required" type="Boolean" role="inputOnly"> </property>
<property name="hideFieldPicklist" type="Boolean" role="inputOnly"> </property>
<property name="displayFieldType" type="Boolean" role="inputOnly"> </property>
<property name="testproperty" type="String" role="inputOnly"> </property>
<!-- Christopher Strecker 06/06/2024 - removed property -->
<!-- <property name="testproperty" type="String" role="inputOnly"> </property> -->
<property name="DataTypeFilter" type="String" role="inputOnly"> </property>
<property name="allowFieldMultiselect" type="Boolean" role="inputOnly"></property>
</targetConfig>
Expand Down

0 comments on commit 3d6b3b5

Please sign in to comment.