just some refactoring for action-dialogue.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
(ns auto-ap.views.utils
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[cljs-time.format :as format]))
|
||||
|
||||
(defn active-when= [active-page candidate]
|
||||
@@ -37,6 +39,9 @@
|
||||
(defmulti do-bind (fn [a {:keys [type] :as x}]
|
||||
type))
|
||||
|
||||
(defn with-keys [children]
|
||||
(map-indexed (fn [i c] ^{:key i} c) children))
|
||||
|
||||
(defmethod do-bind "select" [dom {:keys [field subscription event class value spec] :as keys} & rest]
|
||||
(let [field (if (keyword? field) [field] field)
|
||||
event (if (keyword? event) [event] event)
|
||||
@@ -48,7 +53,7 @@
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(vec (concat [dom keys] rest))))
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
|
||||
(defmethod do-bind "radio" [dom {:keys [field subscription event class value spec] :as keys} & rest]
|
||||
@@ -61,7 +66,7 @@
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field ))))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(vec (concat [dom keys] rest))))
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
|
||||
(defmethod do-bind :default [dom {:keys [field event subscription class spec] :as keys} & rest]
|
||||
@@ -75,10 +80,12 @@
|
||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription :event :spec)]
|
||||
(vec (concat [dom keys] rest))))
|
||||
(into [dom keys] (with-keys rest))))
|
||||
|
||||
(defn bind-field [all]
|
||||
(apply do-bind all))
|
||||
(apply do-bind all))
|
||||
|
||||
|
||||
|
||||
(defn horizontal-field [label & controls]
|
||||
[:div.field.is-horizontal
|
||||
@@ -87,4 +94,7 @@
|
||||
]
|
||||
(into
|
||||
[:div.field-body]
|
||||
(map (fn [c] [:div.field c]) controls))])
|
||||
(with-keys (map (fn [x] [:div.field x]) controls)))])
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user