This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-07
Channels
- # announcements (20)
- # babashka (25)
- # beginners (48)
- # biff (26)
- # calva (5)
- # cider (3)
- # clara (7)
- # clerk (7)
- # clj-kondo (61)
- # cljdoc (3)
- # clojure (6)
- # clojure-austin (1)
- # clojure-conj (8)
- # clojure-europe (58)
- # clojure-nl (1)
- # clojure-norway (4)
- # clojure-poland (1)
- # clojure-uk (9)
- # cursive (2)
- # emacs (11)
- # fulcro (8)
- # graphql (14)
- # gratitude (6)
- # humbleui (10)
- # hyperfiddle (17)
- # integrant (15)
- # introduce-yourself (1)
- # leiningen (5)
- # malli (13)
- # meander (21)
- # nbb (11)
- # off-topic (15)
- # pedestal (15)
- # polylith (15)
- # quil (28)
- # rdf (2)
- # reitit (3)
- # releases (6)
- # sci (21)
- # shadow-cljs (38)
- # spacemacs (3)
- # xtdb (6)
The field is just the attribute in your data model. You can make a mutation that can update the lot of them on a single call. You just change the data in the entity. Fulcro uses the active entity as the edited content, and saves the pristine original data in form config.
indeed that was much easier, thanks! one issue though is that apply-on-change/apply-derived-calculations is not called anymore so the on-change/derived-fields are not updated
correct. You asked how to change a group of fields. If you also want RAD form behavior, then you have to at least send an event to the UISM that is controlling the form so it does that logic.
e.g. call at least one input-changed! or read the low-level UISM and figure out something better
is it safe to call trigger!! in a mutation? on the surface it looks like it works, I ended up triggering the :event/attribute-changed event directly for the :many attribute, but if I use trigger! instead of trigger!! the event is handled too late
(defmutation on-drop [{:keys [dragged-ident
dragged-parent-ident
dropped-ident
dropped-parent-ident
parent-relation
parent-key
asm-id
ordering-attribute]}]
(action [{:keys [state]}]
(let [from-path (conj dragged-parent-ident parent-relation)
to-path (conj dropped-parent-ident parent-relation)
to-children (get-in @state to-path)]
(uism/trigger!! app asm-id :event/attribute-changed
{::attr/qualified-key parent-relation
:form-ident dropped-parent-ident
:form-key parent-key
:old-value to-children
:value (move-child to-children dropped-ident dragged-ident)})
(when-not (= from-path to-path)
(let [from-children (get-in @state from-path)]
(uism/trigger!! app asm-id :event/attribute-changed
{::attr/qualified-key parent-relation
:form-ident dragged-parent-ident
:form-key parent-key
:old-value from-children
:value (remove-child from-children dragged-ident)})))
(swap! state
(fn [state]
(cond->
(-> state
(update-children to-path ordering-attribute)
(dissoc :ui/dragged-component nil))
(not= from-path to-path)
(update-children from-path ordering-attribute)))))))
So I ended up finding a satisfying solution by extending the state machine