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
1212
1313 <!-- Private Attributes -->
1414 <aura:attribute name="fieldValue" type="Object" access="private" />
15+ <aura:attribute name="fieldPicklistLabels" type="String" access="private" description="Used to display translated picklist values" />
1516 <aura:attribute name="relationshipNameField" type="String" access="private" />
1617 <aura:attribute name="parentRecordName" type="String" access="private" />
1718
@@ -87,7 +88,7 @@ See LICENSE file or go to https://github.com/jongpie/LightningComponents for ful
8788
8889 <!-- MULTIPICKLIST or PICKLIST -->
8990 <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 }" />
9192 </aura:if>
9293
9394 <!-- PERCENT -->
Original file line number Diff line number Diff line change 11( {
22 doInit : function ( component , event , helper ) {
33 helper . handleFieldValueChanged ( component , event ) ;
4+ helper . getPicklistLabels ( component , event ) ;
45 } ,
56 handleFieldMetadataChanged : function ( component , event , helper ) {
67 helper . setFieldMetadataAttributes ( component , event ) ;
8+ helper . getPicklistLabels ( component , event ) ;
79 } ,
810 handleRecordChanged : function ( component , event , helper ) {
911 var record = component . get ( 'v.record' ) ;
1012 var fieldApiName = component . get ( 'v.fieldApiName' ) ;
1113
1214 component . set ( 'v.fieldValue' , record [ fieldApiName ] ) ;
15+ helper . getPicklistLabels ( component , event ) ;
1316 } ,
1417 handleFieldValueChanged : function ( component , event , helper ) {
1518 helper . handleFieldValueChanged ( component , event ) ;
19+ helper . getPicklistLabels ( component , event ) ;
1620 }
1721} )
Original file line number Diff line number Diff line change 2929 if ( record . hasOwnProperty ( fieldApiName ) ) {
3030 component . set ( 'v.fieldValue' , record [ fieldApiName ] ) ;
3131 }
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 ( ';' ) ) ;
3256 }
3357} )
You can’t perform that action at this time.
0 commit comments