|
|
@ -1,8 +1,8 @@
|
|
|
|
(ns wanijo.schema.view
|
|
|
|
(ns wanijo.schema.view
|
|
|
|
(:require [hiccup.form :as hform]
|
|
|
|
(:require [hiccup.form :as hform]
|
|
|
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
|
|
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
|
|
|
|
|
|
|
[formulare.core :as form]
|
|
|
|
[wanijo.framework.view :as view]
|
|
|
|
[wanijo.framework.view :as view]
|
|
|
|
[wanijo.framework.form :as form]
|
|
|
|
|
|
|
|
[wanijo.framework.routing :refer [path]]
|
|
|
|
[wanijo.framework.routing :refer [path]]
|
|
|
|
[wanijo.framework.time :refer [prettify-dt]]
|
|
|
|
[wanijo.framework.time :refer [prettify-dt]]
|
|
|
|
[wanijo.schema.domain :as domain]
|
|
|
|
[wanijo.schema.domain :as domain]
|
|
|
@ -11,7 +11,9 @@
|
|
|
|
(def form
|
|
|
|
(def form
|
|
|
|
{:fields {:name {:label "Name"
|
|
|
|
{:fields {:name {:label "Name"
|
|
|
|
:required true
|
|
|
|
:required true
|
|
|
|
:spec ::domain/name}}})
|
|
|
|
:spec ::domain/name}
|
|
|
|
|
|
|
|
:uuid {:label ""
|
|
|
|
|
|
|
|
:widget :hidden}}})
|
|
|
|
|
|
|
|
|
|
|
|
(def attr-form
|
|
|
|
(def attr-form
|
|
|
|
{:fields {:name {:label "Name"
|
|
|
|
{:fields {:name {:label "Name"
|
|
|
@ -27,13 +29,16 @@
|
|
|
|
:required {:label "Required"
|
|
|
|
:required {:label "Required"
|
|
|
|
:required false
|
|
|
|
:required false
|
|
|
|
:spec ::attr-domain/required
|
|
|
|
:spec ::attr-domain/required
|
|
|
|
:widget :checkbox}}})
|
|
|
|
:widget :checkbox}
|
|
|
|
|
|
|
|
:uuid {:widget :hidden}}})
|
|
|
|
|
|
|
|
|
|
|
|
(def assign-form
|
|
|
|
(def assign-form
|
|
|
|
{:fields {:assigned {:label "Users"
|
|
|
|
{:fields {:assigned {:label "Users"
|
|
|
|
:required false
|
|
|
|
:required false
|
|
|
|
:spec ::domain/assigned-to
|
|
|
|
:spec ::domain/assigned-to
|
|
|
|
:widget :mselect}}})
|
|
|
|
:widget :mselect}
|
|
|
|
|
|
|
|
:uuid {:label ""
|
|
|
|
|
|
|
|
:widget :hidden}}})
|
|
|
|
|
|
|
|
|
|
|
|
(defn overview! [req]
|
|
|
|
(defn overview! [req]
|
|
|
|
(let [session (:session req)
|
|
|
|
(let [session (:session req)
|
|
|
@ -70,12 +75,10 @@
|
|
|
|
[:h2 "Edit"]
|
|
|
|
[:h2 "Edit"]
|
|
|
|
(hform/form-to [:post (path :schema-edit)]
|
|
|
|
(hform/form-to [:post (path :schema-edit)]
|
|
|
|
(form/render-widgets form schema req)
|
|
|
|
(form/render-widgets form schema req)
|
|
|
|
(hform/hidden-field "uuid" (:uuid schema))
|
|
|
|
|
|
|
|
(hform/submit-button "Edit"))
|
|
|
|
(hform/submit-button "Edit"))
|
|
|
|
[:h3 "Assign to users"]
|
|
|
|
[:h3 "Assign to users"]
|
|
|
|
(hform/form-to [:post (path :schema-assign)]
|
|
|
|
(hform/form-to [:post (path :schema-assign)]
|
|
|
|
(form/render-widgets assign-form schema req)
|
|
|
|
(form/render-widgets assign-form schema req)
|
|
|
|
(hform/hidden-field "uuid" (:uuid schema))
|
|
|
|
|
|
|
|
(hform/submit-button "Assign"))
|
|
|
|
(hform/submit-button "Assign"))
|
|
|
|
[:h2 "Attributes"]
|
|
|
|
[:h2 "Attributes"]
|
|
|
|
[:ul.schema-attributes
|
|
|
|
[:ul.schema-attributes
|
|
|
@ -83,7 +86,6 @@
|
|
|
|
[:li
|
|
|
|
[:li
|
|
|
|
(hform/form-to [:post (path :attribute-edit {:schema (:uuid schema)})]
|
|
|
|
(hform/form-to [:post (path :attribute-edit {:schema (:uuid schema)})]
|
|
|
|
(form/render-widgets attr-form attr req)
|
|
|
|
(form/render-widgets attr-form attr req)
|
|
|
|
(hform/hidden-field "uuid" (:uuid attr))
|
|
|
|
|
|
|
|
(hform/submit-button "Save"))
|
|
|
|
(hform/submit-button "Save"))
|
|
|
|
(hform/form-to [:delete (path :attribute-delete attr)]
|
|
|
|
(hform/form-to [:delete (path :attribute-delete attr)]
|
|
|
|
(anti-forgery-field)
|
|
|
|
(anti-forgery-field)
|
|
|
|