diff --git a/.gitignore b/.gitignore index 9de1c41a..d406c0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ robot/SummitEventsApp/results/ .DS_Store # Illuminated Cloud (IntelliJ IDEA) +.IlluminatedCloud IlluminatedCloud .IlluminatedCloud out diff --git a/datasets/snowfakery/sea_test_registrations.yml b/datasets/snowfakery/sea_test_registrations.yml new file mode 100644 index 00000000..c51bd93e --- /dev/null +++ b/datasets/snowfakery/sea_test_registrations.yml @@ -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' \ No newline at end of file diff --git a/force-app/main/default/classes/SummitEventsMapController.cls b/force-app/main/default/classes/SummitEventsMapController.cls new file mode 100644 index 00000000..c7888447 --- /dev/null +++ b/force-app/main/default/classes/SummitEventsMapController.cls @@ -0,0 +1,27 @@ +public with sharing class SummitEventsMapController { + + @AuraEnabled(cacheable=true) + public static List getSummitEventsRegistrants(Id eventId) { + List 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; + } +} \ No newline at end of file diff --git a/force-app/main/default/classes/SummitEventsMapController.cls-meta.xml b/force-app/main/default/classes/SummitEventsMapController.cls-meta.xml new file mode 100644 index 00000000..1e7de940 --- /dev/null +++ b/force-app/main/default/classes/SummitEventsMapController.cls-meta.xml @@ -0,0 +1,5 @@ + + + 64.0 + Active + diff --git a/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.html b/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.html new file mode 100644 index 00000000..3df895bf --- /dev/null +++ b/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.html @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.js b/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.js new file mode 100644 index 00000000..69af47fb --- /dev/null +++ b/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.js @@ -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; + } +} \ No newline at end of file diff --git a/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.js-meta.xml b/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.js-meta.xml new file mode 100644 index 00000000..1819cfbe --- /dev/null +++ b/force-app/main/default/lwc/summitEventsRegistrantMap/summitEventsRegistrantMap.js-meta.xml @@ -0,0 +1,12 @@ + + + 64.0 + Summit Events Registrant Map + true + Summit Events Registrant Map + + lightning__AppPage + lightning__RecordPage + lightning__HomePage + + \ No newline at end of file diff --git a/force-app/main/default/lwc/tsconfig.json b/force-app/main/default/lwc/tsconfig.json new file mode 100644 index 00000000..c430026c --- /dev/null +++ b/force-app/main/default/lwc/tsconfig.json @@ -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" +} \ No newline at end of file diff --git a/force-app/test/default/classes/SummitEventsMapController_TEST.cls b/force-app/test/default/classes/SummitEventsMapController_TEST.cls new file mode 100644 index 00000000..52572763 --- /dev/null +++ b/force-app/test/default/classes/SummitEventsMapController_TEST.cls @@ -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 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 registrants = SummitEventsMapController.getSummitEventsRegistrants(seaTestInstances[1].Id); + Test.stopTest(); + + Assert.areEqual(1, registrants.size(), 'There should be one registrant returned'); + } +} \ No newline at end of file diff --git a/force-app/test/default/classes/SummitEventsMapController_TEST.cls-meta.xml b/force-app/test/default/classes/SummitEventsMapController_TEST.cls-meta.xml new file mode 100644 index 00000000..1e7de940 --- /dev/null +++ b/force-app/test/default/classes/SummitEventsMapController_TEST.cls-meta.xml @@ -0,0 +1,5 @@ + + + 64.0 + Active +