search in tables by tag

neo4j-4
Josha von Gizycki 5 years ago
parent a953dc9800
commit 62929a8c22

@ -243,6 +243,10 @@ table {
margin-top: 1rem;
margin-bottom: 1rem;
.tags-for-search {
display: none;
}
thead {
position: sticky;
top: 0;

@ -147,7 +147,7 @@ document.addEventListener('DOMContentLoaded', function () {
const contents = tblRows(ctx.tbl).map(function (row) {
return Array.from(row.cells).reduce(function (carr, cell) {
return carr + cell.innerText.toLocaleLowerCase()
return carr + cell.textContent.toLocaleLowerCase()
}, "")
})

@ -12,7 +12,7 @@
(spec/def ::uuid
#(re-matches
#"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" %))
#"[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+-[0-9a-f]+" %))
(def conn
(let [env #(or (System/getenv %1) %2)

@ -38,16 +38,25 @@
(spec/def ::contains-schema
(spec/keys :req-un [::domain-schema/schema]))
(spec/def ::instances-with-tags
(spec/coll-of (spec/merge ::instance
(spec/keys :req-un [::tags]))))
(neo4j/defquery findy-by-schema
"MATCH (i:instance)-[:of]->(s:schema)
WHERE s.uuid = {uuid}
RETURN i
OPTIONAL MATCH
(i)-[:tagged_with]->(t:tag)
RETURN i, t
ORDER BY i.name")
(defn find-by-schema! [schema-uuid]
(map :i
(neo4j/exec-query!
findy-by-schema
{:uuid schema-uuid})))
{:post [(spec/assert ::instances-with-tags %)]}
(->> (neo4j/exec-query! findy-by-schema
{:uuid schema-uuid})
(group-by :i)
(map #(assoc (key %)
:tags (->> (val %)
(map :t)
(filter some?))))))
(neo4j/defquery create-instance
"MATCH (s:schema {uuid:{schema_uuid}}),
@ -91,8 +100,7 @@
(spec/def ::instance-with-schema
(spec/merge ::instance ::contains-schema))
(neo4j/defquery find-by-uuid
"MATCH (i:instance {uuid:{uuid}})
-[:of]->(s:schema)
"MATCH (i:instance {uuid:{uuid}})-[:of]->(s:schema)
RETURN i, s")
(defn find-by-uuid! [uuid]
{:post [(spec/assert ::instance-with-schema %)]}

@ -13,6 +13,10 @@
[routing :refer [path]]
[time :refer [prettify-dt]]]))
(defn tags-for-search [{tags :tags}]
[:span.tags-for-search
(reduce #(str %1 ":" (:name %2)) "" tags)])
(defn list! [schema instances new-form req]
(view/layout!
:request req
@ -35,6 +39,7 @@
(for [instance instances]
[:tr
[:td
(tags-for-search instance)
[:a {:href (path :instance-show instance)}
(h (:name instance))]]
[:td (prettify-dt (:updated_at instance))]

Loading…
Cancel
Save