Skip to content

Commit

Permalink
Hieararchical menu support
Browse files Browse the repository at this point in the history
  • Loading branch information
mstahv committed Nov 7, 2024
1 parent fda0b85 commit dd7fae8
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 23 deletions.
18 changes: 3 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,10 @@
<parent>
<groupId>in.virit.sb</groupId>
<artifactId>viritin-project-parent</artifactId>
<version>0.0.7</version>
<version>0.0.9</version>
<relativePath/>
</parent>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>24.4.13</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -68,7 +56,7 @@
<dependency>
<groupId>org.parttio</groupId>
<artifactId>tinymce-for-flow</artifactId>
<version>4.2.1</version>
<version>4.2.4</version>
</dependency>

<dependency>
Expand All @@ -86,7 +74,7 @@
<dependency>
<groupId>in.virit</groupId>
<artifactId>viritin</artifactId>
<version>2.9.3</version>
<version>2.10.1</version>
</dependency>

</dependencies>
Expand Down
Binary file modified src/main/bundles/dev.bundle
Binary file not shown.
Binary file modified src/main/bundles/prod.bundle
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.time.LocalDate;

@Route(layout = DefaultLayout.class)
@MenuItem(title = "MapLibre JTS editors", icon = VaadinIcon.MAP_MARKER)
@MenuItem(title = "MapLibre JTS editors", icon = VaadinIcon.MAP_MARKER, parent = MapLibreMenuGroup.class)
@Addon("maplibregl--add-on")
public class MapLibreJTSEditorsView extends VerticalLayout {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example.views.maplibre;

import org.vaadin.firitin.appframework.MenuItem;

@MenuItem(title = "MapLibre", openByDefault = true)
public class MapLibreMenuGroup {
}
2 changes: 1 addition & 1 deletion src/main/java/org/example/views/maplibre/MapLibreView.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.net.URISyntaxException;

@Route(layout = DefaultLayout.class)
@MenuItem(title = "MapLibreGL JS", icon = VaadinIcon.MAP_MARKER)
@MenuItem(title = "MapLibreGL JS", order = MenuItem.BEGINNING, icon = VaadinIcon.GLOBE, parent = MapLibreMenuGroup.class)
@Addon("maplibregl--add-on")
public class MapLibreView extends VerticalLayout {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.example.views;
package org.example.views.viritin;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.icon.VaadinIcon;
Expand All @@ -22,7 +22,7 @@
import java.util.Set;

@Route(layout = DefaultLayout.class)
@MenuItem(icon = VaadinIcon.EDIT)
@MenuItem(icon = VaadinIcon.EDIT, parent = ViritinMenuGroup.class)
@Addon("flow-viritin")
public class FormFieldsView extends BeanValidationForm<FormFieldsView.MyRecord> {

Expand Down
51 changes: 51 additions & 0 deletions src/main/java/org/example/views/viritin/MainLayoutView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.example.views.viritin;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
import org.example.Addon;
import org.example.DefaultLayout;
import org.vaadin.firitin.appframework.MenuItem;
import org.vaadin.firitin.components.RichText;
import org.vaadin.firitin.fields.CommaSeparatedStringField;
import org.vaadin.firitin.fields.DurationField;
import org.vaadin.firitin.fields.ElementCollectionField;
import org.vaadin.firitin.fields.EnumSelect;
import org.vaadin.firitin.form.BeanValidationForm;

import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

@Route(layout = DefaultLayout.class)
@MenuItem(icon = VaadinIcon.LAYOUT, parent = ViritinMenuGroup.class)
@Addon("flow-viritin")
public class MainLayoutView extends VerticalLayout {

public MainLayoutView() {
add(new RichText().withMarkDown("""
# AppLayout with automatic menu for small to medium size applications
Viritin provides a simple way to create a main layout and top level navigation for your application.
Nowadays based on the AppLayout and SideNav components from the Vaadin core.
This example uses this MainLayout component of which the DefaultLayout is a subclass.
The menu is built automatically for views that define the DefaultLayout as their layout.
*Add a view to your app -> it automatically appears in the menu.*
Only views for which the user has access (role based check) are shown in the menu and
dynamically registered routes are supported.
To customize the menu (icons, order, custom title etc), you can use the *@MenuItem annotation*.
In Vaadin 24.5 and later Vaadin ships a similar in nature @Menu annotation. Latest Viritin
versions support both annotations, but to define hierarcy and some other more advanced features
you need to use the Viritin specific @MenuItem annotation.
"""));
}

}

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.example.views;
package org.example.views.viritin;

import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.grid.GridSortOrder;
Expand All @@ -16,7 +16,7 @@
import org.vaadin.firitin.components.grid.PagingGrid;

@Route(layout = DefaultLayout.class)
@MenuItem(icon = VaadinIcon.EDIT)
@MenuItem(icon = VaadinIcon.GRID, parent = ViritinMenuGroup.class)
@Addon("flow-viritin")
public class PagingGridView extends VerticalLayout {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.example.views;
package org.example.views.viritin;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -29,7 +29,7 @@
import java.util.Locale;

@Route(layout = DefaultLayout.class)
@MenuItem(icon = VaadinIcon.PRINT)
@MenuItem(icon = VaadinIcon.PRINT, parent = ViritinMenuGroup.class)
@Addon("flow-viritin")
public class PrettyPrintingView extends VVerticalLayout {

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/example/views/viritin/ViritinMenuGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example.views.viritin;

import org.vaadin.firitin.appframework.MenuItem;

@MenuItem(title = "Viritin", openByDefault = true)
public class ViritinMenuGroup {
}

0 comments on commit dd7fae8

Please sign in to comment.