Search in sources :

Example 1 with DatabaseService

use of org.komunumo.data.service.DatabaseService in project komunumo-server by komunumo.

the class MembersView method afterNavigation.

@Override
public void afterNavigation(@NotNull final AfterNavigationEvent afterNavigationEvent) {
    final var url = afterNavigationEvent.getLocation().getPath();
    final var subMenu = new SubMenu();
    databaseService.getPages(PageParent.Members).forEach(page -> subMenu.add(new SubMenuItem(page.getCompletePageUrl(), page.getTitle(), url.equals(page.getCompletePageUrl()))));
    subMenu.add(new SubMenuItem("/members/feedback", "Feedback", url.equals("members/feedback")));
    setSubMenu(subMenu);
    if (url.equals("members/feedback")) {
        setContent(createFeedbackForm());
    } else if (url.contains("/")) {
        final var page = loadPage(databaseService, url);
        this.getUI().ifPresent(ui -> ui.getPage().setTitle("%s: %s".formatted(databaseService.configuration().getWebsiteName(), page != null ? page.getTitle() : "Members")));
    }
}
Also used : BeforeEnterEvent(com.vaadin.flow.router.BeforeEnterEvent) Component(com.vaadin.flow.component.Component) CssImport(com.vaadin.flow.component.dependency.CssImport) TextArea(com.vaadin.flow.component.textfield.TextArea) Div(com.vaadin.flow.component.html.Div) Route(com.vaadin.flow.router.Route) RouteAlias(com.vaadin.flow.router.RouteAlias) ContentBlock(org.komunumo.ui.view.website.ContentBlock) SubMenuItem(org.komunumo.ui.view.website.SubMenuItem) Paragraph(com.vaadin.flow.component.html.Paragraph) TextField(com.vaadin.flow.component.textfield.TextField) BeforeEnterObserver(com.vaadin.flow.router.BeforeEnterObserver) ValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode) Serial(java.io.Serial) PageParent(org.komunumo.data.db.enums.PageParent) WebsiteLayout(org.komunumo.ui.view.website.WebsiteLayout) ButtonVariant(com.vaadin.flow.component.button.ButtonVariant) EmailField(com.vaadin.flow.component.textfield.EmailField) SubMenu(org.komunumo.ui.view.website.SubMenu) H2(com.vaadin.flow.component.html.H2) FormLayout(com.vaadin.flow.component.formlayout.FormLayout) DatabaseService(org.komunumo.data.service.DatabaseService) Button(com.vaadin.flow.component.button.Button) List(java.util.List) AfterNavigationEvent(com.vaadin.flow.router.AfterNavigationEvent) AnonymousAllowed(com.vaadin.flow.server.auth.AnonymousAllowed) NotNull(org.jetbrains.annotations.NotNull) AfterNavigationObserver(com.vaadin.flow.router.AfterNavigationObserver) SubMenuItem(org.komunumo.ui.view.website.SubMenuItem) SubMenu(org.komunumo.ui.view.website.SubMenu)

Aggregations

Component (com.vaadin.flow.component.Component)1 Button (com.vaadin.flow.component.button.Button)1 ButtonVariant (com.vaadin.flow.component.button.ButtonVariant)1 CssImport (com.vaadin.flow.component.dependency.CssImport)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 Div (com.vaadin.flow.component.html.Div)1 H2 (com.vaadin.flow.component.html.H2)1 Paragraph (com.vaadin.flow.component.html.Paragraph)1 EmailField (com.vaadin.flow.component.textfield.EmailField)1 TextArea (com.vaadin.flow.component.textfield.TextArea)1 TextField (com.vaadin.flow.component.textfield.TextField)1 ValueChangeMode (com.vaadin.flow.data.value.ValueChangeMode)1 AfterNavigationEvent (com.vaadin.flow.router.AfterNavigationEvent)1 AfterNavigationObserver (com.vaadin.flow.router.AfterNavigationObserver)1 BeforeEnterEvent (com.vaadin.flow.router.BeforeEnterEvent)1 BeforeEnterObserver (com.vaadin.flow.router.BeforeEnterObserver)1 Route (com.vaadin.flow.router.Route)1 RouteAlias (com.vaadin.flow.router.RouteAlias)1 AnonymousAllowed (com.vaadin.flow.server.auth.AnonymousAllowed)1 Serial (java.io.Serial)1