@@ -102,14 +102,17 @@ define([
102
102
]
103
103
104
104
this . methodList = [
105
- { label : 'count' , value : 'count' } ,
106
- { label : 'size' , value : 'size' } ,
107
- { label : 'std' , value : 'std' } ,
108
- { label : 'sum' , value : 'sum' } ,
109
- { label : 'max' , value : 'max' } ,
110
- { label : 'mean' , value : 'mean' } ,
111
- { label : 'median' , value : 'median' } ,
112
- { label : 'min' , value : 'min' } ,
105
+ { label : 'count' , value : 'count' } ,
106
+ { label : 'first' , value : 'first' } ,
107
+ { label : 'last' , value : 'last' } ,
108
+ { label : 'size' , value : 'size' } ,
109
+ { label : 'std' , value : 'std' } ,
110
+ { label : 'sum' , value : 'sum' } ,
111
+ { label : 'max' , value : 'max' } ,
112
+ { label : 'mean' , value : 'mean' } ,
113
+ { label : 'median' , value : 'median' } ,
114
+ { label : 'min' , value : 'min' } ,
115
+ { label : 'quantile' , value : 'quantile' } ,
113
116
]
114
117
}
115
118
@@ -150,7 +153,7 @@ define([
150
153
$ ( this . _wrapSelector ( '#vp_gbAdvanced' ) ) . trigger ( 'change' ) ;
151
154
}
152
155
$ ( this . _wrapSelector ( '#vp_gbAllocateTo' ) ) . val ( allocateTo ) ;
153
- $ ( this . _wrapSelector ( '#vp_gbResetIndex' ) ) . prop ( 'checked' , resetIndex ) ;
156
+ $ ( this . _wrapSelector ( '#vp_gbResetIndex' ) ) . val ( resetIndex ? 'yes' : 'no' ) ;
154
157
155
158
$ ( this . _wrapSelector ( '.vp-gb-adv-box' ) ) . html ( advPageDom ) ;
156
159
@@ -298,7 +301,7 @@ define([
298
301
// groupby column
299
302
page . appendLine ( '<div>' ) ;
300
303
page . appendFormatLine ( '<label for="{0}" class="{1}">{2}</label>' , 'vp_gbBy' , 'vp-orange-text wp80' , 'Groupby' ) ;
301
- page . appendFormatLine ( '<input type="text" id="{0}" disabled/>' , 'vp_gbBy' ) ;
304
+ page . appendFormatLine ( '<input type="text" id="{0}" placeholder="{1}" disabled/>' , 'vp_gbBy' , 'Groupby coluns ') ;
302
305
page . appendFormatLine ( '<button id="{0}" class="{1}">{2}</button>' , 'vp_gbBySelect' , 'vp-button wp50' , 'Edit' ) ;
303
306
page . appendFormatLine ( '<label style="display: none;"><input type="checkbox" id="{0}"/><span>{1}</span></label>' , 'vp_gbByGrouper' , 'Grouper' ) ;
304
307
page . appendFormatLine ( '<div class="{0}" style="display:none;">' , 'vp-gb-by-grouper-box' ) ;
@@ -311,11 +314,20 @@ define([
311
314
page . appendLine ( '</select>' ) ;
312
315
page . appendLine ( '</div>' ) ; // by-grouper-box
313
316
page . appendLine ( '</div>' ) ;
314
- page . appendLine ( '<hr style="margin: 10px 0;"/>' ) ;
317
+ // Reset index
318
+ // page.appendFormatLine('<label><input type="checkbox" id="{0}"/><span>{1}</span></label>', 'vp_gbResetIndex', 'Reset index');
319
+ page . appendLine ( '<div>' ) ;
320
+ page . appendFormatLine ( '<label for="{0}" class="{1}">{2}</label>' , 'vp_gbResetIndex' , 'wp80' , 'Reset Index' ) ;
321
+ page . appendFormatLine ( '<select id="{0}">' , 'vp_gbResetIndex' ) ;
322
+ page . appendFormatLine ( '<option value="{0}">{1}</option>' , 'no' , 'No' ) ;
323
+ page . appendFormatLine ( '<option value="{0}">{1}</option>' , 'yes' , 'Yes' ) ;
324
+ page . appendLine ( '</select>' ) ;
325
+ page . appendLine ( '</div>' ) ;
326
+ page . appendLine ( '<hr style="margin: 5px 0;"/>' ) ;
315
327
// display column
316
328
page . appendLine ( '<div>' ) ;
317
329
page . appendFormatLine ( '<label for="{0}" class="{1}">{2}</label>' , 'vp_gbDisplay' , 'wp80' , 'Columns' ) ;
318
- page . appendFormatLine ( '<input type="text" id="{0}" disabled>' , 'vp_gbDisplay' ) ;
330
+ page . appendFormatLine ( '<input type="text" id="{0}" placeholder="{1}" disabled>' , 'vp_gbDisplay' , 'Display columns ') ;
319
331
page . appendFormatLine ( '<button id="{0}" class="{1}">{2}</button>' , 'vp_gbDisplaySelect' , 'vp-button wp50' , 'Edit' ) ;
320
332
page . appendLine ( '</div>' ) ;
321
333
// method
@@ -337,12 +349,12 @@ define([
337
349
page . appendFormatLine ( '<button id="{0}" class="{1}">{2}</button>' , 'vp_gbAdvAdd' , 'vp-button' , '+ Add' ) ;
338
350
page . appendLine ( '</div>' ) ; // end of adv-box
339
351
340
- page . appendLine ( '<hr style="margin: 10px 0;"/>' ) ;
352
+ page . appendLine ( '<hr style="margin: 5px 0;"/>' ) ;
341
353
// Allocate to
342
354
page . appendLine ( '<div>' ) ;
343
355
page . appendFormatLine ( '<label for="{0}" class="{1}">{2}</label>' , 'vp_gbAllocateTo' , 'wp80' , 'Allocate to' ) ;
344
356
page . appendFormatLine ( '<input type="text" id="{0}" placeholder="{1}"/>' , 'vp_gbAllocateTo' , 'New variable name' ) ;
345
- page . appendFormatLine ( '<label><input type="checkbox" id="{0}"/><span>{1}</span></label>' , 'vp_gbResetIndex' , 'Reset index' ) ;
357
+
346
358
page . appendLine ( '</div>' ) ;
347
359
348
360
page . appendLine ( '</div>' ) ; // end of df-box
@@ -410,17 +422,20 @@ define([
410
422
var page = new sb . StringBuilder ( ) ;
411
423
page . appendFormatLine ( '<div class="{0}">' , 'vp-gb-adv-item' ) ;
412
424
// target columns
413
- page . appendFormatLine ( '<input type="text" class="{0}" placeholder="{1}" disabled/>' , 'vp-gb-adv-col' , 'Column list' ) ;
425
+ page . appendFormatLine ( '<input type="text" class="{0}" placeholder="{1}" title="{2}" disabled/>'
426
+ , 'vp-gb-adv-col' , 'Column list' , 'Apply All columns, if not selected' ) ;
414
427
page . appendFormatLine ( '<button class="{0} {1}">{2}</button>' , 'vp-gb-adv-col-selector' , 'vp-button wp50' , 'Edit' ) ;
415
428
// method select
416
429
page . appendFormatLine ( '<select class="{0}">' , 'vp-gb-adv-method-selector' ) ;
430
+ var defaultMethod = '' ;
431
+ page . appendFormatLine ( '<option value="{0}">{1}</option>' , '' , 'Select method type' ) ;
432
+ page . appendFormatLine ( '<option value="{0}">{1}</option>' , 'typing' , 'Typing' ) ;
417
433
this . methodList . forEach ( method => {
418
434
page . appendFormatLine ( '<option value="{0}">{1}</option>' , method . value , method . label ) ;
419
435
} ) ;
420
- page . appendFormatLine ( '<option value="{0}">{1}</option>' , 'typing' , 'Typing' ) ;
421
436
page . appendLine ( '</select>' ) ;
422
437
page . appendFormatLine ( '<div class="{0}" style="display: none;">' , 'vp-gb-adv-method-box' ) ;
423
- page . appendFormatLine ( '<input type="text" class="{0}" placeholder="{1}" value="{2}"/>' , 'vp-gb-adv-method' , 'Type function name' , "'" + this . methodList [ 0 ] . value + "'" ) ;
438
+ page . appendFormatLine ( '<input type="text" class="{0}" placeholder="{1}" value="{2}"/>' , 'vp-gb-adv-method' , 'Type function name' , "'" + defaultMethod + "'" ) ;
424
439
// page.appendFormatLine('<i class="fa fa-search {0}"></i>', 'vp-gb-adv-method-return');
425
440
page . appendFormatLine ( '<img src="{0}" class="{1}" title="{2}">'
426
441
, '/nbextensions/visualpython/resource/arrow_left.svg' , 'vp-gb-adv-method-return' , 'Return to select method' ) ;
@@ -688,7 +703,6 @@ define([
688
703
$ ( document ) . on ( 'change' , this . _wrapSelector ( '#vp_gbDisplay' ) , function ( event ) {
689
704
var colList = event . colList ;
690
705
that . state . display = colList ;
691
- console . log ( 'display' , colList ) ;
692
706
} ) ;
693
707
694
708
// display select button event
@@ -732,7 +746,7 @@ define([
732
746
733
747
// reset index checkbox event
734
748
$ ( document ) . on ( 'change' , this . _wrapSelector ( '#vp_gbResetIndex' ) , function ( ) {
735
- that . state . resetIndex = $ ( this ) . prop ( 'checked' ) ;
749
+ that . state . resetIndex = $ ( this ) . val ( ) == 'yes' ;
736
750
} ) ;
737
751
738
752
//====================================================================
@@ -772,6 +786,7 @@ define([
772
786
if ( method == 'typing' ) {
773
787
// change it to typing input
774
788
$ ( parentDiv ) . find ( '.vp-gb-adv-method-selector' ) . hide ( ) ;
789
+ $ ( parentDiv ) . find ( '.vp-gb-adv-method' ) . val ( '' ) ;
775
790
$ ( parentDiv ) . find ( '.vp-gb-adv-method-box' ) . show ( ) ;
776
791
} else {
777
792
$ ( parentDiv ) . find ( '.vp-gb-adv-method' ) . val ( vpCommon . formatString ( "'{0}'" , method ) ) ;
@@ -780,7 +795,7 @@ define([
780
795
781
796
// return to selecting method
782
797
$ ( document ) . on ( 'click' , this . _wrapSelector ( '.vp-gb-adv-method-return' ) , function ( ) {
783
- var defaultValue = vpCommon . formatString ( "'{0}'" , that . methodList [ 0 ] . value ) ;
798
+ var defaultValue = '' ;
784
799
var parentDiv = $ ( this ) . parent ( ) . parent ( ) ;
785
800
$ ( parentDiv ) . find ( '.vp-gb-adv-method-selector' ) . val ( defaultValue ) ;
786
801
$ ( parentDiv ) . find ( '.vp-gb-adv-method' ) . val ( defaultValue ) ;
@@ -798,9 +813,15 @@ define([
798
813
799
814
// edit columns naming
800
815
$ ( document ) . on ( 'click' , this . _wrapSelector ( '.vp-gb-adv-naming-selector' ) , function ( ) {
801
- var columns = $ ( this ) . parent ( ) . find ( '.vp-gb-adv-col' ) . data ( 'list' ) ;
802
- var method = $ ( this ) . parent ( ) . find ( '.vp-gb-adv-method' ) . val ( ) ;
803
- that . openNamingPopup ( $ ( this ) . parent ( ) . find ( '.vp-gb-adv-naming' ) , columns , method ) ;
816
+ var parentDiv = $ ( this ) . parent ( ) ;
817
+ var columns = $ ( parentDiv ) . find ( '.vp-gb-adv-col' ) . data ( 'list' ) ;
818
+ var method = $ ( parentDiv ) . find ( '.vp-gb-adv-method' ) . val ( ) ;
819
+ if ( ! method || method == '' || method == "''" ) {
820
+ // set focus on selecting method tag
821
+ $ ( parentDiv ) . find ( '.vp-gb-adv-method-selector' ) . focus ( ) ;
822
+ return ;
823
+ }
824
+ that . openNamingPopup ( $ ( parentDiv ) . find ( '.vp-gb-adv-naming' ) , columns , method ) ;
804
825
} ) ;
805
826
806
827
// delete advanced item
@@ -1020,6 +1041,9 @@ define([
1020
1041
var advColumns = $ ( advItemTags [ i ] ) . find ( '.vp-gb-adv-col' ) . data ( 'list' ) ;
1021
1042
var advMethod = $ ( advItemTags [ i ] ) . find ( '.vp-gb-adv-method' ) . val ( ) ;
1022
1043
var advNaming = $ ( advItemTags [ i ] ) . find ( '.vp-gb-adv-naming' ) . data ( 'dict' ) ;
1044
+ if ( ! advMethod || advMethod == '' || advMethod == "''" ) {
1045
+ continue ;
1046
+ }
1023
1047
if ( advColumns && advColumns . length > 0 ) {
1024
1048
advColumns . forEach ( col => {
1025
1049
var naming = advNaming [ col ] ;
0 commit comments