Undoes old way of doing forms in favor of context version. Much easier
This commit is contained in:
@@ -138,68 +138,3 @@
|
||||
(assoc-in [::forms id :error] nil)))
|
||||
|
||||
|
||||
(defn vertical-form [{:keys [can-submit id change-event submit-event fullwidth?] :or {fullwidth? true}}]
|
||||
{:form
|
||||
(fn [{:keys [title] :as params} & children]
|
||||
(let [{:keys [data active? error]} @(re-frame/subscribe [::form id])
|
||||
can-submit @(re-frame/subscribe can-submit)]
|
||||
|
||||
[:form { :on-submit (fn [e]
|
||||
(when (.-stopPropagation e)
|
||||
(.stopPropagation e)
|
||||
(.preventDefault e))
|
||||
(when can-submit
|
||||
(re-frame/dispatch-sync (vec (conj submit-event params)))))}
|
||||
[:h1.title.is-2 title]
|
||||
[:<>
|
||||
children]]))
|
||||
|
||||
:form-inline
|
||||
(fn [{:keys [title] :as params} children]
|
||||
(let [{:keys [data active? error]} @(re-frame/subscribe [::form id])
|
||||
can-submit @(re-frame/subscribe can-submit)]
|
||||
|
||||
[:form { :on-submit (fn [e]
|
||||
(when (.-stopPropagation e)
|
||||
(.stopPropagation e)
|
||||
(.preventDefault e))
|
||||
(when can-submit
|
||||
(re-frame/dispatch-sync (vec (conj submit-event params)))))}
|
||||
(when title
|
||||
[:h1.title.is-2 title])
|
||||
children]))
|
||||
:raw-field (fn [control]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::form id])]
|
||||
[bind-field (-> control
|
||||
(assoc-in [1 :subscription] data)
|
||||
(assoc-in [1 :event] change-event))]))
|
||||
:field-holder (fn [label control]
|
||||
[:div.field
|
||||
(when label (if fullwidth? [:p.help label]
|
||||
[:label.label label]))
|
||||
[:div.control control]])
|
||||
:field ^{:key "field"}
|
||||
(fn [label control]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::form id])]
|
||||
[:div.field
|
||||
(when label (if fullwidth? [:p.help label]
|
||||
[:label.label label]))
|
||||
[:div.control [bind-field (-> control
|
||||
(assoc-in [1 :subscription] data)
|
||||
(assoc-in [1 :event] change-event))]]]))
|
||||
|
||||
:error-notification
|
||||
(fn []
|
||||
(when-let [error (:error @(re-frame/subscribe [::form id]))]
|
||||
^{:key error}
|
||||
[:div.has-text-danger.animated.fadeInUp {} error]))
|
||||
:submit-button (fn [child]
|
||||
(let [error (:error @(re-frame/subscribe [::form id]))
|
||||
status @(re-frame/subscribe [::status/single id])
|
||||
can-submit @(re-frame/subscribe can-submit)]
|
||||
[:button.button.is-medium.is-primary {:disabled (or (status/disabled-for status)
|
||||
(not can-submit))
|
||||
:class (cond-> (status/class-for status)
|
||||
fullwidth? (conj "is-fullwidth")) }
|
||||
child]))})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user