integration-tests
Josha von Gizycki 6 years ago
commit a935efbe31

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

@ -1,7 +1,8 @@
(ns wanijo.framework.view (ns wanijo.framework.view
(:require [hiccup.page :refer (:require [hiccup
[html5 include-css include-js]] [page :refer [html5 include-js include-css]]
[hiccup.form :as hform] [form :as hform]
[core :refer [h]]]
[wanijo.framework.routing :refer [path]])) [wanijo.framework.routing :refer [path]]))
(defn btnlink (defn btnlink
@ -47,7 +48,8 @@
(when authed? (when authed?
[:small.app-title__hello [:small.app-title__hello
"Hi, " "Hi, "
[:a {:href (path :user-profile)} ident]])] [:a {:href (path :user-profile)}
(h ident)]])]
(when authed? (when authed?
[:section.header-content [:section.header-content
(btnlink (path :schema-overview) (btnlink (path :schema-overview)
@ -64,7 +66,7 @@
(for [schema (:schemas session)] (for [schema (:schemas session)]
[:li [:a {:href (path :instance-list [:li [:a {:href (path :instance-list
{:schema-uuid (:uuid schema)})} {:schema-uuid (:uuid schema)})}
(:name schema)]])]])] (h (:name schema))]])]])]
(into [:main (into [:main
(for [msg (:flash request)] (for [msg (:flash request)]
(flash-error msg))] (flash-error msg))]

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

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

@ -44,9 +44,14 @@
(domain/find-properties! uuid))) (domain/find-properties! uuid)))
(defn show! [uuid req] (defn show! [uuid req]
(view/show! (instance! uuid)
(domain-attr/find-by-instance! uuid)
req))
(defn edit-form! [uuid req]
(let [instance (instance! uuid) (let [instance (instance! uuid)
attrs (domain-attr/find-by-instance! uuid)] attrs (domain-attr/find-by-instance! uuid)]
(view/show! instance (view/edit! instance
(form! uuid) (form! uuid)
(forms-inst/instance->form-data instance) (forms-inst/instance->form-data instance)
req))) req)))
@ -81,6 +86,9 @@
(GET (register! :instance-show "/instance/:uuid") (GET (register! :instance-show "/instance/:uuid")
[uuid :as req] [uuid :as req]
(show! uuid 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") (POST (register! :instance-edit "/instance/:uuid")
[uuid :as req] [uuid :as req]
(edit! uuid req)) (edit! uuid req))

@ -1,5 +1,7 @@
(ns wanijo.instance.view (ns wanijo.instance.view
(:require [hiccup.form :as hform] (:require [hiccup
[form :as hform]
[core :refer [h]]]
[ring.util.anti-forgery :refer [anti-forgery-field]] [ring.util.anti-forgery :refer [anti-forgery-field]]
[formulare.core :as form] [formulare.core :as form]
[wanijo.instance.domain :as domain] [wanijo.instance.domain :as domain]
@ -12,7 +14,7 @@
:request req :request req
:content :content
[[:h1 "All Instances of schema " [[:h1 "All Instances of schema "
[:span.schema-title__name (:name schema)]] [:span.schema-title__name (h (:name schema))]]
[:table [:table
[:thead [:thead
[:tr [:tr
@ -24,7 +26,7 @@
[:tr [:tr
[:td [:td
[:a {:href (path :instance-show instance)} [:a {:href (path :instance-show instance)}
(:name instance)]] (h (:name instance))]]
[:td (prettify-dt (:updated_at instance))] [:td (prettify-dt (:updated_at instance))]
[:td (prettify-dt (:created_at instance))]])]] [:td (prettify-dt (:created_at instance))]])]]
[:h1 "New Instance"] [:h1 "New Instance"]
@ -34,11 +36,32 @@
(:uuid schema)) (:uuid schema))
(hform/submit-button "Create!"))])) (hform/submit-button "Create!"))]))
(defn show! [instance form form-data req] (defn show! [instance attrs req]
(view/layout! (view/layout!
:request req :request req
:content :content
[[:h1 (:name instance)] [[:h1
(h (-> instance :schema :name))
" "
[:small (h (: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 (h (:name attr))]
[:p (h (:value prop))]))]))
(defn edit! [instance form form-data req]
(view/layout!
:request req
:content
[[:h1
(h (-> instance :schema :name))
" "
[:small (h (:name instance))]]
(hform/form-to [:post (path :instance-edit instance)] (hform/form-to [:post (path :instance-edit instance)]
(form/render-widgets form form-data req) (form/render-widgets form form-data req)
(hform/submit-button "Edit!")) (hform/submit-button "Edit!"))

@ -1,5 +1,7 @@
(ns wanijo.schema.view (ns wanijo.schema.view
(:require [hiccup.form :as hform] (:require [hiccup
[form :as hform]
[core :refer [h]]]
[ring.util.anti-forgery :refer [anti-forgery-field]] [ring.util.anti-forgery :refer [anti-forgery-field]]
[formulare.core :as form] [formulare.core :as form]
[wanijo.framework.view :as view] [wanijo.framework.view :as view]
@ -26,7 +28,7 @@
[:tr [:tr
[:td [:td
[:a {:href (path :schema-show schema)} [:a {:href (path :schema-show schema)}
(:name schema)]] (h (:name schema))]]
[:td [:td
(prettify-dt (:created_at schema))]])]] (prettify-dt (:created_at schema))]])]]
[:h1 "New schema"] [:h1 "New schema"]
@ -39,7 +41,8 @@
:request req :request req
:content :content
[[:h1 "Schema " [[:h1 "Schema "
[:span.schema-title__name (:name schema)]] [:span.schema-title__name
(h (:name schema))]]
[:h2 "Edit"] [:h2 "Edit"]
(hform/form-to [:post (path :schema-edit)] (hform/form-to [:post (path :schema-edit)]
(form/render-widgets forms/schema schema req) (form/render-widgets forms/schema schema req)

Loading…
Cancel
Save