show required attributes in instance list

neo4j-4
Josha von Gizycki 5 years ago
parent 6d256c6d37
commit 53bca6a698

@ -24,15 +24,12 @@
(spec/def ::contains-schema
(spec/keys :req-un [::db-schema/schema]))
(spec/def ::instances-with-tags-and-props
(spec/coll-of (spec/merge ::instance
(spec/keys :req-un [::tags
::properties]))))
(spec/def ::instance-with-tags-and-props
(spec/merge ::instance
(spec/keys :req-un [::tags
::properties])))
(spec/def ::instances-with-tags-and-props
(spec/coll-of ::instance-with-tags-and-props))
(spec/def ::instance-with-schema
(spec/merge ::instance ::contains-schema))

@ -23,6 +23,8 @@
[:thead
[:tr
[:th "Name"]
(map (fn [attr] [:th (h (:name attr))])
(:req-attrs schema))
[:th "Updated"]
[:th "Created"]]]
[:tbody
@ -32,5 +34,13 @@
[:a {:href (path :instance-show instance)}
(h (:name instance))]
(view-instance/tags-for-search instance)]
(map (fn [attr]
[:td (->> (:properties instance)
(filter #(= (:uuid attr)
(-> % :attribute :uuid)))
first
:value
h)])
(:req-attrs schema))
[:td (prettify-dt (:updated_at instance))]
[:td (prettify-dt (:created_at instance))]])]]]))

@ -1,6 +1,7 @@
(ns wanijo.schema.db
(:require [wanijo.infrastructure.neo4j :as neo4j]
[wanijo.schema.domain :as domain]))
[wanijo.schema.domain :as domain]
[clojure.spec.alpha :as spec]))
(neo4j/defquery all-created-by
"MATCH (s:schema)-[:created_by]->(u:user)
@ -43,14 +44,20 @@
(neo4j/defquery find-by-uuid
"MATCH (s:schema)
WHERE s.uuid = {uuid}
RETURN s")
OPTIONAL MATCH
(s)<-[:of]-(a:attribute)
WHERE a.required = 1
RETURN s, a
ORDER BY a.name")
(defn find-by-uuid! [uuid]
(->>
(neo4j/exec-query!
find-by-uuid
{:uuid uuid})
first
:s))
{:post [(spec/assert ::domain/schema-with-req-attrs %)]}
(let [result (neo4j/exec-query!
find-by-uuid
{:uuid uuid})
schema (:s (first result))]
(when schema
(assoc schema
:req-attrs (map :a result)))))
(neo4j/defquery schema-permissions
"MATCH (s:schema {uuid:{schema_uuid}})

@ -1,6 +1,7 @@
(ns wanijo.schema.domain
(:require [clojure.spec.alpha :as spec]
[wanijo.specs :as specs]
[wanijo.attribute.domain :as domain-attr]
[wanijo.infrastructure.neo4j :as neo4j]))
(spec/def ::name
@ -18,3 +19,9 @@
[{public? :is_public
user-permission :user_has_permission}]
(or public? user-permission))
(spec/def ::req-attrs
(spec/coll-of ::domain-attr/attribute))
(spec/def ::schema-with-req-attrs
(spec/merge ::schema
:req-un [::req-attrs]))

Loading…
Cancel
Save