88Ext4 . define ( 'LDK.form.field.SimpleLabKeyCombo' , {
99 extend : 'LABKEY.ext4.ComboBox' ,
1010 alias : 'widget.ldk-simplelabkeycombo' ,
11+ joinReturnValue : false ,
12+ delimiter : ';' ,
13+ forceSelection : true ,
14+ typeAhead : true ,
15+ queryMode : 'local' ,
16+ triggerAction : 'all' ,
1117
1218 initComponent : function ( ) {
1319 Ext4 . apply ( this , {
14- forceSelection : true ,
15- typeAhead : true ,
16- queryMode : 'local' ,
17- triggerAction : 'all' ,
1820 store : {
1921 type : 'labkey-store' ,
2022 containerPath : this . containerPath ,
@@ -27,6 +29,14 @@ Ext4.define('LDK.form.field.SimpleLabKeyCombo', {
2729 } ) ;
2830
2931 this . callParent ( arguments ) ;
32+
33+ if ( this . initialValues ) {
34+ if ( ! Ext4 . isArray ( this . initialValues ) ) {
35+ this . initialValues = this . initialValues . split ( ';' ) ;
36+ }
37+
38+ this . setValue ( this . initialValues ) ;
39+ }
3040 } ,
3141
3242 setValue : function ( val ) {
@@ -39,18 +49,48 @@ Ext4.define('LDK.form.field.SimpleLabKeyCombo', {
3949
4050 this . setValue . apply ( this , args ) ;
4151 } , this , { defer : 100 , single : true } ) ;
52+
53+ // wait for store load:
54+ return ;
55+ }
56+
57+ if ( this . multiSelect && val && Ext4 . isString ( val ) ) {
58+ val = val . split ( this . delimiter ) ;
4259 }
4360
44- if ( this . store && this . valueField && Ext4 . isPrimitive ( val ) ) {
61+ if ( this . store && this . valueField ) {
4562 var field = this . store . getFields ( ) . get ( this . valueField ) ;
4663 if ( field ) {
47- val = field . convert ( val ) ;
48- if ( Ext4 . isDefined ( val ) ) {
49- arguments [ 0 ] = val ;
64+ if ( Ext4 . isPrimitive ( val ) ) {
65+ val = field . convert ( val ) ;
66+ if ( Ext4 . isDefined ( val ) ) {
67+ arguments [ 0 ] = val ;
68+ }
69+ }
70+ else if ( Ext4 . isArray ( val ) ) {
71+ Ext4 . Array . forEach ( val , function ( v , idx ) {
72+ v = field . convert ( v ) ;
73+ if ( Ext4 . isDefined ( v ) ) {
74+ val [ idx ] = v ;
75+ }
76+ } , this ) ;
5077 }
5178 }
5279 }
5380
5481 this . callParent ( arguments ) ;
82+ } ,
83+
84+ getSubmitValue : function ( ) {
85+ var val = this . callParent ( arguments ) ;
86+ if ( ! Ext4 . isArray ( val ) || ! this . joinReturnValue ) {
87+ return val ;
88+ }
89+
90+ return val && val . length ? val . join ( this . delimiter ) : null ;
91+ } ,
92+
93+ getToolParameterValue : function ( ) {
94+ return this . getSubmitValue ( ) ;
5595 }
5696} ) ;
0 commit comments