You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
(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.infra.view :as view]
|
|
[wanijo.infra.routing :refer [path]]
|
|
[wanijo.infra.time :refer [prettify-dt]]))
|
|
|
|
(defn instances [schema instances new-form req]
|
|
(view/layout
|
|
:request req
|
|
:title (:name schema)
|
|
: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"]
|
|
(view-instance/req-attrs-headings 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)]
|
|
(view-instance/req-attrs-cells schema instance)
|
|
[:td (prettify-dt (:updated_at instance))]
|
|
[:td (prettify-dt (:created_at instance))]])]]]))
|