@@ -132,7 +132,7 @@ define([
132
132
// set button next to input tag
133
133
var buttonTag = new com_String ( ) ;
134
134
buttonTag . appendFormat ( '<button type="button" class="{0} {1} {2}">{3}</button>' ,
135
- VP_DS_BTN , this . uuid , 'vp-button' , 'Edit ' ) ;
135
+ VP_DS_BTN , this . uuid , 'vp-button' , 'Subset ' ) ;
136
136
if ( this . pageThis ) {
137
137
$ ( this . targetSelector ) . parent ( ) . append ( buttonTag . toString ( ) ) ;
138
138
}
@@ -448,12 +448,7 @@ define([
448
448
449
449
tag . appendLine ( '<div class="vp-td-line">' ) ;
450
450
tag . appendLine ( this . templateForConditionColumnInput ( colList ) ) ;
451
- tag . appendFormatLine ( '<select class="{0} {1}">' , 'vp-select s' , 'vp-oper-list' ) ;
452
- var operList = [ '' , '==' , '!=' , 'contains' , 'not contains' , '<' , '<=' , '>' , '>=' , 'starts with' , 'ends with' ] ;
453
- operList . forEach ( oper => {
454
- tag . appendFormatLine ( '<option value="{0}">{1}</option>' , oper , oper ) ;
455
- } ) ;
456
- tag . appendLine ( '</select>' ) ;
451
+ tag . appendLine ( this . templateForConditionOperator ( '' ) ) ;
457
452
tag . appendLine ( '<input class="vp-input m vp-condition" type="text" placeholder="Value"/>' ) ;
458
453
tag . appendLine ( '</div>' ) ;
459
454
@@ -491,6 +486,22 @@ define([
491
486
tag . appendLine ( '</select>' ) ;
492
487
return tag . toString ( ) ;
493
488
}
489
+ templateForConditionOperator ( dtype = 'object' ) {
490
+ var tag = new com_String ( ) ;
491
+ tag . appendFormatLine ( '<select class="{0} {1}">' , 'vp-select s' , 'vp-oper-list' ) ;
492
+ var operList = [ '' , '==' , '!=' , '<' , '<=' , '>' , '>=' , 'contains' , 'not contains' , 'starts with' , 'ends with' , 'isnull()' , 'notnull()' ] ;
493
+ if ( dtype == '' ) {
494
+ // .index
495
+ operList = [ '' , '==' , '!=' , '<' , '<=' , '>' , '>=' ] ;
496
+ } else if ( dtype != 'object' ) {
497
+ operList = [ '' , '==' , '!=' , '<' , '<=' , '>' , '>=' , 'isnull()' , 'notnull()' ] ;
498
+ }
499
+ operList . forEach ( oper => {
500
+ tag . appendFormatLine ( '<option value="{0}">{1}</option>' , oper , oper ) ;
501
+ } ) ;
502
+ tag . appendLine ( '</select>' ) ;
503
+ return tag . toString ( ) ;
504
+ }
494
505
templateForConditionCondInput ( category , dtype = 'object' ) {
495
506
var vpCondSuggest = new SuggestInput ( ) ;
496
507
vpCondSuggest . addClass ( 'vp-input m vp-condition' ) ;
@@ -1331,17 +1342,22 @@ define([
1331
1342
that . generateCode ( ) ;
1332
1343
} ) ;
1333
1344
1345
+ // change column selection for condition page
1334
1346
$ ( document ) . on ( 'change' , this . wrapSelector ( '.vp-ds-cond-tbl .vp-col-list' ) , function ( ) {
1335
1347
var thisTag = $ ( this ) ;
1336
1348
var varName = that . state . pandasObject ;
1337
1349
var colName = $ ( this ) . find ( 'option:selected' ) . attr ( 'data-code' ) ;
1338
1350
var colDtype = $ ( this ) . find ( 'option:selected' ) . attr ( 'data-dtype' ) ;
1339
1351
1352
+ var operTag = $ ( this ) . closest ( 'td' ) . find ( '.vp-oper-list' ) ;
1340
1353
var condTag = $ ( this ) . closest ( 'td' ) . find ( '.vp-condition' ) ;
1341
1354
1342
1355
if ( colName == '.index' ) {
1343
1356
// index
1344
1357
$ ( thisTag ) . closest ( 'td' ) . find ( '.vp-cond-use-text' ) . prop ( 'checked' , false ) ;
1358
+ $ ( operTag ) . replaceWith ( function ( ) {
1359
+ return that . templateForConditionOperator ( '' ) ;
1360
+ } ) ;
1345
1361
$ ( condTag ) . replaceWith ( function ( ) {
1346
1362
return that . templateForConditionCondInput ( [ ] , '' ) ;
1347
1363
} ) ;
@@ -1358,12 +1374,18 @@ define([
1358
1374
} else {
1359
1375
$ ( thisTag ) . closest ( 'td' ) . find ( '.vp-cond-use-text' ) . prop ( 'checked' , false ) ;
1360
1376
}
1377
+ $ ( operTag ) . replaceWith ( function ( ) {
1378
+ return that . templateForConditionOperator ( colDtype ) ;
1379
+ } ) ;
1361
1380
$ ( condTag ) . replaceWith ( function ( ) {
1362
1381
return that . templateForConditionCondInput ( category , colDtype ) ;
1363
1382
} ) ;
1364
1383
that . generateCode ( ) ;
1365
1384
} catch {
1366
1385
$ ( thisTag ) . closest ( 'td' ) . find ( '.vp-cond-use-text' ) . prop ( 'checked' , false ) ;
1386
+ $ ( operTag ) . replaceWith ( function ( ) {
1387
+ return that . templateForConditionOperator ( colDtype ) ;
1388
+ } ) ;
1367
1389
$ ( condTag ) . replaceWith ( function ( ) {
1368
1390
return that . templateForConditionCondInput ( [ ] , colDtype ) ;
1369
1391
} ) ;
@@ -1373,6 +1395,23 @@ define([
1373
1395
}
1374
1396
} ) ;
1375
1397
1398
+ // change operator selection
1399
+ $ ( document ) . on ( 'change' , this . wrapSelector ( '.vp-ds-cond-tbl .vp-oper-list' ) , function ( ) {
1400
+ var oper = $ ( this ) . val ( ) ;
1401
+ var condTag = $ ( this ) . closest ( 'td' ) . find ( '.vp-condition' ) ;
1402
+ var useTextTag = $ ( this ) . closest ( 'td' ) . find ( '.vp-cond-use-text' ) ;
1403
+ // var colDtype = $(this).closest('td').find('.vp-col-list option:selected').attr('data-dtype');
1404
+
1405
+ // if operator is isnull(), notnull(), disable condition input
1406
+ if ( oper == 'isnull()' || oper == 'notnull()' ) {
1407
+ $ ( condTag ) . prop ( 'disabled' , true ) ;
1408
+ $ ( useTextTag ) . prop ( 'disabled' , true ) ;
1409
+ } else {
1410
+ $ ( condTag ) . prop ( 'disabled' , false ) ;
1411
+ $ ( useTextTag ) . prop ( 'disabled' , false ) ;
1412
+ }
1413
+ } ) ;
1414
+
1376
1415
// use text
1377
1416
$ ( document ) . on ( 'change' , this . wrapSelector ( '.vp-ds-cond-tbl .vp-cond-use-text' ) , function ( ) {
1378
1417
that . generateCode ( ) ;
@@ -1507,6 +1546,8 @@ define([
1507
1546
rowSelection . appendFormat ( '{0}.str.startswith({1})' , colValue , condValue ) ;
1508
1547
} else if ( oper == 'ends with' ) {
1509
1548
rowSelection . appendFormat ( '{0}.str.endswith({1})' , colValue , condValue ) ;
1549
+ } else if ( oper == 'isnull()' || oper == 'notnull()' ) {
1550
+ rowSelection . appendFormat ( '{0}.{1}' , colValue , oper ) ;
1510
1551
} else {
1511
1552
rowSelection . appendFormat ( '{0}{1}{2}' , colValue , oper != '' ?( ' ' + oper ) :'' , condValue != '' ?( ' ' + condValue ) :'' ) ;
1512
1553
}
@@ -1538,6 +1579,8 @@ define([
1538
1579
rowSelection . appendFormat ( '{0}.str.startswith({1})' , colValue , condValue ) ;
1539
1580
} else if ( oper == 'ends with' ) {
1540
1581
rowSelection . appendFormat ( '{0}.str.endswith({1})' , colValue , condValue ) ;
1582
+ } else if ( oper == 'isnull()' || oper == 'notnull()' ) {
1583
+ rowSelection . appendFormat ( '{0}.{1}' , colValue , oper ) ;
1541
1584
} else {
1542
1585
rowSelection . appendFormat ( '{0}{1}{2}' , colValue , oper != '' ?( ' ' + oper ) :'' , condValue != '' ?( ' ' + condValue ) :'' ) ;
1543
1586
}
0 commit comments