76
76
import software .xdev .vaadin .daterange_picker .ui .DateRangePicker ;
77
77
import software .xdev .vaadin .model .ChipBadge ;
78
78
import software .xdev .vaadin .model .ChipBadgeExtension ;
79
+ import software .xdev .vaadin .model .CustomizationDegree ;
79
80
import software .xdev .vaadin .model .FilterCondition ;
80
81
import software .xdev .vaadin .model .FilterField ;
81
82
import software .xdev .vaadin .model .FilterFieldEnumExtension ;
@@ -296,9 +297,6 @@ else if(this.selOperations.getValue() != null)
296
297
297
298
private void onShowFilterInput ()
298
299
{
299
- // Needed if the previous condition was an editable initial condition
300
- // The editable initial condition makes the cancel button invisible
301
- this .btnCancelFilter .setVisible (true );
302
300
303
301
if (this .hlFilter .getChildren ().findAny ().isEmpty ())
304
302
{
@@ -307,8 +305,10 @@ private void onShowFilterInput()
307
305
this .btnCancelFilter .setVisible (true );
308
306
309
307
this .selFields .setValue (null );
308
+ this .selFields .setReadOnly (false );
310
309
this .selOperations .setItems (Collections .emptyList ());
311
310
this .selOperations .setEnabled (false );
311
+ this .selOperations .setReadOnly (false );
312
312
this .btnAcceptFilter .setEnabled (false );
313
313
this .txtSearchQuery .clear ();
314
314
this .nmbSearchQuery .clear ();
@@ -318,7 +318,6 @@ private void onShowFilterInput()
318
318
this .setInputComponentVisibility (String .class );
319
319
320
320
this .hlFilter .add (
321
-
322
321
this .selFields ,
323
322
this .selOperations ,
324
323
this .txtSearchQuery ,
@@ -333,6 +332,30 @@ private void onShowFilterInput()
333
332
}
334
333
}
335
334
335
+ /**
336
+ * Method used to make the select field and select condition dependent on the customization degree readonly.
337
+ *
338
+ * @param usedCustomizationDegree Used to set which input field is readonly.
339
+ */
340
+ private void setUsedCustomizationDegreeForComponents (final CustomizationDegree usedCustomizationDegree )
341
+ {
342
+ if (usedCustomizationDegree .equals (CustomizationDegree .INPUT_VALUE ))
343
+ {
344
+ this .selFields .setReadOnly (true );
345
+ this .selOperations .setReadOnly (true );
346
+ }
347
+ else if (usedCustomizationDegree .equals (CustomizationDegree .CONDITION_AND_INPUT_VALUE ))
348
+ {
349
+ this .selFields .setReadOnly (true );
350
+ this .selOperations .setReadOnly (false );
351
+ }
352
+ else
353
+ {
354
+ this .selFields .setReadOnly (false );
355
+ this .selOperations .setReadOnly (false );
356
+ }
357
+ }
358
+
336
359
/**
337
360
* Clicking on the accept filter button.
338
361
*/
@@ -341,6 +364,7 @@ private void onAcceptFilter()
341
364
final String userInput = this .getValueFromVisibleComponent ();
342
365
343
366
final ChipBadgeExtension <FilterCondition <T , ?>> badge ;
367
+ CustomizationDegree customizationDegree = CustomizationDegree .EVERYTHING ;
344
368
final boolean deletable ;
345
369
final boolean editable ;
346
370
@@ -349,6 +373,14 @@ private void onAcceptFilter()
349
373
{
350
374
deletable = this .deletingBadgeEnabled ;
351
375
editable = this .editingBadgeEnabled ;
376
+
377
+ // Get customization rating from initial condition
378
+ customizationDegree = this .initialChipBadges
379
+ .stream ()
380
+ .filter (e -> e .getBadgeId ().equals (this .editingBadgeId ))
381
+ .toList ()
382
+ .get (0 )
383
+ .getCustomizationRating ();
352
384
}
353
385
else
354
386
{
@@ -361,7 +393,8 @@ private void onAcceptFilter()
361
393
this .selOperations .getValue (),
362
394
userInput ,
363
395
deletable ,
364
- editable );
396
+ editable ,
397
+ customizationDegree );
365
398
366
399
if (!this .identifier .isBlank ())
367
400
{
@@ -390,7 +423,8 @@ private void onAcceptFilter()
390
423
final FilterComparator selOperation ,
391
424
final String userInput ,
392
425
final boolean deletableCondition ,
393
- final boolean editableCondition )
426
+ final boolean editableCondition ,
427
+ final CustomizationDegree customizationDegree )
394
428
{
395
429
final ChipBadgeExtension <FilterCondition <T , ?>> badge = new ChipBadgeExtension <>(
396
430
new FilterCondition <>(
@@ -426,6 +460,9 @@ private void onAcceptFilter()
426
460
// Make the cancel button invisible
427
461
this .btnCancelFilter .setVisible (false );
428
462
463
+ // Set the customization rating for the filter select and condition select
464
+ this .setUsedCustomizationDegreeForComponents (customizationDegree );
465
+
429
466
// Just activated when the url parameters are activated
430
467
if (!this .identifier .isBlank ())
431
468
{
@@ -841,15 +878,30 @@ private void createConditionsFromQueryParameters()
841
878
{
842
879
if (!this .queryBadgeIdList .get (i ).equals (DELETED_INITIAL_CONDITION_STRING ))
843
880
{
881
+ final String badgeId = this .queryBadgeIdList .get (i );
882
+ CustomizationDegree customizationDegree = CustomizationDegree .EVERYTHING ;
883
+
884
+ // Check if it's an initial condition
885
+ final List <ChipBadgeExtension <FilterCondition <T , ?>>> cD = this .initialChipBadges
886
+ .stream ()
887
+ .filter (e -> e .getBadgeId ().equals (badgeId ))
888
+ .toList ();
889
+
890
+ if (!cD .isEmpty ())
891
+ {
892
+ customizationDegree = cD .get (0 ).getCustomizationRating ();
893
+ }
894
+
844
895
final ChipBadgeExtension <FilterCondition <T , ?>> chipBadgeExtension =
845
896
this .createBadgeConditionAndApplyFilter (
846
897
filterField ,
847
898
comparatorOptional .get (),
848
899
this .queryInputFieldList .get (i ),
849
900
Boolean .parseBoolean (this .queryBadgeDeletableList .get (i )),
850
- Boolean .parseBoolean (this .queryBadgeEditableList .get (i )));
901
+ Boolean .parseBoolean (this .queryBadgeEditableList .get (i )),
902
+ customizationDegree );
851
903
852
- chipBadgeExtension .setBadgeId (this . queryBadgeIdList . get ( i ) );
904
+ chipBadgeExtension .setBadgeId (badgeId );
853
905
}
854
906
else
855
907
{
@@ -1349,6 +1401,7 @@ public FilterComponent<T> withInitialFilter(
1349
1401
final String searchQuery ,
1350
1402
final boolean conditionDeletable ,
1351
1403
final boolean conditionEditable ,
1404
+ final CustomizationDegree customizationDegree ,
1352
1405
final String badgeId )
1353
1406
{
1354
1407
FilterField <T , ?> finalFilterField = filterField ;
@@ -1381,11 +1434,14 @@ public FilterComponent<T> withInitialFilter(
1381
1434
selectedCondition ,
1382
1435
searchQuery ,
1383
1436
conditionDeletable ,
1384
- conditionEditable );
1437
+ conditionEditable ,
1438
+ customizationDegree );
1385
1439
1386
1440
// Just needed if the url parameters are activated
1387
1441
chipBadge .setBadgeId (badgeId );
1388
1442
1443
+ chipBadge .setCustomizationRating (customizationDegree );
1444
+
1389
1445
// Needed for resetting the conditions
1390
1446
this .initialChipBadges .add (chipBadge );
1391
1447
@@ -1414,6 +1470,30 @@ public FilterComponent<T> withInitialFilter(
1414
1470
searchQuery ,
1415
1471
conditionDeletable ,
1416
1472
conditionEditable ,
1473
+ CustomizationDegree .EVERYTHING ,
1474
+ String .valueOf (this .initialConditionIdCounter ));
1475
+
1476
+ this .initialConditionIdCounter ++;
1477
+
1478
+ return filterComponent ;
1479
+ }
1480
+
1481
+ public FilterComponent <T > withInitialFilter (
1482
+ final FilterField <T , ?> filterField ,
1483
+ final FilterComparator selectedCondition ,
1484
+ final String searchQuery ,
1485
+ final boolean conditionDeletable ,
1486
+ final boolean conditionEditable ,
1487
+ final CustomizationDegree customizationDegree )
1488
+ {
1489
+ final FilterComponent <T > filterComponent =
1490
+ this .withInitialFilter (
1491
+ filterField ,
1492
+ selectedCondition ,
1493
+ searchQuery ,
1494
+ conditionDeletable ,
1495
+ conditionEditable ,
1496
+ customizationDegree ,
1417
1497
String .valueOf (this .initialConditionIdCounter ));
1418
1498
1419
1499
this .initialConditionIdCounter ++;
0 commit comments