From 7074b8890b586a4704cd50ebe10281a06b3af871 Mon Sep 17 00:00:00 2001 From: Aleksandar Zivkovic Date: Wed, 21 Feb 2024 19:42:53 +0100 Subject: [PATCH] fix grid dataprovider not reloading on change use filter method when view is built make grid use full height Signed-off-by: Aleksandar Zivkovic --- .../com/samic/samic/components/UIFactory.java | 14 +++++++++++ .../FreieLagerobjekteView.java | 23 +++++++------------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/samic/samic/components/UIFactory.java b/src/main/java/com/samic/samic/components/UIFactory.java index 13a54b7..c9edf39 100644 --- a/src/main/java/com/samic/samic/components/UIFactory.java +++ b/src/main/java/com/samic/samic/components/UIFactory.java @@ -33,6 +33,13 @@ public static VerticalLayout rootComponentContainer(String heading, Component... return container; } + public static VerticalLayout rootComponentContainerFullHeight(String heading, + Component... containers) { + VerticalLayout container = rootComponentContainer(heading, containers); + container.setHeightFull(); + return container; + } + public static HorizontalLayout childContainer( FlexComponent.JustifyContentMode justifyContentMode, Component... components) { // Create container @@ -50,6 +57,13 @@ public static HorizontalLayout childContainer( return childContainer; } + public static HorizontalLayout childContainerFullHeight( + FlexComponent.JustifyContentMode justifyContentMode, Component... components) { + HorizontalLayout childContainer = childContainer(justifyContentMode, components); + childContainer.setHeightFull(); + return childContainer; + } + ///////////---------------------BUTTONS≈---------------------/////////// public static Button btnPrimary( String text, ComponentEventListener> listener) { diff --git a/src/main/java/com/samic/samic/views/freie_lagerobjekte/FreieLagerobjekteView.java b/src/main/java/com/samic/samic/views/freie_lagerobjekte/FreieLagerobjekteView.java index 1c7bd05..81fd5b3 100644 --- a/src/main/java/com/samic/samic/views/freie_lagerobjekte/FreieLagerobjekteView.java +++ b/src/main/java/com/samic/samic/views/freie_lagerobjekte/FreieLagerobjekteView.java @@ -92,6 +92,9 @@ private void initUI() { .setAutoWidth(true).setFrozenToEnd(true); grid.setItemDetailsRenderer(createStorageObjectDetailsRenderer()); grid.getStyle().setBorder("0px"); + grid.setHeightFull(); + + setHeightFull(); filterStorage.setItemLabelGenerator(Storage::getName); filterStorage.setItems(storageService.findAll().toList()); @@ -105,20 +108,8 @@ private void initUI() { filterObjectType.setPlaceholder("Gerätetyp auswählen"); filterObjectType.setWidth("250px"); - //GridListDataView storageObjectList; - - grid.setItems(storageObjectService.findFreeStorageObjects().toList()); - /*listFilteredStorageObjects(searchField.getValue(), filterStorage.getValue() - .getId());*/ -/* try { - storageObjectList = grid.setItems(listFilteredStorageObjects(searchField.getValue(), filterStorage.getValue() - .getId())); - } catch (SamicException e) { - storageObjectList = grid.setItems(List.of()); - UIFactory.notificationError(e.getMessage()).open(); - }*/ + listFilteredStorageObjects("%", filterStorage.getValue().getId()); - //GridListDataView finalStorageObjectList = storageObjectList; searchField.addValueChangeListener( e -> listFilteredStorageObjects(e.getValue(), filterStorage.getValue() .getId())); @@ -133,8 +124,8 @@ private void initUI() { filterStorage, filterObjectType )), - UIFactory.rootComponentContainer("", - UIFactory.childContainer( + UIFactory.rootComponentContainerFullHeight("", + UIFactory.childContainerFullHeight( JustifyContentMode.START, grid)), reservationDialog); @@ -165,6 +156,7 @@ private void reserve() { reservationDialog.close(); UIFactory.notificationSuccess("Reservierung erfolgreich durchgeführt").open(); + grid.getDataProvider().refreshAll(); } private ComponentRenderer createStorageObjectDetailsRenderer() { @@ -186,6 +178,7 @@ private void addToUser(StorageObject item) { storageObjectService.saveStorageObject(item); UIFactory.notificationSuccess("Lagerobjekt erfolgreich deinem Lager hinzugefügt").open(); + grid.getDataProvider().refreshAll(); }