This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TowerMapController { | |
@AuraEnabled | |
public static List<Tower__c> getAllTowers() { | |
String theObject = 'Tower__c'; | |
List<String> theFields = new List<String>{'Id', 'Name', 'State__r.Name', 'Location__Latitude__s', 'Location__Longitude__s'}; | |
List<String> theFilters = new List<String>(); | |
String sortField = 'Name'; | |
String sortOrder = 'ASC'; | |
List<Tower__c> allTowers = UtilityClass.queryObjects(theObject, theFields, theFilters, sortField, sortOrder); | |
return allTowers; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UtilityClass { | |
public static List<sObject> queryObjects(String theObject, List<String> theFields, List<String> theFilters, String sortField, String sortOrder) { | |
String theQuery = 'SELECT ' + string.join(theFields, ','); | |
theQuery += ' FROM ' + theObject; | |
boolean firstFilter = true; | |
for(String filter : theFilters) { | |
String clauseToUse = (firstFilter) ? ' WHERE ' : ' AND '; | |
filter = filter.trim(); | |
filter = filter.replaceAll('(\\s+)', ' '); // removing white spaces | |
theQuery += clauseToUse + filter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="InheritedSharingClass"> | |
<apex:repeat value="{!allTheSecrets}" var="record"> | |
{!record.Name} | |
</apex:repeat> | |
</apex:page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public inherited sharing class InheritedSharingClass{ | |
public List<Contact> getAllTheSecrets(){ | |
return [SELECT Name FROM Contact]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="contactList"> | |
<apiVersion>45.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightning__AppPage</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__HomePage</target> | |
</targets> | |
</LightningComponentBundle> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, wire } from 'lwc'; | |
import getContactList from '@salesforce/apex/ContactController.getContactList'; | |
export default class EventBubbling extends LightningElement { | |
@wire(getContactList) contacts; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<template if:true={contacts.data}> | |
<template for:each={contacts.data} for:item=contact> | |
<a href="#" key={contact.Id} data-contact-id={contact.Id} onclick={handleSelect}> | |
<lightning-layout> | |
<lightning-layout-item> | |
<img src={contact.Pcture__c} alt="Profile Photo"/> | |
</lightning-layout-item> | |
<lightning-layout-item padding="horizontal-small"> | |
<p>{contact.Name}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class ContactController { | |
@AuraEnabled(cacheable=true) | |
public static List<Contact> getContactList() { | |
return [SELECT Id, Name, Title, Phone, Email, Picture__c FROM Contact WHERE Picture__c != null LIMIT 10]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloConditionalRendering"> | |
<apiVersion>45.0</apiVersion> | |
<isExposed>true</isExposed> | |
<targets> | |
<target>lightning__AppPage</target> | |
<target>lightning__RecordPage</target> | |
<target>lightning__HomePage</target> | |
</targets> | |
</LightningComponentBundle> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement, track } from 'lwc'; | |
export default class HelloConditionalRendering extends LightningElement { | |
@track areDetailsVisible = false; | |
handleChange(event){ | |
this.areDetailsVisible = event.target.checked; | |
} | |
} |