Skip to content

Commit

Permalink
Merge pull request #1435 from octatau/feature/nw/rollup-lwc
Browse files Browse the repository at this point in the history
Object Selector Cleanup
  • Loading branch information
aheber authored Mar 1, 2024
2 parents cb98c1c + add470f commit 57a12f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 120 deletions.
100 changes: 0 additions & 100 deletions dlrs/main/lwc/objectSelector/js-levenshtein.js

This file was deleted.

24 changes: 4 additions & 20 deletions dlrs/main/lwc/objectSelector/objectSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,9 @@ export default class ObjectSelector extends LightningElement {
searchRequired = true;
maxSearchResults = 5;
objectApiNames = [];
objectIconCache;
lstResult = []; // to store list of returned records
searchKey = ""; // to store input field value
isSearchLoading = false; // to control loading spinner
delayTimeout;
selectedRecord = "";
selectedRecordIconName;
objects = [];
preventBlur = false;
connectedCallback() {
this.selectedRecordIconName = this.iconName;
this.isSearchLoading = true;
//GET LIST OF ALL OBJECTS
getAllObjects()
.then((objects) => {
Expand All @@ -51,9 +42,6 @@ export default class ObjectSelector extends LightningElement {
this.error = error;
this.objects = {};
})
.finally(() => {
this.isSearchLoading = false;
});
}

// use the UI API to determine the iconName for each object
Expand All @@ -71,9 +59,9 @@ export default class ObjectSelector extends LightningElement {
t[v.result.apiName] = v.result?.themeInfo;
return t;
}, {});
this.objects.forEach((o) => {
this.objects = this.objects.map((o) => {
if (!objectIconCache[o.fullName]?.iconUrl) {
return;
return o;
}
o.iconUrl = objectIconCache[o.fullName].iconUrl;
o.iconColor = `#${objectIconCache[o.fullName].color}`;
Expand All @@ -84,12 +72,9 @@ export default class ObjectSelector extends LightningElement {
const matches = iconNameRegEx.exec(o.iconUrl);
if (matches) {
o.iconName = `${matches[1]}:${matches[2]}`;
// We just got a new icon for the selected image!
if (o.fullName === this._currentSelection) {
this.selectedRecordIconName = o.iconName;
}
}
}
return o;
});
}
}
Expand All @@ -110,7 +95,7 @@ export default class ObjectSelector extends LightningElement {

// method to update selected record from search result
handleSelectedRecord(event) {
const selectedName = event.detail.selectedOption.value; // event.target.getAttribute("data-objname"); // get selected record Idrd from list
const selectedName = event.detail.selectedOption.value; // get selected record Id from list
this.selectObject(selectedName);
this.lookupUpdatehandler(selectedName); // update value on parent component as well from helper function
}
Expand All @@ -125,7 +110,6 @@ export default class ObjectSelector extends LightningElement {
}
const obj = this.objects.find((o) => o.fullName === val);
this.selectedRecord = obj.fullName;
this.selectedRecordIconName = obj.iconName;
}

// send selected lookup record to parent component using custom event
Expand Down

0 comments on commit 57a12f5

Please sign in to comment.