github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/vadmin/Sitemap.html (about)

     1  <!-- Content managed by Project Forge, see [projectforge.md] for details. -->
     2  {% import (
     3    "slices"
     4  
     5    "github.com/kyleu/dbaudit/app"
     6    "github.com/kyleu/dbaudit/app/controller/cmenu"
     7    "github.com/kyleu/dbaudit/app/controller/cutil"
     8    "github.com/kyleu/dbaudit/app/lib/menu"
     9    "github.com/kyleu/dbaudit/views/components"
    10    "github.com/kyleu/dbaudit/views/layout"
    11  ) %}
    12  
    13  {% code type Sitemap struct {
    14    layout.Basic
    15  } %}
    16  
    17  {% func (p *Sitemap) Body(as *app.State, ps *cutil.PageState) %}
    18    <div class="card">
    19      <h3>{%= components.SVGRefIcon(`star`, ps) %}Sitemap</h3>
    20      <div class="mt">
    21        {%= SitemapDetail(ps.Menu, 1, ps) %}
    22      </div>
    23    </div>
    24  {% endfunc %}
    25  
    26  {% func SitemapDetail(m menu.Items, indent int, ps *cutil.PageState) %}{% stripspace %}
    27    {%= components.Indent(true, 1) %}
    28    <div class="mt">
    29      {%= components.Indent(true, 2) %}
    30      <ul class="level-0">
    31        {% for _, i := range m %}
    32          {% if i.Key != "" %}
    33            {%= sitemapItemDetail(i, []string{}, ps.Breadcrumbs, 3, ps) %}
    34          {% endif %}
    35        {% endfor %}
    36      {%= components.Indent(true, 2) %}
    37      </ul>
    38    {%= components.Indent(true, 1) %}
    39    </div>
    40  {% endstripspace %}{% endfunc %}
    41  
    42  {% func sitemapItemDetail(i *menu.Item, path []string, breadcrumbs cmenu.Breadcrumbs, indent int, ps *cutil.PageState) %}{% stripspace %}
    43    {%= components.Indent(true, indent) %}
    44    <li>
    45      <div class="mts">
    46        {%= components.Indent(true, indent + 1) %}
    47        <a href="{%s i.Route %}" title="{%s i.Desc() %}">
    48          {% if i.Icon != "" %}
    49            {%= components.SVGRef(i.Icon, 16, 16, "icon", ps) %}
    50          {% endif %}
    51          {%s i.Title %}
    52        </a>
    53        <div><em>{%s i.Desc() %}</em></div>
    54        {% if len(i.Children) > 0 %}
    55        <ul class="level-{%d len(path) %}">
    56          {% for _, kid := range i.Children %}
    57            {% if kid.Key != "" %}
    58              {%= sitemapItemDetail(kid, append(slices.Clone(path), i.Key), breadcrumbs, indent + 2, ps) %}
    59            {% endif %}
    60          {% endfor %}
    61        </ul>
    62        {% endif %}
    63      </div>
    64    {%= components.Indent(true, indent) %}
    65    </li>
    66  {% endstripspace %}{% endfunc %}