Changeset 7881080 in Klonkt for src/views


Ignore:
Timestamp:
06/18/2026 03:28:34 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
8398935
Parents:
98ecf51
Message:

Hub #3: explicit is_primary flag + shared getPrimarySite() (DRY)

The "oldest site = primary site" assumption was duplicated independently in
resolveSite, hub.js, account.js and admin.js (fragile: if the oldest happened
to be an artist site, the hub home would be wrong). Now:

  • sites.is_primary column + backfill (marks the oldest if none is primary yet; ensurePrimarySite sets it on fresh installs) → existing behaviour exactly preserved.
  • one getPrimarySite() helper (is_primary, fallback oldest) replaces the 4 copies.
  • god can CHOOSE the primary/main site: ★ button + "primary" badge on /admin/sites (exactly one primary via a transaction).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/pages/admin-sites.ejs

    r98ecf51 r7881080  
    3636              <div class="ax-site-name">
    3737                <a href="/sites/<%= s.slug %>"><%= s.title %></a>
     38                <% if (s.is_primary) { %>
     39                  <span class="ax-pill ax-pill-primary" title="Hoofd-/labelsite van deze installatie">★ primair</span>
     40                <% } %>
    3841                <% if (s.is_public) { %>
    3942                  <span class="ax-pill ax-pill-ok" title="Publiek zichtbaar">✓ public</span>
     
    6770
    6871          <div class="ax-site-controls">
     72            <% if (!s.is_primary && (typeof canMutate === 'undefined' || canMutate)) { %>
     73              <form method="post" action="/admin/sites/<%= s.slug %>/make-primary" style="margin:0;display:inline"
     74                    onsubmit="return confirm('Deze site instellen als de primaire/hoofd-site?')">
     75                <button type="submit" class="ax-icon-btn" aria-label="Maak primair" title="Maak primaire/hoofd-site">★</button>
     76              </form>
     77            <% } %>
    6978            <a href="/admin/sites/<%= s.slug %>/edit" class="ax-icon-btn" aria-label="Bewerken" title="Bewerken">✎</a>
    7079            <form method="post" action="/admin/sites/<%= s.slug %>/delete" class="ax-delete-form"
     
    198207  background: rgba(40,160,90,0.12);
    199208}
     209.ax-pill-primary {
     210  color: var(--accent);
     211  background: color-mix(in srgb, var(--accent) 14%, transparent);
     212  font-weight: 600;
     213}
    200214
    201215/* ─── Stats (2 mini-columns for sites) ────────────────────────── */
Note: See TracChangeset for help on using the changeset viewer.