This repository was archived by the owner on Sep 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ See LICENSE file or go to https://github.com/jongpie/LightningComponents for ful
12
12
13
13
<!-- Private Attributes -->
14
14
<aura:attribute name="fieldValue" type="Object" access="private" />
15
+ <aura:attribute name="fieldPicklistLabels" type="String" access="private" description="Used to display translated picklist values" />
15
16
<aura:attribute name="relationshipNameField" type="String" access="private" />
16
17
<aura:attribute name="parentRecordName" type="String" access="private" />
17
18
@@ -87,7 +88,7 @@ See LICENSE file or go to https://github.com/jongpie/LightningComponents for ful
87
88
88
89
<!-- MULTIPICKLIST or PICKLIST -->
89
90
<aura:if isTrue="{!or(v.displayType == 'MULTIPICKLIST', v.displayType == 'PICKLIST')}">
90
- <ui:outputText aura:id="outputField" value="{!v.fieldValue }" />
91
+ <ui:outputText aura:id="outputField" value="{!v.fieldPicklistLabels }" />
91
92
</aura:if>
92
93
93
94
<!-- PERCENT -->
Original file line number Diff line number Diff line change 1
1
( {
2
2
doInit : function ( component , event , helper ) {
3
3
helper . handleFieldValueChanged ( component , event ) ;
4
+ helper . getPicklistLabels ( component , event ) ;
4
5
} ,
5
6
handleFieldMetadataChanged : function ( component , event , helper ) {
6
7
helper . setFieldMetadataAttributes ( component , event ) ;
8
+ helper . getPicklistLabels ( component , event ) ;
7
9
} ,
8
10
handleRecordChanged : function ( component , event , helper ) {
9
11
var record = component . get ( 'v.record' ) ;
10
12
var fieldApiName = component . get ( 'v.fieldApiName' ) ;
11
13
12
14
component . set ( 'v.fieldValue' , record [ fieldApiName ] ) ;
15
+ helper . getPicklistLabels ( component , event ) ;
13
16
} ,
14
17
handleFieldValueChanged : function ( component , event , helper ) {
15
18
helper . handleFieldValueChanged ( component , event ) ;
19
+ helper . getPicklistLabels ( component , event ) ;
16
20
}
17
21
} )
Original file line number Diff line number Diff line change 29
29
if ( record . hasOwnProperty ( fieldApiName ) ) {
30
30
component . set ( 'v.fieldValue' , record [ fieldApiName ] ) ;
31
31
}
32
+ } ,
33
+ getPicklistLabels : function ( component , event ) {
34
+ var fieldMetadata = component . get ( 'v.fieldMetadata' ) ;
35
+ var fieldApiName = component . get ( 'v.fieldApiName' ) ;
36
+ var record = component . get ( 'v.record' ) ;
37
+
38
+ if ( fieldMetadata === null ) return ;
39
+ if ( fieldMetadata . displayType !== 'MULTIPICKLIST' && fieldMetadata . displayType !== 'PICKLIST' ) return ;
40
+ if ( ! record . hasOwnProperty ( fieldApiName ) ) return ;
41
+
42
+ var picklistValues = record [ fieldApiName ] . split ( ';' ) ;
43
+ var picklistLabels = [ ] ;
44
+ for ( var i = 0 ; i < picklistValues . length ; i ++ ) {
45
+ var picklistValue = picklistValues [ i ] ;
46
+
47
+ for ( var j = 0 ; j < fieldMetadata . picklistOptions . length ; j ++ ) {
48
+ var picklistOption = fieldMetadata . picklistOptions [ j ] ;
49
+
50
+ if ( picklistOption . value !== picklistValue ) continue ;
51
+
52
+ picklistLabels . push ( picklistOption . label ) ;
53
+ }
54
+ }
55
+ component . set ( 'v.fieldPicklistLabels' , picklistLabels . join ( ';' ) ) ;
32
56
}
33
57
} )
You can’t perform that action at this time.
0 commit comments