added examples folder
This commit is contained in:
Родитель
4de1ba8e60
Коммит
cdcdda34d4
|
@ -0,0 +1,15 @@
|
|||
<aura:component controller="helloBadge" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId">
|
||||
<aura:attribute name="loadBadge" type="Boolean" default="{!false}"/>
|
||||
<aura:attribute name="label" type="String"/>
|
||||
<aura:attribute name="theme" type="String"/>
|
||||
|
||||
<aura:attribute name="recordId" type="Id" />
|
||||
|
||||
<aura:handler name="init" value="{!this}" action="{!c.init}"/>
|
||||
|
||||
<aura:if isTrue="{!v.loadBadge}">
|
||||
<div>
|
||||
<c:strike_badge label="{!v.label}" theme="{!v.theme}"/>
|
||||
</div>
|
||||
</aura:if>
|
||||
</aura:component>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>38.0</apiVersion>
|
||||
<description>A Lightning Component Bundle</description>
|
||||
</AuraDefinitionBundle>
|
|
@ -0,0 +1,3 @@
|
|||
<design:component label="Hello Badge">
|
||||
|
||||
</design:component>
|
|
@ -0,0 +1,24 @@
|
|||
({
|
||||
init : function(component, event, helper) {
|
||||
var action = component.get('c.determineIfOwned');
|
||||
action.setParams({
|
||||
recordId: component.get('v.recordId')
|
||||
});
|
||||
|
||||
action.setCallback(this, function(response){
|
||||
var isOwner = response.getReturnValue();
|
||||
console.log('********** made it back ' + isOwner);
|
||||
component.set('v.loadBadge', true);
|
||||
|
||||
if(isOwner){
|
||||
component.set('v.label', 'You are the owner of this account');
|
||||
component.set('v.theme', 'success');
|
||||
} else {
|
||||
component.set('v.label', 'You are not the owner of this account');
|
||||
component.set('v.theme', 'warning');
|
||||
}
|
||||
});
|
||||
|
||||
$A.enqueueAction(action);
|
||||
}
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
|
||||
<aura:attribute name="label" type="String" />
|
||||
<aura:attribute name="class" type="String" />
|
||||
<aura:attribute name="theme" type="String" />
|
||||
<aura:handler name="change" value="{!v.theme}" action="{!c.themeChange}"/>
|
||||
|
||||
<lightning:badge label="{!v.label}" class="{!if(empty(v.theme), '', 'slds-theme--' + v.theme) + ' ' + v.class}"/>
|
||||
|
||||
</aura:component>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>38.0</apiVersion>
|
||||
<description>A Lightning Component Bundle</description>
|
||||
</AuraDefinitionBundle>
|
|
@ -0,0 +1,5 @@
|
|||
({
|
||||
themeChange : function(component, event, helper) {
|
||||
component.set('v.theme', component.get('v.theme').toLowerCase());
|
||||
}
|
||||
})
|
|
@ -0,0 +1,9 @@
|
|||
public class helloBadge {
|
||||
@AuraEnabled
|
||||
public static Boolean determineIfOwned(String recordId){
|
||||
String userId = UserInfo.getUserId();
|
||||
Account currentAccount = [SELECT Id, OwnerId FROM Account WHERE Id =: recordId];
|
||||
|
||||
return userId == currentAccount.OwnerId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||
<apiVersion>38.0</apiVersion>
|
||||
<status>Active</status>
|
||||
</ApexClass>
|
Загрузка…
Ссылка в новой задаче