Merge branch 'master' of https://gitea.heevyis.ninja/josha/wanijooo
commit
42ec83d2e6
@ -1,263 +0,0 @@
|
|||||||
(ns wanijo.instance.view
|
|
||||||
(:require [hiccup
|
|
||||||
[form :as hform]
|
|
||||||
[core :refer [h]]]
|
|
||||||
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
|
||||||
[markdown.core :as md]
|
|
||||||
[formulare.core :as form]
|
|
||||||
[wanijo.tag.view :as view-tag]
|
|
||||||
[wanijo.visualisation.viz :as viz]
|
|
||||||
[wanijo.infrastructure
|
|
||||||
[view :as view]
|
|
||||||
[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
|
|
||||||
:content
|
|
||||||
[[:h1 "All Instances of schema "
|
|
||||||
[:span.schema-title__name (h (:name schema))]]
|
|
||||||
[:h1 "New Instance"]
|
|
||||||
(hform/form-to [:post (path :instance-new)]
|
|
||||||
(form/render-widgets new-form {} req)
|
|
||||||
(hform/hidden-field "schema-uuid"
|
|
||||||
(:uuid schema))
|
|
||||||
(hform/submit-button "Create!"))
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Updated"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [instance instances]
|
|
||||||
[:tr
|
|
||||||
[:td
|
|
||||||
[:a {:href (path :instance-show instance)}
|
|
||||||
(h (:name instance))]
|
|
||||||
(tags-for-search instance)]
|
|
||||||
[:td (prettify-dt (:updated_at instance))]
|
|
||||||
[:td (prettify-dt (:created_at instance))]])]]]))
|
|
||||||
|
|
||||||
(defn list-starred [instances req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1 "Starred instances"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Starred"]
|
|
||||||
[:th "Updated"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [instance instances]
|
|
||||||
[:tr
|
|
||||||
[:td
|
|
||||||
[:a {:href (path :instance-show instance)}
|
|
||||||
(h (:name instance))]]
|
|
||||||
[:td (prettify-dt (:starred_at instance))]
|
|
||||||
[:td (prettify-dt (:updated_at instance))]
|
|
||||||
[:td (prettify-dt (:created_at instance))]])]]]))
|
|
||||||
|
|
||||||
(defn show! [instance schemas req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1
|
|
||||||
(if (:starred instance)
|
|
||||||
(hform/form-to {:class "inline"}
|
|
||||||
[:delete (path :instance-mark-starred instance)]
|
|
||||||
(anti-forgery-field)
|
|
||||||
(hform/submit-button "★"))
|
|
||||||
(hform/form-to {:class "inline"}
|
|
||||||
[:post (path :instance-mark-starred instance)]
|
|
||||||
(anti-forgery-field)
|
|
||||||
(hform/submit-button "☆")))
|
|
||||||
" "
|
|
||||||
(h (-> instance :schema :name))
|
|
||||||
" "
|
|
||||||
[:small (h (:name instance))]]
|
|
||||||
[:p [:small
|
|
||||||
[:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (-> instance :schema :uuid)})}
|
|
||||||
"Back to List"]
|
|
||||||
" | "
|
|
||||||
[:a {:href (path :instance-edit-form instance)}
|
|
||||||
"Edit Instance"]
|
|
||||||
" | "
|
|
||||||
[:a {:href (path :vis-explore {:instance-uuid (:uuid instance)})}
|
|
||||||
"Explore from here"]]]
|
|
||||||
(when (seq (:tags instance))
|
|
||||||
[:section.tags
|
|
||||||
(view-tag/tag-list (:tags instance))])
|
|
||||||
(when (seq (:properties instance))
|
|
||||||
[:section.properties
|
|
||||||
[:h2 "Properties"]
|
|
||||||
(for [prop (:properties instance)
|
|
||||||
:let [attr (:attribute prop)
|
|
||||||
type (:type attr)
|
|
||||||
render-fn (case type
|
|
||||||
"date" #(str (prettify-dt %))
|
|
||||||
"markdown" md/md-to-html-string
|
|
||||||
#(str "<p>" % "</p>"))]]
|
|
||||||
(list [:h3 (h (:name attr))]
|
|
||||||
[:div {:class (str "instance-content "
|
|
||||||
"attr-type-" type)}
|
|
||||||
(render-fn (:value prop))]))])
|
|
||||||
(when (or (seq (:links-out instance))
|
|
||||||
(seq (:links-in instance)))
|
|
||||||
[:section.visualisation
|
|
||||||
[:h2 "Visualisation"]
|
|
||||||
[:p (viz/single-instance instance)]])
|
|
||||||
(when (seq (:links-out instance))
|
|
||||||
[:section.links-out
|
|
||||||
[:h2 "Outgoing Links"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Instance"]
|
|
||||||
[:th "Schema"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [{:keys [link target schema] :as row} (:links-out instance)
|
|
||||||
:let [name (:name link)
|
|
||||||
empty (empty? name)
|
|
||||||
name (if empty [:i "empty"] (h name))]]
|
|
||||||
[:tr
|
|
||||||
[:td
|
|
||||||
name
|
|
||||||
(tags-for-search row)]
|
|
||||||
[:td [:a {:href (path :instance-show target)}
|
|
||||||
(h (:name target))]]
|
|
||||||
[:td [:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]]
|
|
||||||
[:td (prettify-dt (:created_at link))]])]]])
|
|
||||||
(when (seq (:links-in instance))
|
|
||||||
[:section.links-in
|
|
||||||
[:h2 "Incoming Links"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Instance"]
|
|
||||||
[:th "Schema"]
|
|
||||||
[:th "Created"]]]
|
|
||||||
[:tbody
|
|
||||||
(for [{:keys [link source schema] :as row} (:links-in instance)
|
|
||||||
:let [name (:name link)
|
|
||||||
empty (empty? name)
|
|
||||||
name (if empty [:i "empty"] (h name))]]
|
|
||||||
[:tr
|
|
||||||
[:td
|
|
||||||
name
|
|
||||||
(tags-for-search row)]
|
|
||||||
[:td [:a {:href (path :instance-show source)}
|
|
||||||
(h (:name source))]]
|
|
||||||
[:td [:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]]
|
|
||||||
[:td (prettify-dt (:created_at link))]])]]])
|
|
||||||
[:section.quick-edits
|
|
||||||
[:h2 "Quick edits"]
|
|
||||||
[:section.link-instance
|
|
||||||
[:h3 "Link Instance with Instance of Schema..."]
|
|
||||||
[:ul
|
|
||||||
(for [schema schemas]
|
|
||||||
[:li
|
|
||||||
[:a {:href (path :instance-link-selection
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]])]]
|
|
||||||
[:section.tag-instance
|
|
||||||
[:h3 "Add or create Tags"]
|
|
||||||
(view-tag/new-tag-form instance)]]]))
|
|
||||||
|
|
||||||
(defn edit! [instance form form-data schemas req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1
|
|
||||||
(h (-> instance :schema :name))
|
|
||||||
" "
|
|
||||||
[:small (h (:name instance))]]
|
|
||||||
[:p [:small
|
|
||||||
[:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (-> instance :schema :uuid)})}
|
|
||||||
"Back to List"]
|
|
||||||
" | "
|
|
||||||
[:a {:href (path :instance-show instance)}
|
|
||||||
"Back to Instance"]]]
|
|
||||||
[:section.edit-instance
|
|
||||||
[:h2 "Edit Instance"]
|
|
||||||
(hform/form-to [:post (path :instance-edit instance)]
|
|
||||||
(form/render-widgets form form-data req)
|
|
||||||
(hform/submit-button "Edit!"))
|
|
||||||
(hform/form-to [:delete (path :instance-delete instance)]
|
|
||||||
(anti-forgery-field)
|
|
||||||
(view/delete-btn))]
|
|
||||||
(when (seq (:links-out instance))
|
|
||||||
[:section.links-out
|
|
||||||
[:h2 "Outgoing Links"]
|
|
||||||
[:table
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
[:th "Name"]
|
|
||||||
[:th "Instance"]
|
|
||||||
[:th "Schema"]
|
|
||||||
[:th "Created"]
|
|
||||||
[:th]]]
|
|
||||||
[:tbody
|
|
||||||
(for [{:keys [link target schema]} (:links-out instance)
|
|
||||||
:let [name (:name link)
|
|
||||||
empty (empty? name)
|
|
||||||
name (if empty [:i "empty"] (h name))]]
|
|
||||||
[:tr
|
|
||||||
[:td name]
|
|
||||||
[:td [:a {:href (path :instance-show target)}
|
|
||||||
(h (:name target))]]
|
|
||||||
[:td [:a {:href (path :instance-list
|
|
||||||
{:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]]
|
|
||||||
[:td (prettify-dt (:created_at link))]
|
|
||||||
[:td (hform/form-to [:delete (path :instance-link-delete
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:link-uuid (:uuid link)})]
|
|
||||||
(anti-forgery-field)
|
|
||||||
(view/delete-btn))]])]]])
|
|
||||||
(when (seq (:tags instance))
|
|
||||||
[:section.tags
|
|
||||||
[:h2 "Tags"]
|
|
||||||
(view-tag/tag-table instance)])
|
|
||||||
[:section.link-instance
|
|
||||||
[:h2 "Link Instance with Instance of Schema..."]
|
|
||||||
[:ul
|
|
||||||
(for [schema schemas]
|
|
||||||
[:li
|
|
||||||
[:a {:href (path :instance-link-selection
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:schema-uuid (:uuid schema)})}
|
|
||||||
(h (:name schema))]])]]]))
|
|
||||||
|
|
||||||
(defn link-selection [instance schema form req]
|
|
||||||
(view/layout!
|
|
||||||
:request req
|
|
||||||
:content
|
|
||||||
[[:h1
|
|
||||||
[:small "Link " (-> instance :schema :name) " "]
|
|
||||||
(h (:name instance))
|
|
||||||
[:small " with "]
|
|
||||||
(h (:name schema))]
|
|
||||||
(hform/form-to [:post (path :instance-link-create
|
|
||||||
{:uuid (:uuid instance)
|
|
||||||
:schema-uuid (:uuid schema)})]
|
|
||||||
(form/render-widgets form nil req)
|
|
||||||
(hform/submit-button "Link!"))]))
|
|
@ -0,0 +1,75 @@
|
|||||||
|
(ns wanijo.instance.view.edit
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
||||||
|
[wanijo.infrastructure.view :as view]
|
||||||
|
[wanijo.infrastructure.routing :refer [path]]
|
||||||
|
[wanijo.infrastructure.time :refer [prettify-dt]]
|
||||||
|
[wanijo.tag.view :as view-tag]
|
||||||
|
[formulare.core :as form]))
|
||||||
|
|
||||||
|
(defn edit [instance form form-data schemas req]
|
||||||
|
(view/layout!
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
(h (-> instance :schema :name))
|
||||||
|
" "
|
||||||
|
[:small (h (:name instance))]]
|
||||||
|
[:p [:small
|
||||||
|
[:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (-> instance :schema :uuid)})}
|
||||||
|
"Back to List"]
|
||||||
|
" | "
|
||||||
|
[:a {:href (path :instance-show instance)}
|
||||||
|
"Back to Instance"]]]
|
||||||
|
[:section.edit-instance
|
||||||
|
[:h2 "Edit Instance"]
|
||||||
|
(hform/form-to [:post (path :instance-edit instance)]
|
||||||
|
(form/render-widgets form form-data req)
|
||||||
|
(hform/submit-button "Edit!"))
|
||||||
|
(hform/form-to [:delete (path :instance-delete instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(view/delete-btn))]
|
||||||
|
(when (seq (:links-out instance))
|
||||||
|
[:section.links-out
|
||||||
|
[:h2 "Outgoing Links"]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Instance"]
|
||||||
|
[:th "Schema"]
|
||||||
|
[:th "Created"]
|
||||||
|
[:th]]]
|
||||||
|
[:tbody
|
||||||
|
(for [{:keys [link target schema]} (:links-out instance)
|
||||||
|
:let [name (:name link)
|
||||||
|
empty (empty? name)
|
||||||
|
name (if empty [:i "empty"] (h name))]]
|
||||||
|
[:tr
|
||||||
|
[:td name]
|
||||||
|
[:td [:a {:href (path :instance-show target)}
|
||||||
|
(h (:name target))]]
|
||||||
|
[:td [:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]]
|
||||||
|
[:td (prettify-dt (:created_at link))]
|
||||||
|
[:td (hform/form-to [:delete (path :instance-link-delete
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:link-uuid (:uuid link)})]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(view/delete-btn))]])]]])
|
||||||
|
(when (seq (:tags instance))
|
||||||
|
[:section.tags
|
||||||
|
[:h2 "Tags"]
|
||||||
|
(view-tag/tag-table instance)])
|
||||||
|
[:section.link-instance
|
||||||
|
[:h2 "Link Instance with Instance of Schema..."]
|
||||||
|
[:ul
|
||||||
|
(for [schema schemas]
|
||||||
|
[:li
|
||||||
|
[:a {:href (path :instance-link-selection
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]])]]]))
|
@ -0,0 +1,46 @@
|
|||||||
|
(ns wanijo.instance.view.instances
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[formulare.core :as form]
|
||||||
|
[wanijo.instance.view.view :as view-instance]
|
||||||
|
[wanijo.infrastructure.view :as view]
|
||||||
|
[wanijo.infrastructure.routing :refer [path]]
|
||||||
|
[wanijo.infrastructure.time :refer [prettify-dt]]))
|
||||||
|
|
||||||
|
(defn instances [schema instances new-form req]
|
||||||
|
(view/layout!
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1 "All Instances of schema "
|
||||||
|
[:span.schema-title__name (h (:name schema))]]
|
||||||
|
[:h1 "New Instance"]
|
||||||
|
(hform/form-to [:post (path :instance-new)]
|
||||||
|
(form/render-widgets new-form {} req)
|
||||||
|
(hform/hidden-field "schema-uuid"
|
||||||
|
(:uuid schema))
|
||||||
|
(hform/submit-button "Create!"))
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
(map (fn [attr] [:th (h (:name attr))])
|
||||||
|
(:req-attrs schema))
|
||||||
|
[:th "Updated"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [instance instances]
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
[: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))]])]]]))
|
@ -0,0 +1,21 @@
|
|||||||
|
(ns wanijo.instance.view.link-selection
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[wanijo.infrastructure.view :as view]
|
||||||
|
[wanijo.infrastructure.routing :refer [path]]
|
||||||
|
[formulare.core :as form]))
|
||||||
|
|
||||||
|
(defn link-selection [instance schema form req]
|
||||||
|
(view/layout!
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
[:small "Link " (-> instance :schema :name) " "]
|
||||||
|
(h (:name instance))
|
||||||
|
[:small " with "]
|
||||||
|
(h (:name schema))]
|
||||||
|
(hform/form-to [:post (path :instance-link-create
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:schema-uuid (:uuid schema)})]
|
||||||
|
(form/render-widgets form nil req)
|
||||||
|
(hform/submit-button "Link!"))]))
|
@ -0,0 +1,126 @@
|
|||||||
|
(ns wanijo.instance.view.show
|
||||||
|
(:require [hiccup.form :as hform]
|
||||||
|
[hiccup.core :refer [h]]
|
||||||
|
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
||||||
|
[wanijo.infrastructure.view :as view]
|
||||||
|
[wanijo.infrastructure.routing :refer [path]]
|
||||||
|
[wanijo.infrastructure.time :refer [prettify-dt]]
|
||||||
|
[wanijo.instance.view.view :as view-instance]
|
||||||
|
[wanijo.tag.view :as view-tag]
|
||||||
|
[markdown.core :as md]
|
||||||
|
[wanijo.visualisation.viz :as viz]))
|
||||||
|
|
||||||
|
(defn show [instance schemas req]
|
||||||
|
(view/layout!
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1
|
||||||
|
(if (:starred instance)
|
||||||
|
(hform/form-to {:class "inline"}
|
||||||
|
[:delete (path :instance-mark-starred instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(hform/submit-button "★"))
|
||||||
|
(hform/form-to {:class "inline"}
|
||||||
|
[:post (path :instance-mark-starred instance)]
|
||||||
|
(anti-forgery-field)
|
||||||
|
(hform/submit-button "☆")))
|
||||||
|
" "
|
||||||
|
(h (-> instance :schema :name))
|
||||||
|
" "
|
||||||
|
[:small (h (:name instance))]]
|
||||||
|
[:p [:small
|
||||||
|
[:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (-> instance :schema :uuid)})}
|
||||||
|
"Back to List"]
|
||||||
|
" | "
|
||||||
|
[:a {:href (path :instance-edit-form instance)}
|
||||||
|
"Edit Instance"]
|
||||||
|
" | "
|
||||||
|
[:a {:href (path :vis-explore {:instance-uuid (:uuid instance)})}
|
||||||
|
"Explore from here"]]]
|
||||||
|
(when (seq (:tags instance))
|
||||||
|
[:section.tags
|
||||||
|
(view-tag/tag-list (:tags instance))])
|
||||||
|
(when (seq (:properties instance))
|
||||||
|
[:section.properties
|
||||||
|
[:h2 "Properties"]
|
||||||
|
(for [prop (:properties instance)
|
||||||
|
:let [attr (:attribute prop)
|
||||||
|
type (:type attr)
|
||||||
|
render-fn (case type
|
||||||
|
"date" #(str (prettify-dt %))
|
||||||
|
"markdown" md/md-to-html-string
|
||||||
|
#(str "<p>" % "</p>"))]]
|
||||||
|
(list [:h3 (h (:name attr))]
|
||||||
|
[:div {:class (str "instance-content "
|
||||||
|
"attr-type-" type)}
|
||||||
|
(render-fn (:value prop))]))])
|
||||||
|
(when (or (seq (:links-out instance))
|
||||||
|
(seq (:links-in instance)))
|
||||||
|
[:section.visualisation
|
||||||
|
[:h2 "Visualisation"]
|
||||||
|
[:p (viz/single-instance instance)]])
|
||||||
|
(when (seq (:links-out instance))
|
||||||
|
[:section.links-out
|
||||||
|
[:h2 "Outgoing Links"]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Instance"]
|
||||||
|
[:th "Schema"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [{:keys [link target schema] :as row} (:links-out instance)
|
||||||
|
:let [name (:name link)
|
||||||
|
empty (empty? name)
|
||||||
|
name (if empty [:i "empty"] (h name))]]
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
name
|
||||||
|
(view-instance/tags-for-search row)]
|
||||||
|
[:td [:a {:href (path :instance-show target)}
|
||||||
|
(h (:name target))]]
|
||||||
|
[:td [:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]]
|
||||||
|
[:td (prettify-dt (:created_at link))]])]]])
|
||||||
|
(when (seq (:links-in instance))
|
||||||
|
[:section.links-in
|
||||||
|
[:h2 "Incoming Links"]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Instance"]
|
||||||
|
[:th "Schema"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [{:keys [link source schema] :as row} (:links-in instance)
|
||||||
|
:let [name (:name link)
|
||||||
|
empty (empty? name)
|
||||||
|
name (if empty [:i "empty"] (h name))]]
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
name
|
||||||
|
(view-instance/tags-for-search row)]
|
||||||
|
[:td [:a {:href (path :instance-show source)}
|
||||||
|
(h (:name source))]]
|
||||||
|
[:td [:a {:href (path :instance-list
|
||||||
|
{:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]]
|
||||||
|
[:td (prettify-dt (:created_at link))]])]]])
|
||||||
|
[:section.quick-edits
|
||||||
|
[:h2 "Quick edits"]
|
||||||
|
[:section.link-instance
|
||||||
|
[:h3 "Link Instance with Instance of Schema..."]
|
||||||
|
[:ul
|
||||||
|
(for [schema schemas]
|
||||||
|
[:li
|
||||||
|
[:a {:href (path :instance-link-selection
|
||||||
|
{:uuid (:uuid instance)
|
||||||
|
:schema-uuid (:uuid schema)})}
|
||||||
|
(h (:name schema))]])]]
|
||||||
|
[:section.tag-instance
|
||||||
|
[:h3 "Add or create Tags"]
|
||||||
|
(view-tag/new-tag-form instance)]]]))
|
@ -0,0 +1,27 @@
|
|||||||
|
(ns wanijo.instance.view.starred
|
||||||
|
(:require [hiccup.core :refer [h]]
|
||||||
|
[wanijo.infrastructure.view :as view]
|
||||||
|
[wanijo.infrastructure.routing :refer [path]]
|
||||||
|
[wanijo.infrastructure.time :refer [prettify-dt]]))
|
||||||
|
|
||||||
|
(defn starred [instances req]
|
||||||
|
(view/layout!
|
||||||
|
:request req
|
||||||
|
:content
|
||||||
|
[[:h1 "Starred instances"]
|
||||||
|
[:table
|
||||||
|
[:thead
|
||||||
|
[:tr
|
||||||
|
[:th "Name"]
|
||||||
|
[:th "Starred"]
|
||||||
|
[:th "Updated"]
|
||||||
|
[:th "Created"]]]
|
||||||
|
[:tbody
|
||||||
|
(for [instance instances]
|
||||||
|
[:tr
|
||||||
|
[:td
|
||||||
|
[:a {:href (path :instance-show instance)}
|
||||||
|
(h (:name instance))]]
|
||||||
|
[:td (prettify-dt (:starred_at instance))]
|
||||||
|
[:td (prettify-dt (:updated_at instance))]
|
||||||
|
[:td (prettify-dt (:created_at instance))]])]]]))
|
@ -0,0 +1,6 @@
|
|||||||
|
(ns wanijo.instance.view.view
|
||||||
|
(:require [hiccup.core :refer [h]]))
|
||||||
|
|
||||||
|
(defn tags-for-search [{tags :tags}]
|
||||||
|
[:span.tags-for-search
|
||||||
|
(reduce #(str %1 ":" (h (:name %2))) "" tags)])
|
@ -0,0 +1,27 @@
|
|||||||
|
(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
|
||||||
|
(spec/and ::specs/name (complement empty?)))
|
||||||
|
(spec/def ::assigned-to
|
||||||
|
(spec/or :public empty?
|
||||||
|
:assigned (spec/coll-of ::neo4j/uuid)
|
||||||
|
:assigned-single ::neo4j/uuid))
|
||||||
|
(spec/def ::schema
|
||||||
|
(spec/keys ::req-un [::name
|
||||||
|
::specs/created-at
|
||||||
|
::neo4j/uuid]))
|
||||||
|
|
||||||
|
(defn has-user-permission?
|
||||||
|
[{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…
Reference in new issue