dedicated edit route for instances, view-only route

integration-tests
Josha von Gizycki 6 years ago
parent b8339001f0
commit 5541b3113d

@ -28,6 +28,11 @@ a:active {
h1 {
font-size: 1.5rem;
small {
font-weight: normal;
font-size: 1.5rem;
}
}
h2 {
@ -35,6 +40,10 @@ h2 {
border-bottom: 1px solid @ci-blue;
}
em {
font-weight: bold;
}
.thin-border {
border: @border-stack;
}

@ -56,12 +56,15 @@
(neo4j/defquery find-by-uuid
"MATCH (i:instance {uuid:{uuid}})
RETURN i")
-[:of]->(s:schema)
RETURN i, s")
(defn find-by-uuid! [uuid]
(->> (neo4j/exec-query! find-by-uuid
{:uuid uuid})
(map :i)
(map #(assoc (:i %)
:schema
(:s %)))
first))
(neo4j/defquery find-properties

@ -1,6 +1,5 @@
(ns wanijo.instance.forms
(:require [wanijo.instance.domain :as domain]
[wanijo.attribute.domain :as domain-attr]))
(:require [wanijo.instance.domain :as domain]))
(def form
{:fields {:name {:label "Name"

@ -44,9 +44,14 @@
(domain/find-properties! uuid)))
(defn show! [uuid req]
(view/show! (instance! uuid)
(domain-attr/find-by-instance! uuid)
req))
(defn edit-form! [uuid req]
(let [instance (instance! uuid)
attrs (domain-attr/find-by-instance! uuid)]
(view/show! instance
(view/edit! instance
(form! uuid)
(forms-inst/instance->form-data instance)
req)))
@ -74,6 +79,9 @@
(GET (register! :instance-show "/instance/:uuid")
[uuid :as req]
(show! uuid req))
(GET (register! :instance-edit-form "/instance/:uuid/edit")
[uuid :as req]
(edit-form! uuid req))
(POST (register! :instance-edit "/instance/:uuid")
[uuid :as req]
(edit! uuid req)))

@ -34,7 +34,25 @@
(:uuid schema))
(hform/submit-button "Create!"))]))
(defn show! [instance form form-data req]
(defn show! [instance attrs req]
(view/layout!
:request req
:content
[[:h1
(-> instance :schema :name)
" "
[:small (:name instance)]]
[:p
[:small [:a {:href (path :instance-edit-form instance)}
"Edit Instance"]]]
(for [attr attrs
:let [auuid (:uuid attr)
prop (first (filter #(= auuid (-> % :attribute :uuid))
(:properties instance)))]]
(list [:em (:name attr)]
[:p (:value prop)]))]))
(defn edit! [instance form form-data req]
(view/layout!
:request req
:content

Loading…
Cancel
Save