@@ -49,38 +49,60 @@ define([
49
49
/**
50
50
*
51
51
* @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
53
54
* @param {Array<string> } selectedList
54
55
* @param {Array<string> } includeList
55
56
*/
56
- constructor ( frameSelector , dataframe , selectedList = [ ] , includeList = [ ] ) {
57
+ constructor ( frameSelector , config ) {
57
58
this . uuid = 'u' + vpCommon . getUUID ( ) ;
58
59
this . frameSelector = frameSelector ;
60
+
61
+ // configuration
62
+ var { dataframe, selectedList= [ ] , includeList= [ ] } = config ;
59
63
this . dataframe = dataframe ;
60
64
this . selectedList = selectedList ;
61
65
this . includeList = includeList ;
66
+
62
67
this . columnList = [ ] ;
63
68
this . pointer = { start : - 1 , end : - 1 } ;
64
69
65
70
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 ( ) ;
74
87
} ) ;
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
+ }
84
106
}
85
107
86
108
_wrapSelector ( query = '' ) {
@@ -90,6 +112,8 @@ define([
90
112
load ( ) {
91
113
$ ( vpCommon . wrapSelector ( this . frameSelector ) ) . html ( this . render ( ) ) ;
92
114
vpCommon . loadCssForDiv ( this . _wrapSelector ( ) , Jupyter . notebook . base_url + vpConst . BASE_PATH + vpConst . STYLE_PATH + 'common/component/columnSelector.css' ) ;
115
+ this . bindEvent ( ) ;
116
+ this . bindDraggable ( ) ;
93
117
}
94
118
95
119
getColumnList ( ) {
0 commit comments