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