|  |  | @ -1,5 +1,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | (ns wanijo.instance.view |  |  |  | (ns wanijo.instance.view | 
			
		
	
		
		
			
				
					
					|  |  |  |   (:require [hiccup.form :as hform] |  |  |  |   (:require [hiccup | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              [form :as hform] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |              [core :refer [h]]] | 
			
		
	
		
		
			
				
					
					|  |  |  |             [ring.util.anti-forgery :refer [anti-forgery-field]] |  |  |  |             [ring.util.anti-forgery :refer [anti-forgery-field]] | 
			
		
	
		
		
			
				
					
					|  |  |  |             [formulare.core :as form] |  |  |  |             [formulare.core :as form] | 
			
		
	
		
		
			
				
					
					|  |  |  |             [wanijo.instance.domain :as domain] |  |  |  |             [wanijo.instance.domain :as domain] | 
			
		
	
	
		
		
			
				
					|  |  | @ -12,7 +14,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |    :request req |  |  |  |    :request req | 
			
		
	
		
		
			
				
					
					|  |  |  |    :content |  |  |  |    :content | 
			
		
	
		
		
			
				
					
					|  |  |  |    [[:h1 "All Instances of schema " |  |  |  |    [[:h1 "All Instances of schema " | 
			
		
	
		
		
			
				
					
					|  |  |  |      [:span.schema-title__name (:name schema)]] |  |  |  |      [:span.schema-title__name (h (:name schema))]] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     [:table |  |  |  |     [:table | 
			
		
	
		
		
			
				
					
					|  |  |  |      [:thead |  |  |  |      [:thead | 
			
		
	
		
		
			
				
					
					|  |  |  |       [:tr |  |  |  |       [:tr | 
			
		
	
	
		
		
			
				
					|  |  | @ -24,7 +26,7 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |         [:tr |  |  |  |         [:tr | 
			
		
	
		
		
			
				
					
					|  |  |  |          [:td |  |  |  |          [:td | 
			
		
	
		
		
			
				
					
					|  |  |  |           [:a {:href (path :instance-show instance)} |  |  |  |           [:a {:href (path :instance-show instance)} | 
			
		
	
		
		
			
				
					
					|  |  |  |            (:name instance)]] |  |  |  |            (h (:name instance))]] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |          [:td (prettify-dt (:updated_at instance))] |  |  |  |          [:td (prettify-dt (:updated_at instance))] | 
			
		
	
		
		
			
				
					
					|  |  |  |          [:td (prettify-dt (:created_at instance))]])]] |  |  |  |          [:td (prettify-dt (:created_at instance))]])]] | 
			
		
	
		
		
			
				
					
					|  |  |  |     [:h1 "New Instance"] |  |  |  |     [:h1 "New Instance"] | 
			
		
	
	
		
		
			
				
					|  |  | @ -34,11 +36,32 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  |                                        (:uuid schema)) |  |  |  |                                        (:uuid schema)) | 
			
		
	
		
		
			
				
					
					|  |  |  |                    (hform/submit-button "Create!"))])) |  |  |  |                    (hform/submit-button "Create!"))])) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | (defn show! [instance form form-data req] |  |  |  | (defn show! [instance attrs req] | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   (view/layout! |  |  |  |   (view/layout! | 
			
		
	
		
		
			
				
					
					|  |  |  |    :request req |  |  |  |    :request req | 
			
		
	
		
		
			
				
					
					|  |  |  |    :content |  |  |  |    :content | 
			
		
	
		
		
			
				
					
					|  |  |  |    [[:h1 (:name instance)] |  |  |  |    [[:h1 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      (h (-> instance :schema :name)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      " " | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      [:small (h (:name instance))]] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     [:p | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      [:small [:a {:href (path :instance-edit-form instance)} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |               "Edit Instance"]]] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     (for [attr attrs | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           :let [auuid (:uuid attr) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 prop (first (filter #(= auuid (-> % :attribute :uuid)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                     (:properties instance)))]] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       (list [:em (h (:name attr))] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             [:p (h (:value prop))]))])) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | (defn edit! [instance form form-data req] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   (view/layout! | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |    :request req | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |    :content | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |    [[:h1 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      (h (-> instance :schema :name)) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      " " | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      [:small (h (:name instance))]] | 
			
		
	
		
		
			
				
					
					|  |  |  |     (hform/form-to [:post (path :instance-edit instance)] |  |  |  |     (hform/form-to [:post (path :instance-edit instance)] | 
			
		
	
		
		
			
				
					
					|  |  |  |                    (form/render-widgets form form-data req) |  |  |  |                    (form/render-widgets form form-data req) | 
			
		
	
		
		
			
				
					
					|  |  |  |                    (hform/submit-button "Edit!")) |  |  |  |                    (hform/submit-button "Edit!")) | 
			
		
	
	
		
		
			
				
					|  |  | 
 |