# NAME

Mojolicious::Plugin::Fondation::Menu - Dynamic menu management plugin for Fondation — navbar, breadcrumb

# VERSION

version 0.04

# SYNOPSIS

    # myapp.conf
    {
        'Fondation' => {
            dependencies => [
                { 'Fondation::Model::DBIx::Async' => {
                    backends => [ main => {
                        dsn          => 'dbi:SQLite:dbname=data/app.db',
                        schema_class => 'MySchema',
                    }],
                }},
                'Fondation::Menu',
            ],
        },
    }

# DESCRIPTION

[Mojolicious::Plugin::Fondation::Menu](https://metacpan.org/pod/Mojolicious%3A%3APlugin%3A%3AFondation%3A%3AMenu) provides dynamic menu management.
Menus are declared declaratively via `share/menus.json` in each plugin
and synchronized with the database via `menu sync`.

## Schema

    id          INTEGER PRIMARY KEY AUTOINCREMENT
    title       TEXT NOT NULL
    link        TEXT
    icon        TEXT          (FontAwesome class)
    icon_color  TEXT          (CSS color)
    name        TEXT NOT NULL DEFAULT 'left'  (menu group)
    condition   TEXT          ("group:NAME", "perm:NAME", or "")
    sort_order  INTEGER DEFAULT 0
    parent_id   INTEGER NOT NULL DEFAULT 0
    open_tab    INTEGER DEFAULT 0
    view_in_menu INTEGER DEFAULT 1
    description TEXT
    created_at  TEXT
    updated_at  TEXT

## menus.json format

Each plugin can ship a `share/menus.json`:

    [
      {
        "title":        "Administration",
        "link":         "/admin",
        "icon":         "fas fa-lock-open",
        "menu":         "admin_menu",
        "condition":    "group:administrateur",
        "order":        1,
        "parent_title": null,
        "description":  "Admin panel"
      },
      {
        "title":        "Users",
        "link":         "/users",
        "menu":         "admin_menu",
        "parent_title": "Administration"
      }
    ]

Fields: `title` (required), `link`, `icon`, `icon_color`,
`menu` (group name, default "left"), `condition`, `order`
(auto if absent), `parent_title`, `open_tab`, `view_in_menu`,
`description`.

## Commands

    myapp.pl menu sync       Sync menu entries from share/menus.json

## Helpers

    $c->menus
    $c->menu_by_name('left_menu')
    $c->menu_by_id(42)
    $c->breadcrumb
    $c->check_menu_condition('group:admin')
    $c->render_menu('left_menu')
    $c->render_menu_breadcrumb

## REST API (auto-generated by OpenAPI)

    GET    /api/menu
    POST   /api/menu
    GET    /api/menu/:id
    PUT    /api/menu/:id
    DELETE /api/menu/:id

## Permissions

    menu_read    menu_create    menu_update    menu_delete

# AUTHOR

Daniel Brosseau <dab@cpan.org>

# COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Daniel Brosseau.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
