fix: deleting category when not possible
This commit is contained in:
parent
e916e6edff
commit
31d2f27728
1 changed files with 6 additions and 2 deletions
|
@ -25,9 +25,8 @@ import com.vaadin.flow.router.BeforeEnterEvent;
|
|||
import com.vaadin.flow.router.BeforeEnterObserver;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.data.VaadinSpringDataHelpers;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.orm.ObjectOptimisticLockingFailureException;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -133,6 +132,11 @@ public class CategoriesView extends Div implements BeforeEnterObserver {
|
|||
"Error updating the data. Somebody else has updated the record while you were making changes.");
|
||||
n.setPosition(Notification.Position.MIDDLE);
|
||||
n.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||
} catch (DataIntegrityViolationException ex) {
|
||||
Notification n = Notification.show(
|
||||
"Cannot delete this category as it is associated with existing expenses.");
|
||||
n.setPosition(Notification.Position.MIDDLE);
|
||||
n.addThemeVariants(NotificationVariant.LUMO_ERROR);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue