diff --git a/resources/app/stylesheets/app.less b/resources/app/stylesheets/app.less index 477c330..1e57390 100644 --- a/resources/app/stylesheets/app.less +++ b/resources/app/stylesheets/app.less @@ -243,6 +243,10 @@ table { margin-top: 1rem; margin-bottom: 1rem; + .tags-for-search { + display: none; + } + thead { position: sticky; top: 0; diff --git a/resources/public/js/scripts.js b/resources/public/js/scripts.js index 85aff8f..aaeeb55 100644 --- a/resources/public/js/scripts.js +++ b/resources/public/js/scripts.js @@ -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() }, "") }) diff --git a/src/wanijo/framework/neo4j.clj b/src/wanijo/framework/neo4j.clj index cc663b4..724659a 100644 --- a/src/wanijo/framework/neo4j.clj +++ b/src/wanijo/framework/neo4j.clj @@ -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) diff --git a/src/wanijo/instance/domain.clj b/src/wanijo/instance/domain.clj index 4921fdf..0789ef7 100644 --- a/src/wanijo/instance/domain.clj +++ b/src/wanijo/instance/domain.clj @@ -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 %)]} diff --git a/src/wanijo/instance/view.clj b/src/wanijo/instance/view.clj index 8b9fdfa..2dca798 100644 --- a/src/wanijo/instance/view.clj +++ b/src/wanijo/instance/view.clj @@ -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))]