so many bug fixes.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
(re-frame/reg-sub
|
||||
::form
|
||||
(fn [db [_ x]]
|
||||
(-> db ::forms x)))
|
||||
(get (-> db ::forms) x)))
|
||||
|
||||
|
||||
(re-frame/reg-sub
|
||||
@@ -47,7 +47,7 @@
|
||||
:after (fn [context]
|
||||
(let [db (i/get-coeffect context :db)
|
||||
result (get-in (i/get-coeffect context :event) [1 data-key])]
|
||||
(println (get-in db [::forms form :complete-listener]))
|
||||
|
||||
(cond-> context
|
||||
true
|
||||
(i/assoc-effect :db (update-in db
|
||||
@@ -95,7 +95,8 @@
|
||||
(re-frame/reg-event-db
|
||||
::save-error
|
||||
(fn [db [_ form result]]
|
||||
(println form result)
|
||||
(println result)
|
||||
|
||||
(-> db
|
||||
(assoc-in [::forms form :status] :error)
|
||||
(assoc-in [::forms form :error] (or (:message (first result))
|
||||
@@ -114,7 +115,6 @@
|
||||
(i/->interceptor
|
||||
:id :settles
|
||||
:befor (fn [context]
|
||||
(println "here2")
|
||||
context)
|
||||
:after (fn [context]
|
||||
(i/assoc-effect context :dispatch-debounce {:event event
|
||||
@@ -143,18 +143,20 @@
|
||||
|
||||
|
||||
(defn vertical-form [{:keys [can-submit id change-event submit-event ]}]
|
||||
{:form (fn [{:keys [title] :as params} & children]
|
||||
(let [{:keys [data active? error]} @(re-frame/subscribe [::form id])
|
||||
can-submit @(re-frame/subscribe can-submit)]
|
||||
|
||||
(into ^{:key id} [: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 ^{:key "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]]))
|
||||
:raw-field (fn [control]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::form id])]
|
||||
[bind-field (-> control
|
||||
@@ -164,18 +166,20 @@
|
||||
[:div.field
|
||||
(when label [:p.help label])
|
||||
[:div.control control]])
|
||||
:field (fn [label control]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::form id])]
|
||||
[:div.field
|
||||
(when label [:p.help label])
|
||||
[:div.control [bind-field (-> control
|
||||
(assoc-in [1 :subscription] data)
|
||||
(assoc-in [1 :event] change-event))]]]))
|
||||
:field ^{:key "field"}
|
||||
(fn [label control]
|
||||
(let [{:keys [data]} @(re-frame/subscribe [::form id])]
|
||||
[:div.field
|
||||
(when label [:p.help 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.notification.is-warning.animated.fadeInUp error]))
|
||||
:error-notification
|
||||
(fn []
|
||||
(when-let [error (:error @(re-frame/subscribe [::form id]))]
|
||||
^{:key error}
|
||||
[:div.notification.is-warning.animated.fadeInUp {} error]))
|
||||
:submit-button (fn [child]
|
||||
(let [error (:error @(re-frame/subscribe [::form id]))]
|
||||
[:button.button.is-medium.is-primary.is-fullwidth {:disabled (if @(re-frame/subscribe can-submit)
|
||||
|
||||
Reference in New Issue
Block a user