some specs, checkbox support

integration-tests
Josha von Gizycki 6 years ago
parent 5fe5ed5239
commit 4aa80950e5

@ -10,6 +10,8 @@
string?
#(some #{"date" "file" "string" "text"} %)))
(spec/def ::required boolean?)
(neo4j/defquery
findy-by-schema
"MATCH (a:attribute)-->(s:schema)

@ -54,9 +54,7 @@
(defn drop-down
([form-def field req]
{:pre [(spec/valid? ::form form-def)]}
(drop-down form-def
field
req
(drop-down form-def field req
(get-in form-def [:fields field :options])))
([form-def field req options]
{:pre [(spec/valid? ::form form-def)]}
@ -71,6 +69,19 @@
options
field-value)))))
(defn check-box [form-def field req]
{:pre [(spec/valid? ::form form-def)]}
(let [field-value (get-in req [:params field])
field-def (get-in form-def [:fields field])
{:keys [label required] spec-key :spec} field-def]
(list
(when-not (field-valid? field-value spec-key req)
(spec-to-errmsg label spec-key field-value))
(hform/label field label)
(hform/check-box field
(some? field-value)
field-value))))
(defn valid? [form-def req]
{:pre [(spec/valid? ::form form-def)]}
(reduce-kv

@ -23,7 +23,10 @@
:options [["Lon e lipu" "string"]
["Ali lon e lipu" "text"]
["Kama" "date"]
["Sitelen" "file"]]}}})
["Sitelen" "file"]]}
:required {:label "Wile"
:required false
:spec ::attr-domain/required}}})
(defn overview! [req]
(let [session (:session req)
@ -72,6 +75,7 @@
(hform/hidden-field "schema" (:uuid schema))
(form/field new-attr-form :name req)
(form/drop-down new-attr-form :type req)
(form/check-box new-attr-form :required req)
(hform/submit-button "Pali"))
[:h2 "Mute pali"]
(hform/form-to

Loading…
Cancel
Save