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.sortColumn,
this.sortOrder);
updateFilterUserAttrs();
}
public String getName() {
@ -330,8 +331,9 @@ public class EntityTable<ROW extends ModelIdAware> {
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<ROW extends ModelIdAware> {
}
}
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<ROW extends ModelIdAware> {
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);