Files
rose-ash/events/sx/layouts.sx
giles b0920a1121 Rename all 1,169 components to path-based names with namespace support
Component names now reflect filesystem location using / as path separator
and : as namespace separator for shared components:
  ~sx-header → ~layouts/header
  ~layout-app-body → ~shared:layout/app-body
  ~blog-admin-dashboard → ~admin/dashboard

209 files, 4,941 replacements across all services.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 22:00:12 +00:00

454 lines
21 KiB
Plaintext

;; Events layout defcomps — fully self-contained via IO primitives.
;; Registered via register_sx_layout in helpers.py.
;; ---------------------------------------------------------------------------
;; Auto-fetching header macros — calendar, day, entry, slot, tickets
;; ---------------------------------------------------------------------------
(defmacro ~events-calendar-header-auto (oob)
"Calendar header row using (events-calendar-ctx)."
(quasiquote
(let ((__cal (events-calendar-ctx))
(__sc (select-colours)))
(when (get __cal "slug")
(~shared:layout/menu-row-sx :id "calendar-row" :level 3
:link-href (url-for "calendar.get"
:calendar-slug (get __cal "slug"))
:link-label-content (~header/calendar-label
:name (get __cal "name")
:description (get __cal "description"))
:nav (<>
(~shared:layout/nav-link :href (url-for "defpage_slots_listing"
:calendar-slug (get __cal "slug"))
:icon "fa fa-clock" :label "Slots"
:select-colours __sc)
(let ((__rights (app-rights)))
(when (get __rights "admin")
(~shared:layout/nav-link :href (url-for "defpage_calendar_admin"
:calendar-slug (get __cal "slug"))
:icon "fa fa-cog"
:select-colours __sc))))
:child-id "calendar-header-child"
:oob (unquote oob))))))
(defmacro ~events-calendar-admin-header-auto (oob)
"Calendar admin header row."
(quasiquote
(let ((__cal (events-calendar-ctx))
(__sc (select-colours)))
(when (get __cal "slug")
(~shared:layout/menu-row-sx :id "calendar-admin-row" :level 4
:link-label "admin" :icon "fa fa-cog"
:nav (<>
(~shared:layout/nav-link :href (url-for "defpage_slots_listing"
:calendar-slug (get __cal "slug"))
:label "slots" :select-colours __sc)
(~shared:layout/nav-link :href (url-for "calendar.admin.calendar_description_edit"
:calendar-slug (get __cal "slug"))
:label "description" :select-colours __sc))
:child-id "calendar-admin-header-child"
:oob (unquote oob))))))
(defmacro ~events-day-header-auto (oob)
"Day header row using (events-day-ctx)."
(quasiquote
(let ((__day (events-day-ctx))
(__cal (events-calendar-ctx)))
(when (get __day "date-str")
(~shared:layout/menu-row-sx :id "day-row" :level 4
:link-href (url-for "calendar.day.show_day"
:calendar-slug (get __cal "slug")
:year (get __day "year")
:month (get __day "month")
:day (get __day "day"))
:link-label-content (~header/day-label
:date-str (get __day "date-str"))
:nav (get __day "nav")
:child-id "day-header-child"
:oob (unquote oob))))))
(defmacro ~events-day-admin-header-auto (oob)
"Day admin header row."
(quasiquote
(let ((__day (events-day-ctx))
(__cal (events-calendar-ctx)))
(when (get __day "date-str")
(~shared:layout/menu-row-sx :id "day-admin-row" :level 5
:link-href (url-for "defpage_day_admin"
:calendar-slug (get __cal "slug")
:year (get __day "year")
:month (get __day "month")
:day (get __day "day"))
:link-label "admin" :icon "fa fa-cog"
:child-id "day-admin-header-child"
:oob (unquote oob))))))
(defmacro ~events-entry-header-auto (oob)
"Entry header row using (events-entry-ctx)."
(quasiquote
(let ((__ectx (events-entry-ctx)))
(when (get __ectx "id")
(~shared:layout/menu-row-sx :id "entry-row" :level 5
:link-href (get __ectx "link-href")
:link-label-content (~header/entry-label
:entry-id (get __ectx "id")
:title (~admin/entry-title :name (get __ectx "name"))
:times (~admin/entry-times :time-str (get __ectx "time-str")))
:nav (get __ectx "nav")
:child-id "entry-header-child"
:oob (unquote oob))))))
(defmacro ~events-entry-admin-header-auto (oob)
"Entry admin header row."
(quasiquote
(let ((__ectx (events-entry-ctx)))
(when (get __ectx "id")
(~shared:layout/menu-row-sx :id "entry-admin-row" :level 6
:link-href (get __ectx "admin-href")
:link-label "admin" :icon "fa fa-cog"
:nav (when (get __ectx "is-admin")
(~shared:layout/nav-link :href (get __ectx "ticket-types-href")
:label "ticket_types"
:select-colours (get __ectx "select-colours")))
:child-id "entry-admin-header-child"
:oob (unquote oob))))))
(defmacro ~events-slot-header-auto (oob)
"Slot detail header row using (events-slot-ctx)."
(quasiquote
(let ((__slot (events-slot-ctx)))
(when (get __slot "name")
(~shared:layout/menu-row-sx :id "slot-row" :level 5
:link-label-content (~header/slot-label
:name (get __slot "name")
:description (get __slot "description"))
:child-id "slot-header-child"
:oob (unquote oob))))))
(defmacro ~events-ticket-types-header-auto (oob)
"Ticket types header row."
(quasiquote
(let ((__ectx (events-entry-ctx))
(__cal (events-calendar-ctx)))
(when (get __ectx "id")
(~shared:layout/menu-row-sx :id "ticket_types-row" :level 7
:link-href (get __ectx "ticket-types-href")
:link-label-content (<>
(i :class "fa fa-ticket")
(div :class "shrink-0" "ticket types"))
:nav (~forms/admin-placeholder-nav)
:child-id "ticket_type-header-child"
:oob (unquote oob))))))
(defmacro ~events-ticket-type-header-auto (oob)
"Single ticket type header row using (events-ticket-type-ctx)."
(quasiquote
(let ((__tt (events-ticket-type-ctx)))
(when (get __tt "id")
(~shared:layout/menu-row-sx :id "ticket_type-row" :level 8
:link-href (get __tt "link-href")
:link-label-content (div :class "flex flex-col md:flex-row md:gap-2 items-center"
(div :class "flex flex-row items-center gap-2"
(i :class "fa fa-ticket")
(div :class "shrink-0" (get __tt "name"))))
:nav (~forms/admin-placeholder-nav)
:child-id "ticket_type-header-child-inner"
:oob (unquote oob))))))
(defmacro ~events-markets-header-auto (oob)
"Markets section header row."
(quasiquote
(~shared:layout/menu-row-sx :id "markets-row" :level 3
:link-href (url-for "defpage_events_markets")
:link-label-content (~header/markets-label)
:child-id "markets-header-child"
:oob (unquote oob))))
;; ---------------------------------------------------------------------------
;; OOB clear helpers — clear deeper header rows not present at this level
;; ---------------------------------------------------------------------------
(defcomp ~layouts/clear-oob-cal-admin ()
"Clear OOB divs for cal-admin level (keeps down to calendar-admin)."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row")
(~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row")
(~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row")
(~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "day-row")
(~shared:layout/clear-oob-div :id "day-header-child")
(~shared:layout/clear-oob-div :id "calendars-row")
(~shared:layout/clear-oob-div :id "calendars-header-child")))
(defcomp ~layouts/clear-oob-slot ()
"Clear OOB divs for slot level."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row")
(~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row")
(~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row")
(~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "day-row")
(~shared:layout/clear-oob-div :id "day-header-child")
(~shared:layout/clear-oob-div :id "calendars-row")
(~shared:layout/clear-oob-div :id "calendars-header-child")))
(defcomp ~layouts/clear-oob-day-admin ()
"Clear OOB divs for day-admin level."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row")
(~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row")
(~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "calendars-row")
(~shared:layout/clear-oob-div :id "calendars-header-child")))
(defcomp ~layouts/clear-oob-entry ()
"Clear OOB divs for entry level (public, no admin rows)."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row")
(~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row")
(~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "calendar-admin-row")
(~shared:layout/clear-oob-div :id "calendar-admin-header-child")
(~shared:layout/clear-oob-div :id "calendars-row")
(~shared:layout/clear-oob-div :id "calendars-header-child")
(~shared:layout/clear-oob-div :id "post-admin-row")
(~shared:layout/clear-oob-div :id "post-admin-header-child")))
(defcomp ~layouts/clear-oob-entry-admin ()
"Clear OOB divs for entry-admin level."
(<>
(~shared:layout/clear-oob-div :id "calendars-row")
(~shared:layout/clear-oob-div :id "calendars-header-child")))
;; ---------------------------------------------------------------------------
;; OOB clear helpers for renders.py — clear all deeper IDs except kept ones
;; ---------------------------------------------------------------------------
(defcomp ~layouts/clear-deeper-post ()
"Clear all events IDs deeper than post level."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row") (~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row") (~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row") (~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "day-row") (~shared:layout/clear-oob-div :id "day-header-child")
(~shared:layout/clear-oob-div :id "calendar-admin-row") (~shared:layout/clear-oob-div :id "calendar-admin-header-child")
(~shared:layout/clear-oob-div :id "calendar-row") (~shared:layout/clear-oob-div :id "calendar-header-child")
(~shared:layout/clear-oob-div :id "calendars-row") (~shared:layout/clear-oob-div :id "calendars-header-child")
(~shared:layout/clear-oob-div :id "post-admin-row") (~shared:layout/clear-oob-div :id "post-admin-header-child")))
(defcomp ~layouts/clear-deeper-post-admin ()
"Clear all events IDs deeper than post-admin level."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row") (~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row") (~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row") (~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "day-row") (~shared:layout/clear-oob-div :id "day-header-child")
(~shared:layout/clear-oob-div :id "calendar-admin-row") (~shared:layout/clear-oob-div :id "calendar-admin-header-child")
(~shared:layout/clear-oob-div :id "calendar-row") (~shared:layout/clear-oob-div :id "calendar-header-child")
(~shared:layout/clear-oob-div :id "calendars-row") (~shared:layout/clear-oob-div :id "calendars-header-child")))
(defcomp ~layouts/clear-deeper-calendar ()
"Clear all events IDs deeper than calendar level."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row") (~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row") (~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row") (~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "day-row") (~shared:layout/clear-oob-div :id "day-header-child")
(~shared:layout/clear-oob-div :id "calendar-admin-row") (~shared:layout/clear-oob-div :id "calendar-admin-header-child")
(~shared:layout/clear-oob-div :id "calendars-row") (~shared:layout/clear-oob-div :id "calendars-header-child")
(~shared:layout/clear-oob-div :id "post-admin-row") (~shared:layout/clear-oob-div :id "post-admin-header-child")))
(defcomp ~layouts/clear-deeper-day ()
"Clear all events IDs deeper than day level."
(<>
(~shared:layout/clear-oob-div :id "entry-admin-row") (~shared:layout/clear-oob-div :id "entry-admin-header-child")
(~shared:layout/clear-oob-div :id "entry-row") (~shared:layout/clear-oob-div :id "entry-header-child")
(~shared:layout/clear-oob-div :id "day-admin-row") (~shared:layout/clear-oob-div :id "day-admin-header-child")
(~shared:layout/clear-oob-div :id "calendar-admin-row") (~shared:layout/clear-oob-div :id "calendar-admin-header-child")
(~shared:layout/clear-oob-div :id "calendars-row") (~shared:layout/clear-oob-div :id "calendars-header-child")
(~shared:layout/clear-oob-div :id "post-admin-row") (~shared:layout/clear-oob-div :id "post-admin-header-child")))
;; ---------------------------------------------------------------------------
;; Calendar admin layout: root + post + child(post-admin + cal + cal-admin)
;; ---------------------------------------------------------------------------
(defcomp ~layouts/cal-admin-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~post-admin-header-auto nil "calendars")
(~events-calendar-header-auto nil)
(~events-calendar-admin-header-auto nil)))))
(defcomp ~layouts/cal-admin-layout-oob ()
(<> (~post-admin-header-auto true "calendars")
(~events-calendar-header-auto true)
(~shared:layout/oob-header-sx :parent-id "calendar-header-child"
:row (~events-calendar-admin-header-auto nil))
(~layouts/clear-oob-cal-admin)
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Slots layout: same full as cal-admin
;; ---------------------------------------------------------------------------
(defcomp ~layouts/slots-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~post-admin-header-auto nil "calendars")
(~events-calendar-header-auto nil)
(~events-calendar-admin-header-auto nil)))))
(defcomp ~layouts/slots-layout-oob ()
(<> (~post-admin-header-auto true "calendars")
(~events-calendar-admin-header-auto true)
(~layouts/clear-oob-cal-admin)
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Slot detail layout: root + post + child(admin + cal + cal-admin + slot)
;; ---------------------------------------------------------------------------
(defcomp ~layouts/slot-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~post-admin-header-auto nil "calendars")
(~events-calendar-header-auto nil)
(~events-calendar-admin-header-auto nil)
(~events-slot-header-auto nil)))))
(defcomp ~layouts/slot-layout-oob ()
(<> (~post-admin-header-auto true "calendars")
(~events-calendar-admin-header-auto true)
(~shared:layout/oob-header-sx :parent-id "calendar-admin-header-child"
:row (~events-slot-header-auto nil))
(~layouts/clear-oob-slot)
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Day admin layout: root + post + child(admin + cal + day + day-admin)
;; ---------------------------------------------------------------------------
(defcomp ~layouts/day-admin-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~post-admin-header-auto nil "calendars")
(~events-calendar-header-auto nil)
(~events-day-header-auto nil)
(~events-day-admin-header-auto nil)))))
(defcomp ~layouts/day-admin-layout-oob ()
(<> (~post-admin-header-auto true "calendars")
(~events-calendar-header-auto true)
(~shared:layout/oob-header-sx :parent-id "day-header-child"
:row (~events-day-admin-header-auto nil))
(~layouts/clear-oob-day-admin)
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Entry layout: root + child(post + cal + day + entry) — public, no admin
;; ---------------------------------------------------------------------------
(defcomp ~layouts/entry-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~events-calendar-header-auto nil)
(~events-day-header-auto nil)
(~events-entry-header-auto nil)))))
(defcomp ~layouts/entry-layout-oob ()
(<> (~events-day-header-auto true)
(~shared:layout/oob-header-sx :parent-id "day-header-child"
:row (~events-entry-header-auto nil))
(~layouts/clear-oob-entry)
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Entry admin layout: root + post + child(admin + cal + day + entry + entry-admin)
;; ---------------------------------------------------------------------------
(defcomp ~layouts/entry-admin-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~post-admin-header-auto nil "calendars")
(~events-calendar-header-auto nil)
(~events-day-header-auto nil)
(~events-entry-header-auto nil)
(~events-entry-admin-header-auto nil)))))
(defcomp ~layouts/entry-admin-layout-oob ()
(<> (~post-admin-header-auto true "calendars")
(~events-entry-header-auto true)
(~shared:layout/oob-header-sx :parent-id "entry-header-child"
:row (~events-entry-admin-header-auto nil))
(~layouts/clear-oob-entry-admin)
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Ticket types layout: root + child(post + cal + day + entry + entry-admin + ticket-types)
;; ---------------------------------------------------------------------------
(defcomp ~layouts/ticket-types-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~events-calendar-header-auto nil)
(~events-day-header-auto nil)
(~events-entry-header-auto nil)
(~events-entry-admin-header-auto nil)
(~events-ticket-types-header-auto nil)))))
(defcomp ~layouts/ticket-types-layout-oob ()
(<> (~events-entry-admin-header-auto true)
(~shared:layout/oob-header-sx :parent-id "entry-admin-header-child"
:row (~events-ticket-types-header-auto nil))
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Ticket type layout: all headers down to ticket-type
;; ---------------------------------------------------------------------------
(defcomp ~layouts/ticket-type-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~events-calendar-header-auto nil)
(~events-day-header-auto nil)
(~events-entry-header-auto nil)
(~events-entry-admin-header-auto nil)
(~events-ticket-types-header-auto nil)
(~events-ticket-type-header-auto nil)))))
(defcomp ~layouts/ticket-type-layout-oob ()
(<> (~events-ticket-types-header-auto true)
(~shared:layout/oob-header-sx :parent-id "ticket_types-header-child"
:row (~events-ticket-type-header-auto nil))
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; Markets layout: root + child(post + markets)
;; ---------------------------------------------------------------------------
(defcomp ~layouts/markets-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~post-header-auto nil)
(~events-markets-header-auto nil)))))
(defcomp ~layouts/markets-layout-oob ()
(<> (~post-header-auto true)
(~shared:layout/oob-header-sx :parent-id "post-header-child"
:row (~events-markets-header-auto nil))
(~root-header-auto true)))