From a905ed63c32e7f1240bb69bdc6ba9e0873a069a7 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 13 Mar 2024 15:51:54 +0100 Subject: [PATCH] SEBSERV-515 fixed delete actual multi selection on table filter change --- .../seb/sebserver/gui/table/EntityTable.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java index ddcbeb9d..d2e7315b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/table/EntityTable.java @@ -244,6 +244,7 @@ public class EntityTable { this.pageSize, this.sortColumn, this.sortOrder); + updateFilterUserAttrs(); } public String getName() { @@ -330,8 +331,9 @@ public class EntityTable { public void applyFilter() { try { - updateFilterUserAttrs(); - this.selectPage(1); + if (updateFilterUserAttrs()) { + this.selectPage(1); + } } catch (final Exception e) { log.error("Unexpected error while trying to apply filter: ", e); @@ -812,16 +814,27 @@ public class EntityTable { } } - private void updateFilterUserAttrs() { + private boolean updateFilterUserAttrs() { if (this.filter != null) { try { - this.pageService - .getCurrentUser() - .putAttribute(this.filterAttrName, this.filter.getFilterAttributes()); + + final CurrentUser currentUser = this.pageService.getCurrentUser(); + final String newFilterAttributes = this.filter.getFilterAttributes(); + final String oldFilterAttributes = currentUser.getAttribute(this.filterAttrName); + if(Objects.equals(newFilterAttributes, oldFilterAttributes)) { + return false; + } + if (multiselection != null) { + multiselection.clear(); + } + currentUser.putAttribute(this.filterAttrName, newFilterAttributes); + return true; } catch (final Exception e) { log.error("Failed to put filter attributes to current user attributes", e); + return true; } } + return false; } private void initFilterFromUserAttrs() { @@ -865,7 +878,7 @@ public class EntityTable { Arrays.asList(this.table.getItems()) .stream() .forEach(item -> { - final int index = this.table.indexOf(item); + final int index = this.table.indexOf(item); if (this.multiselection.contains(getModelId(item))) { if (!this.table.isSelected(index)) { this.table.select(index);