Skip to content

Instantly share code, notes, and snippets.

@lfreeland
lfreeland / gist:3c9af25f8a70751e76cbcb10ecca7535
Created April 9, 2018 02:57
Page Layout Record Display Lightning Component Controller
({
init : function(component, event, helper) {
helper.retrievePageLayout(component, helper);
}
})
@lfreeland
lfreeland / gist:ac5d584f9cf4599dcd63e031b8ecbc0d
Last active September 14, 2018 19:45
Page Layout Record Display Lightning Component Markup
<aura:component controller="PageLayoutRecordDisplayController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:hasSObjectName">
<aura:attribute name="PageLayoutName" type="String" />
<aura:attribute name="PageLayout" type="Object" access="private" />
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<div class="slds-box slds-theme_default">
<aura:if isTrue="{! v.recordId }">
<lightning:recordViewForm recordId="{! v.recordId }" objectApiName="{! v.sObjectName }">
@lfreeland
lfreeland / gist:4aab8c34cc6b9ee02b0358d066822a6c
Last active April 9, 2018 00:13
Collapsible Section Lightning Component Usage
<c:CollapsibleSection title="<Some_Title_Here>">
<!-- Body Content Here -->
</c:CollapsibleSection>
@lfreeland
lfreeland / gist:8e94c727df3ba0e7b832c79b18c883ec
Created April 9, 2018 00:07
Collapsible Section Lightning Component Controller
({
handleSectionHeaderClick : function(component, event, helper) {
var button = event.getSource();
button.set('v.state', !button.get('v.state'));
var sectionContainer = component.find('collapsibleSectionContainer');
$A.util.toggleClass(sectionContainer, "slds-is-open");
}
})
@lfreeland
lfreeland / gist:56920e809a13c1374717b9890de65a8a
Created April 9, 2018 00:05
Collapsible Section Lightning Component Markup
<aura:component>
<aura:attribute name="title" type="String" />
<div class="slds-section slds-is-open"
aura:id="collapsibleSectionContainer">
<h3 class="slds-section__title slds-theme_shade">
<!-- button state defaults to false so state
represents "is collapsed"
-->
<lightning:buttonStateful labelWhenOff="{! v.title }"
@lfreeland
lfreeland / gist:c99a6826d9da14b69a3d65ec8b7a82a7
Created March 25, 2018 18:48
Data Table Custom Event Handler Override Example
<aura:component implements="...">
<c:customDataTable viewRecordOverride="{! c.viewRecordOverride }"
... />
</aura:component>
<aura:component implements="...">
<aura:attribute name="viewRecordOverride" type="Aura.Action" />
<table>
...
<tr>
<td>
<a onclick="{! v.viewRecordOverride ? v.viewRecordOverride : c.viewRecord }>{! record.Name }</a>
</td>
</td>
<div class="slds-box">
<!-- Lightning component body markup here -->
</div>
@lfreeland
lfreeland / gist:0875323bd9f7566750121511418c33bd
Created March 18, 2018 22:31
Lightning Record Video Viewer Component Apex Controller Test Class
@isTest
public with sharing class RecordVideoViewerControllerTest {
@isTest
static void getVideoURL_accountWithWebsiteAsVideoSource_expectVideoSourceUrlReturnedTest() {
String videoSrcURL = 'http://vid@example.com';
Account acct = new Account(
Name = 'Test Account',
Website = videoSrcURL
@lfreeland
lfreeland / gist:e2774720d9249db3a90f4f326645e1dd
Created March 18, 2018 20:19
Lightning Record Video Viewer Component Apex Controller
public with sharing class RecordVideoViewerController {
@AuraEnabled
public static String getVideoURL(Id recordId, String videoField) {
Schema.SObjectType objectType = recordId.getSobjectType();
String objectName = objectType.getDescribe().getName();
String videoSOQL = 'SELECT ' + videoField +
' FROM ' + objectName +
' WHERE Id = :recordId';