@@ -3,11 +3,11 @@ import * as initializeReactFastclick from "react-fastclick";
33import { hot } from "react-hot-loader" ;
44
55import { AttributeType , DropdownReferenceProps , ReferenceOption , parseStyle , validateProps } from "../../SharedResources/utils/ContainerUtils" ;
6- import { FetchDataOptions , Nanoflow , fetchData } from "../../SharedResources/utils/Data" ;
6+ import { FetchDataOptions , fetchData } from "../../SharedResources/utils/Data" ;
77import { DropdownReference } from "./DropdownReference" ;
88
99interface WrapperProps {
10- class : string ;
10+ " class" : string ;
1111 mxObject : mendix . lib . MxObject ;
1212 mxform : mxui . lib . form . _FormBase ;
1313 style : string ;
@@ -21,11 +21,10 @@ export interface ContainerProps extends WrapperProps, DropdownReferenceProps {
2121 entityConstraint : string ;
2222 searchAttribute : string ;
2323 source : "xpath" | "microflow" | "nanoflow" ;
24- // sortOrder: "asc" | "desc";
2524 sortAttributes : AttributeType [ ] ;
26- nanoflow : Nanoflow ;
25+ nanoflow : mx . Nanoflow ;
2726 microflow : string ;
28- onChangeNanoflow : Nanoflow ;
27+ onChangeNanoflow : mx . Nanoflow ;
2928 onChangeMicroflow : string ;
3029 onChangeEvent : "callMicroflow" | "callNanoflow" ;
3130 editable : "default" | "never" ;
@@ -40,7 +39,7 @@ export interface ContainerState {
4039class DropdownReferenceContainer extends Component < ContainerProps , ContainerState > {
4140 readonly state : ContainerState = {
4241 options : [ ] ,
43- isClearable : this . props . isClearable ? true : false ,
42+ isClearable : this . props . isClearable ,
4443 selectedObject : { }
4544 } ;
4645
@@ -59,12 +58,11 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
5958 selectType : this . props . selectType ,
6059 lazyFilter : this . props . lazyFilter ,
6160 isReadOnly : this . isReadOnly ( ) ,
62- labelCaption : this . props . labelCaption ? this . props . labelCaption . trim ( ) : "" ,
61+ labelCaption : this . props . labelCaption ? this . props . labelCaption : "" ,
6362 labelOrientation : this . props . labelOrientation ,
6463 labelWidth : this . props . labelWidth ,
6564 location : this . props . mxform . place ,
6665 readOnlyStyle : this . props . readOnlyStyle ,
67- searchText : this . props . searchText , // unused???
6866 loadingText : this . props . loadingText ,
6967 minimumCharacter : this . props . minimumCharacter ,
7068 selectedValue : this . state . selectedObject ,
@@ -74,7 +72,7 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
7472 }
7573
7674 componentWillReceiveProps ( newProps : ContainerProps ) {
77- if ( newProps . mxObject && ( newProps . mxObject !== this . props . mxObject ) ) {
75+ if ( newProps . mxObject !== this . props . mxObject ) {
7876 this . getSelectedValue ( newProps ) ;
7977 this . resetSubscriptions ( newProps . mxObject ) ;
8078 if ( this . props . selectType === "normal" ) {
@@ -158,7 +156,6 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
158156
159157 private onChange = ( selection : ReferenceOption ) => {
160158 if ( this . props . mxObject ) {
161-
162159 if ( ! selection ) {
163160 const references = this . props . mxObject . getReferences ( this . association ) ;
164161 this . props . mxObject . removeReferences ( this . association , references ) ;
@@ -180,19 +177,19 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
180177 context . setContext ( mxObject . getEntity ( ) , mxObject . getGuid ( ) ) ;
181178 if ( onChangeEvent === "callMicroflow" && onChangeMicroflow ) {
182179 window . mx . ui . action ( onChangeMicroflow , {
183- error : error => window . mx . ui . error ( `Error while executing onchange microflow ${ onChangeMicroflow } : ${ error . message } ` ) , // tslint:disable-line max-line-length
184- origin : mxform ,
185180 params : {
186181 applyto : "selection" ,
187182 guids : [ mxObject . getGuid ( ) ]
188- }
183+ } ,
184+ origin : mxform ,
185+ error : error => window . mx . ui . error ( `Error while executing onchange microflow ${ onChangeMicroflow } : ${ error . message } ` )
189186 } ) ;
190187 } else if ( onChangeEvent === "callNanoflow" && onChangeNanoflow . nanoflow ) {
191188 window . mx . data . callNanoflow ( {
192- context,
193- error : error => window . mx . ui . error ( `Error while executing onchange nanoflow: ${ error . message } ` ) ,
194189 nanoflow : onChangeNanoflow ,
195- origin : mxform
190+ origin : mxform ,
191+ context,
192+ error : error => window . mx . ui . error ( `Error while executing onchange nanoflow: ${ error . message } ` )
196193 } ) ;
197194 }
198195 }
@@ -224,13 +221,11 @@ class DropdownReferenceContainer extends Component<ContainerProps, ContainerStat
224221 }
225222
226223 private setOptions = ( mendixObjects : mendix . lib . MxObject [ ] ) => {
227- const options : ReferenceOption [ ] = [ ] ;
228-
229- mendixObjects . forEach ( mxObject => {
230- options . push ( {
224+ const options : ReferenceOption [ ] = mendixObjects . map ( mxObject => {
225+ return {
231226 label : mx . parser . formatAttribute ( mxObject , this . props . attribute ) ,
232227 value : mxObject . getGuid ( )
233- } ) ;
228+ } ;
234229 } ) ;
235230
236231 this . setState ( { options } ) ;
0 commit comments