Skip to content

Commit 414d6a0

Browse files
Merge pull request #4 from xdev-software/initial-condition-not-editable-after-editing
Bug Fix: Condition should be still editable/deletable/both after editing
2 parents 31e9129 + caa2cf8 commit 414d6a0

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

vaadin-simple-grid-filter/src/main/java/software/xdev/vaadin/FilterComponent.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,19 +369,24 @@ private void onAcceptFilter()
369369
final boolean deletable;
370370
final boolean editable;
371371

372-
// Check if it's an initial condition
373-
if(this.editingBadgeId != null && !this.editingBadgeId.equals(NO_BADGE_ID_STRING))
372+
if(this.deletingBadgeEnabled != null && this.editingBadgeEnabled != null)
374373
{
375374
deletable = this.deletingBadgeEnabled;
376375
editable = this.editingBadgeEnabled;
377376

378-
// Get customization rating from initial condition
379-
customizationDegree = this.initialChipBadges
380-
.stream()
381-
.filter(e -> e.getBadgeId().equals(this.editingBadgeId))
382-
.toList()
383-
.get(0)
384-
.getCustomizationRating();
377+
this.deletingBadgeEnabled = null;
378+
this.editingBadgeEnabled = null;
379+
380+
if(this.editingBadgeId != null)
381+
{
382+
// Get customization rating from initial condition
383+
customizationDegree = this.initialChipBadges
384+
.stream()
385+
.filter(e -> e.getBadgeId().equals(this.editingBadgeId))
386+
.toList()
387+
.get(0)
388+
.getCustomizationRating();
389+
}
385390
}
386391
else
387392
{
@@ -461,17 +466,15 @@ private void onAcceptFilter()
461466
// Make the cancel button invisible
462467
this.btnCancelFilter.setVisible(false);
463468

469+
// Needed to save state of the condition if it was editable/deletable before editing
470+
this.editingBadgeEnabled = badge.isBtnEditEnabled();
471+
this.deletingBadgeEnabled = badge.isBtnDeleteEnabled();
472+
473+
// Just activated when the url parameters are enabled
464474
// Set the customization rating for the filter select and condition select
465475
this.setUsedCustomizationDegreeForComponents(customizationDegree);
466476

467-
// Just activated when the url parameters are activated
468-
if(!this.identifier.isBlank())
469-
{
470-
this.editingBadgeId = badge.getBadgeId();
471-
// Needed for the acceptFilterBtn
472-
this.editingBadgeEnabled = badge.isBtnEditEnabled();
473-
this.deletingBadgeEnabled = badge.isBtnDeleteEnabled();
474-
}
477+
this.editingBadgeId = badge.getBadgeId();
475478

476479
// Remove filter, update grid
477480
this.removeChipBadgeCondition(badge);

0 commit comments

Comments
 (0)