SEBSERV-515 fixed delete actual multi selection on table filter change

This commit is contained in:
anhefti 2024-03-13 15:51:54 +01:00
parent 2baf0d4caf
commit a905ed63c3

View file

@ -244,6 +244,7 @@ public class EntityTable<ROW extends ModelIdAware> {
this.pageSize, this.pageSize,
this.sortColumn, this.sortColumn,
this.sortOrder); this.sortOrder);
updateFilterUserAttrs();
} }
public String getName() { public String getName() {
@ -330,8 +331,9 @@ public class EntityTable<ROW extends ModelIdAware> {
public void applyFilter() { public void applyFilter() {
try { try {
updateFilterUserAttrs(); if (updateFilterUserAttrs()) {
this.selectPage(1); this.selectPage(1);
}
} catch (final Exception e) { } catch (final Exception e) {
log.error("Unexpected error while trying to apply filter: ", e); log.error("Unexpected error while trying to apply filter: ", e);
@ -812,16 +814,27 @@ public class EntityTable<ROW extends ModelIdAware> {
} }
} }
private void updateFilterUserAttrs() { private boolean updateFilterUserAttrs() {
if (this.filter != null) { if (this.filter != null) {
try { try {
this.pageService
.getCurrentUser() final CurrentUser currentUser = this.pageService.getCurrentUser();
.putAttribute(this.filterAttrName, this.filter.getFilterAttributes()); 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) { } catch (final Exception e) {
log.error("Failed to put filter attributes to current user attributes", e); log.error("Failed to put filter attributes to current user attributes", e);
return true;
} }
} }
return false;
} }
private void initFilterFromUserAttrs() { private void initFilterFromUserAttrs() {
@ -865,7 +878,7 @@ public class EntityTable<ROW extends ModelIdAware> {
Arrays.asList(this.table.getItems()) Arrays.asList(this.table.getItems())
.stream() .stream()
.forEach(item -> { .forEach(item -> {
final int index = this.table.indexOf(item); final int index = this.table.indexOf(item);
if (this.multiselection.contains(getModelId(item))) { if (this.multiselection.contains(getModelId(item))) {
if (!this.table.isSelected(index)) { if (!this.table.isSelected(index)) {
this.table.select(index); this.table.select(index);