Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object And Field picklist updates #1549

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
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
Expand Up @@ -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