-
Notifications
You must be signed in to change notification settings - Fork 3
/
similarBoats.js
59 lines (51 loc) · 1.51 KB
/
similarBoats.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { api, LightningElement, wire } from 'lwc';
import { NavigationMixin } from 'lightning/navigation'
import getSimilarBoats from '@salesforce/apex/BoatDataService.getSimilarBoats';
const BOAT_OBJECT = 'Boat__c';
export default class SimilarBoats extends NavigationMixin(LightningElement) {
// Private
currentBoat;
relatedBoats;
boatId;
error;
@api
get recordId() {
return this.boatId;
}
set recordId(value) {
//sets boatId attribute
this.setAttribute('boatId', value);
//sets boatId assignment
this.boatId = value;
}
@api
similarBy;
// Wire custom Apex call, using the import named getSimilarBoats
// Populates the relatedBoats list
@wire(getSimilarBoats, {boatId: '$boatId', similarBy: '$similarBy'})
similarBoats({ error, data }) {
if (data) {
this.relatedBoats = data;
this.error = undefined;
} else if (error) {
this.error = error;
}
}
get getTitle() {
return 'Similar boats by ' + this.similarBy;
}
get noBoats() {
return !(this.relatedBoats && this.relatedBoats.length > 0);
}
// Navigate to record page
openBoatDetailPage(event) {
this[NavigationMixin.Navigate]({
type: 'standard__recordPage',
attributes: {
recordId: event.detail.boatId,
objectApiName: BOAT_OBJECT,
actionName: 'view'
},
});
}
}