@@ -49,38 +49,60 @@ define([
4949 /**
5050 *
5151 * @param {string } frameSelector query for parent component
52- * @param {string } dataframe dataframe variable name
52+ * @param {Object } config dataframe:[], selectedList=[], includeList=[]
53+ * @param {Array<string> } dataframe dataframe variable name
5354 * @param {Array<string> } selectedList
5455 * @param {Array<string> } includeList
5556 */
56- constructor ( frameSelector , dataframe , selectedList = [ ] , includeList = [ ] ) {
57+ constructor ( frameSelector , config ) {
5758 this . uuid = 'u' + vpCommon . getUUID ( ) ;
5859 this . frameSelector = frameSelector ;
60+
61+ // configuration
62+ var { dataframe, selectedList= [ ] , includeList= [ ] } = config ;
5963 this . dataframe = dataframe ;
6064 this . selectedList = selectedList ;
6165 this . includeList = includeList ;
66+
6267 this . columnList = [ ] ;
6368 this . pointer = { start : - 1 , end : - 1 } ;
6469
6570 var that = this ;
66- kernelApi . getColumnList ( dataframe , function ( result ) {
67- var colList = JSON . parse ( result ) ;
68- colList = colList . map ( function ( x ) {
69- return {
70- ...x ,
71- value : x . label ,
72- code : x . value
73- } ;
71+ if ( dataframe && dataframe . length > 1 ) {
72+ kernelApi . getCommonColumnList ( dataframe , function ( result ) {
73+ var colList = JSON . parse ( result ) ;
74+ colList = colList . map ( function ( x ) {
75+ return {
76+ ...x ,
77+ value : x . label ,
78+ code : x . value
79+ } ;
80+ } ) ;
81+ if ( includeList && includeList . length > 0 ) {
82+ that . columnList = colList . filter ( col => includeList . includes ( col . code ) ) ;
83+ } else {
84+ that . columnList = colList ;
85+ }
86+ that . load ( ) ;
7487 } ) ;
75- if ( includeList && includeList . length > 0 ) {
76- that . columnList = colList . filter ( col => includeList . includes ( col . code ) ) ;
77- } else {
78- that . columnList = colList ;
79- }
80- that . load ( ) ;
81- that . bindEvent ( ) ;
82- that . bindDraggable ( ) ;
83- } ) ;
88+ } else {
89+ kernelApi . getColumnList ( dataframe , function ( result ) {
90+ var colList = JSON . parse ( result ) ;
91+ colList = colList . map ( function ( x ) {
92+ return {
93+ ...x ,
94+ value : x . label ,
95+ code : x . value
96+ } ;
97+ } ) ;
98+ if ( includeList && includeList . length > 0 ) {
99+ that . columnList = colList . filter ( col => includeList . includes ( col . code ) ) ;
100+ } else {
101+ that . columnList = colList ;
102+ }
103+ that . load ( ) ;
104+ } ) ;
105+ }
84106 }
85107
86108 _wrapSelector ( query = '' ) {
@@ -90,6 +112,8 @@ define([
90112 load ( ) {
91113 $ ( vpCommon . wrapSelector ( this . frameSelector ) ) . html ( this . render ( ) ) ;
92114 vpCommon . loadCssForDiv ( this . _wrapSelector ( ) , Jupyter . notebook . base_url + vpConst . BASE_PATH + vpConst . STYLE_PATH + 'common/component/columnSelector.css' ) ;
115+ this . bindEvent ( ) ;
116+ this . bindDraggable ( ) ;
93117 }
94118
95119 getColumnList ( ) {
0 commit comments