Move events/market/blog composition from Python to .sx defcomps (Phase 9)
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 2m33s

Continues the pattern of eliminating Python sx_call tree-building in favour
of data-driven .sx defcomps. POST/PUT/DELETE routes now pass plain data
(dicts, lists, scalars) and let .sx handle iteration, conditionals, and
layout via map/let/when/if. Single response components wrap OOB swaps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 08:17:09 +00:00
parent 877e776977
commit 51ebf347ba
23 changed files with 1841 additions and 1423 deletions

View File

@@ -318,6 +318,64 @@
"+ Add slot"))
;; ---------------------------------------------------------------------------
;; Composition defcomps — receive data, compose form trees
;; ---------------------------------------------------------------------------
;; Day checkboxes from data — replaces Python loop
(defcomp ~events-day-checkboxes-from-data (&key days-data all-checked)
(<>
(~events-day-all-checkbox :checked (when all-checked "checked"))
(map (lambda (d)
(~events-day-checkbox
:name (get d "name")
:label (get d "label")
:checked (when (get d "checked") "checked")))
(or days-data (list)))))
;; Slot options from data — replaces _slot_options_html Python loop
(defcomp ~events-slot-options-from-data (&key slots)
(<> (map (lambda (s)
(~events-slot-option
:value (get s "value")
:data-start (get s "data-start")
:data-end (get s "data-end")
:data-flexible (get s "data-flexible")
:data-cost (get s "data-cost")
:selected (get s "selected")
:label (get s "label")))
(or slots (list)))))
;; Slot picker from data — wraps picker + options
(defcomp ~events-slot-picker-from-data (&key id slots)
(if (empty? (or slots (list)))
(~events-no-slots)
(~events-slot-picker
:id id
:options (~events-slot-options-from-data :slots slots))))
;; Slot edit form from data
(defcomp ~events-slot-edit-form-from-data (&key slot-id list-container put-url cancel-url csrf
name-val cost-val start-val end-val desc-val
days-data all-checked flexible-checked
action-btn cancel-btn)
(~events-slot-edit-form
:slot-id slot-id :list-container list-container
:put-url put-url :cancel-url cancel-url :csrf csrf
:name-val name-val :cost-val cost-val :start-val start-val
:end-val end-val :desc-val desc-val
:days (~events-day-checkboxes-from-data :days-data days-data :all-checked all-checked)
:flexible-checked flexible-checked
:action-btn action-btn :cancel-btn cancel-btn))
;; Slot add form from data
(defcomp ~events-slot-add-form-from-data (&key post-url csrf days-data action-btn cancel-btn cancel-url)
(~events-slot-add-form
:post-url post-url :csrf csrf
:days (~events-day-checkboxes-from-data :days-data days-data)
:action-btn action-btn :cancel-btn cancel-btn :cancel-url cancel-url))
;; ---------------------------------------------------------------------------
;; Entry add form (_types/day/_add.html)
;; ---------------------------------------------------------------------------