@@ -66,6 +66,11 @@ define([
6666 this . columnSelector = null ;
6767 }
6868
69+ _unbindEvent ( ) {
70+ super . _unbindEvent ( ) ;
71+ $ ( document ) . off ( 'change' , this . wrapSelector ( '#dependent' ) ) ;
72+ }
73+
6974 _bindEvent ( ) {
7075 super . _bindEvent ( ) ;
7176 /** Implement binding events */
@@ -79,10 +84,19 @@ define([
7984 $ ( that . wrapSelector ( '.vp-st-option' ) ) . hide ( ) ;
8085 $ ( that . wrapSelector ( '.vp-st-option.' + testType ) ) . show ( ) ;
8186
87+ let excludeList = [ ] ;
88+ if ( that . state . testType === 'multiple'
89+ || that . state . testType === 'hierarchical'
90+ || that . state . testType === 'dummy' ) {
91+ let depVal = $ ( that . wrapSelector ( '#dependent' ) ) . val ( ) ;
92+ excludeList = [ depVal ] ;
93+ }
94+
8295 // render variable selector
8396 that . columnSelector = new MultiSelector ( that . wrapSelector ( '#independentBox' ) ,
8497 {
8598 mode : 'columns' , parent : that . state . data , showDescription : false ,
99+ excludeList : excludeList ,
86100 change : function ( type , list ) {
87101 that . _handleMultiColumnChange ( type , list ) ;
88102 }
@@ -94,6 +108,24 @@ define([
94108 let data = $ ( this ) . val ( ) ;
95109 that . handleVariableChange ( data ) ;
96110 } ) ;
111+
112+ // dependent change
113+ $ ( document ) . on ( 'change' , this . wrapSelector ( '#dependent' ) , function ( ) {
114+ let depVal = $ ( this ) . val ( ) ;
115+ if ( that . state . testType === 'multiple'
116+ || that . state . testType === 'hierarchical'
117+ || that . state . testType === 'dummy' ) {
118+ that . columnSelector = new MultiSelector ( that . wrapSelector ( '#independentBox' ) ,
119+ {
120+ mode : 'columns' , parent : that . state . data , showDescription : false ,
121+ excludeList : [ depVal ] ,
122+ change : function ( type , list ) {
123+ that . _handleMultiColumnChange ( type , list ) ;
124+ }
125+ }
126+ ) ;
127+ }
128+ } ) ;
97129 }
98130
99131 handleVariableChange ( data ) {
@@ -116,7 +148,6 @@ define([
116148 $ ( that . wrapSelector ( '#' + id ) ) . prop ( 'disabled' , true ) ;
117149 } ) ;
118150 }
119-
120151 // render variable selector
121152 this . columnSelector = new MultiSelector ( this . wrapSelector ( '#independentBox' ) ,
122153 {
@@ -191,10 +222,22 @@ define([
191222 }
192223 } ) ;
193224
225+ let excludeList = [ ] ;
226+ if ( this . state . testType === 'multiple'
227+ || this . state . testType === 'hierarchical'
228+ || this . state . testType === 'dummy' ) {
229+ if ( this . state . dependent !== '' ) {
230+ excludeList = [ this . state . dependent ] ;
231+ }
232+ }
233+
194234 // render variable selector
195235 this . columnSelector = new MultiSelector ( this . wrapSelector ( '#indenpendentBox' ) ,
196- { mode : 'columns' , parent : this . state . data , selectedList : this . state . independentMulti . map ( x => x . code ) , showDescription : false }
197- ) ;
236+ {
237+ mode : 'columns' , parent : this . state . data ,
238+ selectedList : this . state . independentMulti . map ( x => x . code ) , excludeList : excludeList , showDescription : false
239+ }
240+ ) ;
198241
199242 // bind column if data exist
200243 if ( this . state . data !== '' ) {
0 commit comments