Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ robot/SummitEventsApp/results/
.DS_Store

# Illuminated Cloud (IntelliJ IDEA)
.IlluminatedCloud
IlluminatedCloud
.IlluminatedCloud
out
Expand Down
33 changes: 33 additions & 0 deletions datasets/snowfakery/sea_test_registrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
- snowfakery_version: 3
- plugin: snowfakery.standard_plugins.Salesforce.SOQLDataset
- object: Contact
count: 100
fields:
FirstName: ${{fake.first_name}}
LastName: ${{fake.last_name}}
Email: ${{fake.email}}
Phone: ${{fake.phone_number}}
MailingStreet: ${{fake.street_address}}
MailingCity: ${{fake.city}}
MailingState: ${{fake.state}}
MailingPostalCode: ${{fake.postcode}}
MailingCountry: ${{fake.country}}
friends:
- object: summit_events_Registration__c
fields:
__instance:
SOQLDataset.iterate:
fields: Id, Instance_Title__c, Event__c
from: summit_events_instance__c
where: Event__r.Name = 'Sample - Open House for Prospective Graduate Students'
Contact__c: ${{Contact}}
Event__c: ${{__instance.Event__c}}
Event_Instance__c: ${{__instance.Id}}
registrant_first_name__c: ${{Contact.FirstName}}
registrant_last_name__c: ${{Contact.LastName}}
registrant_email__c: ${{Contact.Email}}
registrant_phone__c: ${{Contact.Phone}}
registrant_street_1__c: ${{Contact.MailingStreet}}
registrant_city__c: ${{Contact.MailingCity}}
registrant_postal_code__c: ${{Contact.MailingPostalCode}}
status__c: 'Registered'
27 changes: 27 additions & 0 deletions force-app/main/default/classes/SummitEventsMapController.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public with sharing class SummitEventsMapController {

@AuraEnabled(cacheable=true)
public static List<Summit_Events_Registration__c> getSummitEventsRegistrants(Id eventId) {
List<Summit_Events_Registration__c> registrations;
try {
if (Schema.SObjectType.Summit_Events_Registration__c.isAccessible()) {
registrations = [SELECT Id,
Preferred_First_Name_Formatted__c,
Contact__r.MailingStreet,
Contact__r.MailingCity,
Contact__r.MailingState,
Contact__r.MailingPostalCode,
Contact__r.MailingCountry,
Contact__r.MailingLongitude,
Contact__r.MailingLatitude
FROM Summit_Events_Registration__c
WHERE (Event_Instance__c =: eventId OR Event__c =: eventId)
WITH SECURITY_ENFORCED
];
}
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
return registrations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<lightning-card title="Registrants Map">
<lightning-layout>
<lightning-layout-item flexibility="auto" padding="horizontal-medium">
<lightning-map
map-markers={mapMarkers}
markers-title="Registrants"
list-view="hidden"
selected-marker-value={selectedMarkerValue}
onmarkerselect={handleMarkerSelect}>
</lightning-map>
</lightning-layout-item>
</lightning-layout>
<template lwc:if={isEvent}>
<lightning-select
name="selectEventInstance"
label="Select Event Instance"
value={selectedEventInstance}
onchange={handleSelectEventInstanceChange}
options={eventInstancesOptions}>
</lightning-select>
</template>
</lightning-card>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { LightningElement, wire, api } from 'lwc';
import getSummitEventsRegistrants from '@salesforce/apex/SummitEventsMapController.getSummitEventsRegistrants';
import { getRelatedListRecords } from 'lightning/uiRelatedListApi';

export default class SummitEventsRegistrantMap extends LightningElement {
@api recordId;
@api objectApiName;
mapMarkers;
selectedEventInstance = '';
selectedMarkerValue;
eventInstancesOptions = [
{ label: 'All Event Instances', value: '' }
];

get selectedEventOrEventInstanceId() {
return (this.selectedEventInstance === null || this.selectedEventInstance === '') ? this.recordId : this.selectedEventInstance;
}

get isEvent() {
return this.objectApiName === 'Summit_Events__c';
}

@wire(getRelatedListRecords, {
parentRecordId: '$recordId',
relatedListId: 'Event_Instances__r',
fields: ['Summit_Events_Instance__c.Id','Summit_Events_Instance__c.Event__c', 'Summit_Events_Instance__c.Name'],
orderBy: 'Summit_Events_Instance__c.Name'
})
listInfo({ error, data }) {
if (data) {
data.records.forEach((childRecord) => {
this.eventInstancesOptions.push({
label: childRecord?.fields?.Name?.value,
value: childRecord?.fields?.Id?.value
})
});
this.eventInstancesOptions = JSON.parse(JSON.stringify(this.eventInstancesOptions));
} else if (error) {
if (this.isEvent) {
console.error(JSON.stringify(error));
}
}
}

@wire(getSummitEventsRegistrants, {eventId: '$selectedEventOrEventInstanceId'})
summitEventsRegistrants ({error, data}) {
if (error) {
console.error(JSON.stringify(error));
} else if (data) {
this.mapMarkers = data.map((registrant) => ({
location: {
Latitude: registrant?.Contact__r?.MailingLatitude,
Longitude: registrant?.Contact__r?.MailingLongitude,
},
title: registrant?.Preferred_First_Name_Formatted__c || 'Registrant',
description: registrant?.Contact__r?.MailingCity + ', ' + (registrant?.Contact__r?.MailingState === undefined ? registrant?.Contact__r?.MailingCountry : registrant?.Contact__r?.MailingState),
value: registrant?.Id,
icon: 'standard:location'
}));
}
}
handleSelectEventInstanceChange(event) {
this.selectedEventInstance = event.target.value;
}

handleMarkerSelect(event) {
this.selectedMarkerValue = event.target.selectedMarkerValue;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<description>Summit Events Registrant Map</description>
<isExposed>true</isExposed>
<masterLabel>Summit Events Registrant Map</masterLabel>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
4 changes: 4 additions & 0 deletions force-app/main/default/lwc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// DO NOT EDIT: This file is managed by Illuminated Cloud. Any external changes will be discarded.
{
"extends": "../../../../.illuminatedCloud/lwc/tsconfig.json"
}
18 changes: 18 additions & 0 deletions force-app/test/default/classes/SummitEventsMapController_TEST.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@isTest
public with sharing class SummitEventsMapController_TEST {
@isTest
public static void getSummitEventsRegistrants_givenRegistrant_shouldReturnRegistrant() {
SummitEventsTestSharedDataFactory.createContact('TestFirst1', 'TestLast1', 'test1@example.net', '55418', '(555) 555-5555', '1971-03-22');
List<Summit_Events_Instance__c> seaTestInstances = SummitEventsTestSharedDataFactory.createTestEvent();
Summit_Events_Registration__c seaTestRegistration = SummitEventsTestSharedDataFactory.createEventRegistration(seaTestInstances[1], 'TestFirst', 'TestLast', 'test@example.net', '55418', '1971-03-22', '2012', null);
seaTestRegistration.Registrant_City__c = 'Example';
seaTestRegistration.Registrant_State__c = 'KS';
update seaTestRegistration;

Test.startTest();
List<Summit_Events_Registration__c> registrants = SummitEventsMapController.getSummitEventsRegistrants(seaTestInstances[1].Id);
Test.stopTest();

Assert.areEqual(1, registrants.size(), 'There should be one registrant returned');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>64.0</apiVersion>
<status>Active</status>
</ApexClass>