|
|
|
@ -3,18 +3,14 @@
|
|
|
|
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
|
|
|
|
[ring.util.response :as resp]
|
|
|
|
|
[hiccup.form :as hform]
|
|
|
|
|
[clojure.spec.alpha :as spec]
|
|
|
|
|
[wanijo.domain.schema :as domain-schemas]
|
|
|
|
|
[wanijo.view :as view]
|
|
|
|
|
[wanijo.forms :as forms]))
|
|
|
|
|
|
|
|
|
|
(spec/def ::schema-name
|
|
|
|
|
(spec/and some? string? not-empty))
|
|
|
|
|
|
|
|
|
|
(def new-schema-form
|
|
|
|
|
{:fields {:schema-name {:label "Nimi"
|
|
|
|
|
:required true
|
|
|
|
|
:spec ::schema-name}}})
|
|
|
|
|
:spec :wanijo.domain.schema/name}}})
|
|
|
|
|
|
|
|
|
|
(defn- overview! [req]
|
|
|
|
|
(let [session (:session req)
|
|
|
|
@ -42,7 +38,7 @@
|
|
|
|
|
(anti-forgery-field))])))
|
|
|
|
|
|
|
|
|
|
(defn- new! [req]
|
|
|
|
|
(if (spec/valid? ::new-schema (:params req))
|
|
|
|
|
(if (forms/valid? req new-schema-form)
|
|
|
|
|
(resp/redirect "/schema")
|
|
|
|
|
(overview! req)))
|
|
|
|
|
|
|
|
|
|