-
Notifications
You must be signed in to change notification settings - Fork 0
/
DependentPicklist.cmp
51 lines (48 loc) · 3.01 KB
/
DependentPicklist.cmp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!--
- Created by johnpernock from OpenGate Consulting on 2019-01-09.
-->
<aura:component description="DependentPicklist" access="global" controller="DependentPicklistController">
<!-- aura attributes-->
<aura:attribute access="private" name="listControllingValues" type="list" default="[]" description="to store controller field values"/>
<aura:attribute access="private" name="listDependingValues" type="list" default="['--- None ---']" description="to store dependent field values"/>
<aura:attribute access="private" name="depnedentFieldMap" type="String" description="map to store dependent values with controlling value"/>
<aura:attribute access="private" name="bDisabledDependentFld" type="boolean" default="true"/>
<aura:attribute name="objDetail" type="sObject" required="true"/>
<aura:attribute name="requiredField" type="Boolean" default="false" />
<aura:attribute name="objControlField" type="String" required="true"/>
<aura:attribute name="objControlLabel" type="String" required="true"/>
<aura:attribute name="objDependentField" type="String" required="true"/>
<aura:attribute name="objDependentLabel" type="String" required="true"/>
<aura:attribute name="controllingFieldAPI" type="string" description="store field API name of Controller field" required="true"/>
<aura:attribute name="dependingFieldAPI" type="string" description="store field API name of dependent field" required="true"/>
<aura:handler name="change" value="{!v.objControlField}" action="{!c.onControllerFieldChange}"/>
<!-- call doInit function on component load -->
<aura:handler name="init" value="this" action="{!c.doInit}"/>
<div aura:id="dependentPicklistDiv" class="slds-is-relative">
<lightning:spinner variant="brand" size="large" aura:id="loaddependent_spinner" class="slds-hide" />
<!--Controller Field-->
<lightning:select name="controllerFld"
value="{!v.objControlField}"
label="{!v.objControlLabel}"
required="{!v.requiredField}">
<aura:iteration items="{!v.listControllingValues}" var="val">
<option value="{!val.value}">{!val.label}</option>
</aura:iteration>
</lightning:select>
<!--Dependent Field-->
<lightning:select name="dependentFld"
value="{!v.objDependentField}"
label="{!v.objDependentLabel}"
disabled="{!v.bDisabledDependentFld}"
required="{!v.requiredField}">
<aura:iteration items="{!v.listDependingValues}" var="val">
<aura:if isTrue="{!v.objDependentField == val}">
<option value="{!val}" selected='selected'>{!val}</option>
<aura:set attribute="else">
<option value="{!val.value}">{!val.label}</option>
</aura:set>
</aura:if>
</aura:iteration>
</lightning:select>
</div>
</aura:component>