This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SimpleMetadata library for metadata classes, created new compon…
…ents Created several new components that are built on top of SimpleMetadata library (included in this repo) * simpleAdmin.cmp * currentUser.cmp * environmentMetadata.cmp * fieldSetMetadata.cmp * listviewMetadata.cmp * queueMetadata.cmp * recordTypeMetadata.cmp
- Loading branch information
Showing
82 changed files
with
2,663 additions
and
418 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,43 @@ | ||
# Lightning Components | ||
A library of lightweight Salesforce Lightning components that streamline developing by automatically applying sobject-level security, field-level security, field types and more. | ||
# Simple Lightning Components | ||
A library of lightweight Salesforce Lightning components that simplify developing in Lightning by automatically: | ||
* Honoring SObject-level security & field-level security for displaying fields & allowing fields to be edited | ||
* Displaying the correct input field type based on the field's metadata, including lookup fields & support for polymorphic fields like Task.WhoId & Task.WhatId | ||
* Translating SObject labels, field labels and picklist options | ||
|
||
<a href="https://githubsfdeploy.herokuapp.com" target="_blank"> | ||
<img alt="Deploy to Salesforce" | ||
src="https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/deploy.png"> | ||
<img alt="Deploy to Salesforce" src="https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/deploy.png"> | ||
</a> | ||
|
||
## sobjectMetadata.cmp | ||
* An extensible, markup-less component that returns an instance of LightningMetadataController.SObjectMetadata for the specified SObject | ||
|
||
`<c:sobjectMetadata sobjectName="Account" aura:id="accountMetadataService" />` | ||
|
||
## fieldMetadata.cmp | ||
* An extensible, markup-less component that returns an instance of LightningMetadataController.FieldMetadata for the specified field | ||
|
||
`<c:fieldMetadata sobjectName="Account" fieldName="Type" aura:id="accountTypeMetadataService" />` | ||
|
||
## inputField.cmp | ||
* Provides a simple way to display an SObject's field as an input (editable) that automatically determines sobject-level security, field-level security, the field type, field label, etc. Attributes can be overridden to allow control over the field when needed | ||
|
||
`<c:inputField sobjectName="Account" fieldName="Type" record="{!v.myAccount}" />` | ||
|
||
## lookup.cmp | ||
* Provides lookup functionality that Salesforce does not provide for developers in LEX. This component is used by inputField.cmp for lookup fields. | ||
|
||
Users can search for the record or choose one of the recently viewed records automatically displayed on focus | ||
`<c:lookup sobjectName="Contact" fieldName="AccountId" record="{!v.myContact}" />` | ||
|
||
Polymorphic fields, like Task.WhoId, automatically display an SObject Switcher. | ||
SObject-level permissions are automatically applied - only objects that the user has permission to view are displayed in the SObject Switcher. | ||
`<c:lookup sobjectName="Task" fieldName="WhoId" record="{!v.myTask}" />` | ||
![lookup-task-whoid](https://user-images.githubusercontent.com/1267157/34769563-6f5b8374-f5fe-11e7-88c7-98e6fbb0ec75.gif) | ||
|
||
|
||
## outputField.cmp | ||
* Provides a simple way to display an SObject's field as an output (read-only) that automatically determines sobject-level security, field-level security, the field type, field label, etc. Attributes can be overridden to allow control over the field when needed | ||
|
||
`<c:inputField sobjectName="Account" fieldName="Type" record="{!v.myAccount}" />` | ||
|
||
## sobjectLabel.cmp | ||
* Displays the localized version of the provided SObject's label | ||
|
||
`<c:sobjectLabel sobjectName="Account" />` | ||
|
||
* Feature: Show the SObject's plural label | ||
|
||
`<c:sobjectLabel sobjectName="Account" variant="labelPlural" />` | ||
|
||
## fieldLabel.cmp | ||
* Displays the localized version of the provided field's label | ||
|
||
`<c:fieldLabel sobjectName="Account" fieldName="Type" />` | ||
|
||
* Feature: Show the field's inline help text | ||
|
||
`<c:fieldLabel sobjectName="Account" fieldName="Type" showHelpText="true" />` | ||
|
||
## modal.cmp | ||
* Generates a modal window and displays your contents inside | ||
``` | ||
<c:modal title="My Modal" isOpen="{!v.showModal}"> | ||
<aura:set attribute="body"> | ||
<p>This paragraph will be shown inside the modal</p> | ||
</aura:set> | ||
</c:modal> | ||
``` | ||
## objectPropertyValue.cmp | ||
* Displays the specified property of any javascript object - this is helpful since Lightning does not allow you to dynamically get a property value by name (like 'myObject[someProperty]') | ||
`<c:objectPropertyValue object="{!v.my.complex.nested.object}" propertyName="someProperty" />` | ||
# Apex Classes | ||
## LightningMetadataController.cls | ||
## Simple Admin component | ||
* simpleAdmin.cmp - this is a demo component that provides examples of how to use the other components. It's also a handy admin tool to quickly get information about your org. | ||
|
||
## Metadata Components | ||
Several no-markup components are included. These can be used to dynamically access metadata about your org in Lightning components | ||
* **currentUser.cmp**: return info about the current user. Additional user fields can be returned by setting currentUser.additionalFieldApiNames | ||
* **environmentMetadata.cmp**: returns an instance of EnvironmentMetadata for the specified SObjectenvironmentMetadata.cmp | ||
* **fieldMetadata.cmp**: returns an instance of FieldMetadata for the specified SObjectfieldMetadata.cmp | ||
* **fieldSetMetadata.cmp**: returns an instance of FieldSetMetadata for the specified SObjectfieldSetMetadata.cmp | ||
* **listviewMetadata.cmp**: returns an instance of ListviewMetadata for the specified SObjectlistviewMetadata.cmp | ||
* **queueMetadata.cmp**: returns an instance of QueueMetadata for the specified SObjectqueueMetadata.cmp | ||
* **recordTypeMetadata.cmp**: returns an instance of RecordTypeMetadata for the specified SObjectrecordTypeMetadata.cmp | ||
* **sobjectMetadata.cmp**: returns an instance of SObjectMetadata for the specified SObjectsobjectMetadata.cmp | ||
|
||
## UI Components | ||
These components are used to build UIs in Lightning - several of these leverage the metadata service components | ||
* **fieldLabel.cmp**: Displays the localized version of the provided field's label | ||
* **inputField.cmp**: Provides a simple way to display an SObject's field as an input (editable) that automatically determines sobject-level security, field-level security, the field type, field label, etc. Attributes can be overridden to allow control over the field when needed | ||
* **lookup.cmp**: Provides lookup functionality that Salesforce does not provide for developers in LEX. This component is used by inputField.cmp for lookup fields. | ||
* **modal.cmp**: Generates a modal window and displays your contents inside | ||
* **objectPropertyValue.cmp**: Displays the specified property of any javascript object - this is helpful since Lightning does not allow you to dynamically get a property value by name (like 'myObject[someProperty]') | ||
* **outputField.cmp**: Provides a simple way to display an SObject's field as an output (read-only) that automatically determines sobject-level security, field-level security, the field type, field label, etc. Attributes can be overridden to allow control over the field when needed | ||
* **sobjectLabel.cmp**: Displays the localized version of the provided SObject's label | ||
|
||
## Apex Classes | ||
|
||
### LightningMetadataController.cls | ||
Contains methods for describing your orgs metadata and returning the info as aura-friendly objects that can be consumed by Lightning Components | ||
* getSObjectMetadata(String sobjectName) - returns an instance of LightningMetadataController.SObjectMetadata | ||
* getFieldMetadata(String sobjectName, String fieldName) - returns an instance of LightningMetadataController.FieldMetadata | ||
* getFieldMetadata(String sobjectName, String fieldName) - returns an instance of LightningMetadataController.FieldMetadata | ||
|
||
### SimpleMetadata classes | ||
The remaining metadata classes (SObjectMetadata.cls, FieldMetadata.cls, etc) are part of the [SimpleMetadata](https://github.com/jongpie/SimpleMetadata) project - any bugs or enhancements for those classes are maintained in that project, and the latest version is used in this repo. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
This file is part of the Simple Lightning Components project, released under the MIT License. | ||
See LICENSE file or go to https://github.com/jongpie/LightningComponents for full license details. | ||
--> | ||
<aura:component extensible="true" controller="LightningMetadataController"> | ||
|
||
<!-- Public Attributes --> | ||
<aura:attribute name="additionalFieldApiNames" type="String[]" description="(Optional) Additional field API names to return for the current user" /> | ||
<aura:attribute name="currentUser" type="User" description="The current user" /> | ||
|
||
<!-- Public Functions --> | ||
<aura:method name="fetch" action="{!c.doInit}" description="(Optional) Callback function to use after fetching the current user"> | ||
<aura:attribute name="callback" type="function"/> | ||
</aura:method> | ||
|
||
<!-- Handlers --> | ||
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | ||
<aura:handler name="change" value="{!v.additionalFieldApiNames}" action="{!c.doInit}" /> | ||
|
||
<!-- Markup --> | ||
{!v.body} | ||
|
||
</aura:component> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>41.0</apiVersion> | ||
<description>currentUser</description> | ||
</AuraDefinitionBundle> |
2 changes: 1 addition & 1 deletion
2
...ra/sobjectLabel/sobjectLabelController.js → ...aura/currentUser/currentUserController.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
({ | ||
doInit : function(component, event, helper) { | ||
helper.fetchSObjectMetadata(component, event); | ||
helper.fetchCurrentUser(component, event); | ||
} | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
({ | ||
fetchCurrentUser : function(component, event) { | ||
var params = event.getParam('arguments'); | ||
|
||
var action = component.get('c.getCurrentUser'); | ||
action.setParams({ | ||
'additionalFieldApiNames': component.get('v.additionalFieldApiNames') | ||
}); | ||
action.setStorable(); | ||
action.setCallback(this, function(response) { | ||
if(response.getState() === 'SUCCESS') { | ||
var currentUser = response.getReturnValue(); | ||
component.set('v.currentUser', currentUser); | ||
|
||
if(params) params.callback(null, currentUser); | ||
} else if(response.getState() === 'ERROR') { | ||
this.processCallbackErrors(response); | ||
} | ||
}); | ||
$A.enqueueAction(action); | ||
}, | ||
processCallbackErrors : function(response) { | ||
console.log('ERROR'); | ||
for(var i=0; i < response.getError().length; i++) { | ||
console.log(response.getError()[i]); | ||
} | ||
} | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!-- | ||
This file is part of the Simple Lightning Components project, released under the MIT License. | ||
See LICENSE file or go to https://github.com/jongpie/LightningComponents for full license details. | ||
--> | ||
<aura:component extensible="true" controller="LightningMetadataController"> | ||
|
||
<!-- Public Attributes --> | ||
<aura:attribute name="environmentMetadata" type="EnvironmentMetadata" description="The Environment metadata object returned from the controller" /> | ||
|
||
<!-- Public Functions --> | ||
<aura:method name="fetch" action="{!c.doInit}" description="(Optional) Callback function to use after fetching the metadata"> | ||
<aura:attribute name="callback" type="function"/> | ||
</aura:method> | ||
|
||
<!-- Handlers --> | ||
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | ||
|
||
<!-- Markup --> | ||
{!v.body} | ||
|
||
</aura:component> |
5 changes: 5 additions & 0 deletions
5
src/aura/environmentMetadata/environmentMetadata.cmp-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>41.0</apiVersion> | ||
<description>environmentMetadata</description> | ||
</AuraDefinitionBundle> |
5 changes: 5 additions & 0 deletions
5
src/aura/environmentMetadata/environmentMetadataController.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
({ | ||
doInit : function(component, event, helper) { | ||
helper.fetchEnvironmentMetadata(component, event); | ||
} | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
({ | ||
fetchEnvironmentMetadata : function(component, event) { | ||
var params = event.getParam('arguments'); | ||
|
||
var action = component.get('c.getEnvironmentMetadata'); | ||
action.setStorable(); | ||
action.setCallback(this, function(response) { | ||
if(response.getState() === 'SUCCESS') { | ||
var environmentMetadata = response.getReturnValue(); | ||
component.set('v.environmentMetadata', environmentMetadata); | ||
|
||
if(params) params.callback(null, environmentMetadata); | ||
} else if(response.getState() === 'ERROR') { | ||
this.processCallbackErrors(response); | ||
} | ||
}); | ||
$A.enqueueAction(action); | ||
}, | ||
processCallbackErrors : function(response) { | ||
console.log('ERROR'); | ||
for(var i=0; i < response.getError().length; i++) { | ||
console.log(response.getError()[i]); | ||
} | ||
} | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
<!-- | ||
This file is part of the Simple Lightning Components project, released under the MIT License. | ||
See LICENSE file or go to https://github.com/jongpie/LightningComponents for full license details. | ||
--> | ||
<aura:component extends="c.fieldMetadata"> | ||
|
||
<!-- Public Attributes --> | ||
<aura:attribute name="label" type="String" /> | ||
<aura:attribute name="showHelpText" type="Boolean" default="true" /> | ||
<aura:attribute name="helpText" type="String" /> | ||
|
||
<!-- Private Attributes --> | ||
<aura:attribute name="fieldMetadata" type="Object" access="private" /> | ||
|
||
<!-- Markup --> | ||
<ui:outputText value="{!v.label}" /> | ||
<aura:if isTrue="{!and(v.showHelpText, v.helpText != null)}"> | ||
<lightning:helptext iconName="utility:info" content="{!v.helpText}" /> | ||
<ui:outputText value="{!v.fieldMetadata.label}" /> | ||
<aura:if isTrue="{!v.fieldMetadata.inlineHelpText != null}"> | ||
<lightning:helptext iconName="utility:info" content="{!v.fieldMetadata.inlineHelpText}" /> | ||
</aura:if> | ||
|
||
</aura:component> |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
This file is part of the Simple Lightning Components project, released under the MIT License. | ||
See LICENSE file or go to https://github.com/jongpie/LightningComponents for full license details. | ||
--> | ||
<aura:component extends="c.sobjectMetadata" extensible="true" controller="LightningMetadataController"> | ||
|
||
<!-- Public Attributes --> | ||
<aura:attribute name="fieldSetApiName" type="String" required="true" description="The API name of the field set" /> | ||
<aura:attribute name="fieldSetMetadata" type="FieldSetMetadata" description="The field set metadata object returned from the controller" /> | ||
|
||
<!-- Public Methods --> | ||
<aura:method name="fetch" action="{!c.doInit}" description="(Optional) Callback function to use after fetching the metadata"> | ||
<aura:attribute name="callback" type="function"/> | ||
</aura:method> | ||
|
||
<!-- Handlers --> | ||
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | ||
<aura:handler name="change" value="{!v.sobjectApiName}" action="{!c.doInit}" /> | ||
<aura:handler name="change" value="{!v.fieldSetApiName}" action="{!c.doInit}" /> | ||
|
||
<!-- Markup --> | ||
{!v.body} | ||
|
||
</aura:component> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>41.0</apiVersion> | ||
<description>fieldSetMetadata</description> | ||
</AuraDefinitionBundle> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
({ | ||
doInit : function(component, event, helper) { | ||
helper.fetchFieldSetMetadata(component, event); | ||
} | ||
}) |
Oops, something went wrong.