create attributes, switch back to english in ui, fixes

integration-tests
Josha von Gizycki 6 years ago
parent 37c42d94ac
commit 5cd55676fc

@ -8,7 +8,7 @@
(spec/def ::type (spec/def ::type
(spec/and (spec/and
string? string?
#(some #{"date" "file" "string" "text"} %))) #(some (partial = %) ["date" "file", "string" "text"])))
(spec/def ::required (spec/def ::required
(spec/or :bool-val boolean? (spec/or :bool-val boolean?
@ -42,6 +42,6 @@
(neo4j/exec-query! (neo4j/exec-query!
create-new create-new
{:user_uuid user-uuid {:user_uuid user-uuid
:schem_uuid schema-uuid :schema_uuid schema-uuid
:type type :type type
:name name})) :name name}))

@ -16,8 +16,7 @@
(get-in req [:params :type]) (get-in req [:params :type])
schema-uuid schema-uuid
(get-in req [:session :uuid])) (get-in req [:session :uuid]))
(resp/redirect (path :schema-show (resp/redirect (path :schema-show {:uuid schema-uuid})))
schema-uuid)))
(view-schema/show-schema! (view-schema/show-schema!
(domain-schema/find-by-uuid! schema-uuid) (domain-schema/find-by-uuid! schema-uuid)
(domain/find-by-schema! schema-uuid) (domain/find-by-schema! schema-uuid)

@ -41,7 +41,7 @@
(defn field (defn field
([form-def field-id req] ([form-def field-id req]
(field form-def field-id req (field form-def field-id req
(get-in req [:params field]))) (get-in req [:params field-id])))
([form-def field-id req field-value] ([form-def field-id req field-value]
{:pre [(spec/valid? ::form form-def)]} {:pre [(spec/valid? ::form form-def)]}
(let [field-def (get-in form-def [:fields field-id]) (let [field-def (get-in form-def [:fields field-id])

@ -2,9 +2,13 @@
(:require [neo4j-clj.core :as db] (:require [neo4j-clj.core :as db]
[wanijo.framework.devmode :as devmode] [wanijo.framework.devmode :as devmode]
[clj-time.format :as time-format] [clj-time.format :as time-format]
[clj-time.local :as time-local]) [clj-time.local :as time-local]
[clojure.spec.alpha :as spec])
(:import (java.util UUID))) (:import (java.util UUID)))
(spec/def ::date-str
#(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %))
(def conn (def conn
(delay (db/connect (delay (db/connect
"bolt://localhost:7687" "bolt://localhost:7687"

@ -33,15 +33,15 @@
[:h1.app-title "wan ijo" [:h1.app-title "wan ijo"
(when authed? (when authed?
[:small.app-title__hello [:small.app-title__hello
"O, " "Hi, "
[:a {:href (path :user-profile)} ident]])] [:a {:href (path :user-profile)} ident]])]
(when authed? (when authed?
[:section.header-content [:section.header-content
(btnlink (path :schema-overview) (btnlink (path :schema-overview)
"Jaki ijo" "Schemas"
"header-content__link") "header-content__link")
(btnlink (path :auth-logout) (btnlink (path :auth-logout)
"Lape!" "Logout!"
"header-content__link")])] "header-content__link")])]
[:nav (when authed? "nav")] [:nav (when authed? "nav")]
(vec (concat [:main] content)) (vec (concat [:main] content))
@ -51,5 +51,5 @@
(defn flash-error [content] (defn flash-error [content]
[:section.flash--error [:section.flash--error
[:h2.flash__heading--error "Pakala"] [:h2.flash__heading--error "Warning"]
content]) content])

@ -6,8 +6,7 @@
(spec/and string? not-empty)) (spec/and string? not-empty))
(spec/def ::created-at (spec/def ::created-at
(spec/and string? (spec/and string? ::neo4j/date-str))
#(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %)))
(neo4j/defquery (neo4j/defquery
all-created-by all-created-by

@ -9,22 +9,22 @@
[wanijo.attribute.domain :as attr-domain])) [wanijo.attribute.domain :as attr-domain]))
(def new-form (def new-form
{:fields {:schema-name {:label "Nimi" {:fields {:schema-name {:label "Name"
:required true :required true
:spec ::domain/name}}}) :spec ::domain/name}}})
(def new-attr-form (def new-attr-form
{:fields {:name {:label "Nimi" {:fields {:name {:label "Name"
:required true :required true
:spec ::attr-domain/name} :spec ::attr-domain/name}
:type {:label "Tomo" :type {:label "Type"
:required true :required true
:spec ::attr-domain/type :spec ::attr-domain/type
:options [["Lon e lipu" "string"] :options [["String" "string"]
["Ali lon e lipu" "text"] ["Text" "text"]
["Kama" "date"] ["Date" "date"]
["Sitelen" "file"]]} ["File" "file"]]}
:required {:label "Wile" :required {:label "Required"
:required false :required false
:spec ::attr-domain/required}}}) :spec ::attr-domain/required}}})
@ -35,12 +35,12 @@
(view/layout! (view/layout!
:session session :session session
:content :content
[[:h1 "Ali jaki ijo"] [[:h1 "All schemas"]
[:table [:table
[:thead [:thead
[:tr [:tr
[:th "Nimi"] [:th "Name"]
[:th "Tenpo kama"]]] [:th "Created"]]]
[:tbody [:tbody
(for [schema schemas] (for [schema schemas]
[:tr [:tr
@ -49,33 +49,33 @@
(:name schema)]] (:name schema)]]
[:td [:td
(prettify-dt (:created_at schema))]])]] (prettify-dt (:created_at schema))]])]]
[:h1 "Pali sin e jaki ijo"] [:h1 "New schema"]
(hform/form-to [:post (path :schema-new)] (hform/form-to [:post (path :schema-new)]
(anti-forgery-field) (anti-forgery-field)
(form/field new-form :schema-name req) (form/field new-form :schema-name req)
(hform/submit-button "Pali"))]))) (hform/submit-button "Create"))])))
(defn show-schema! [schema attrs req] (defn show-schema! [schema attrs req]
(view/layout! (view/layout!
:session (:session req) :session (:session req)
:content :content
[[:h1 "Jaki ijo " [[:h1 "Schema "
[:span.schema-title__name (:name schema)]] [:span.schema-title__name (:name schema)]]
(hform/form-to [:post "/schema/edit"]) (hform/form-to [:post "/schema/edit"])
[:h2 "Lili wan e jaki ijo"] [:h2 "Attributes"]
[:ul [:ul
(for [attr attrs] (for [attr attrs]
[:li (:name attr)])] [:li (:name attr)])]
[:h3 "Pali lili wan"] [:h3 "New attribute"]
(hform/form-to [:post (path :attribute-new)] (hform/form-to [:post (path :attribute-new)]
(anti-forgery-field) (anti-forgery-field)
(hform/hidden-field "schema" (:uuid schema)) (hform/hidden-field "schema" (:uuid schema))
(form/field new-attr-form :name req) (form/field new-attr-form :name req)
(form/drop-down new-attr-form :type req) (form/drop-down new-attr-form :type req)
(form/check-box new-attr-form :required req) (form/check-box new-attr-form :required req)
(hform/submit-button "Pali")) (hform/submit-button "Save"))
[:h2 "Mute pali"] [:h2 "Actions"]
(hform/form-to {:class "inline"} (hform/form-to {:class "inline"}
[:delete (path :schema-delete schema)] [:delete (path :schema-delete schema)]
(anti-forgery-field) (anti-forgery-field)
(hform/submit-button "Pakala!"))])) (hform/submit-button "Delete!"))]))

@ -21,7 +21,7 @@
(view/layout! (view/layout!
:session (:session req) :session (:session req)
:content :content
[[:h1 "O, " (get-in req [:session :ident])] [[:h1 "Hi, " (get-in req [:session :ident])]
[:div (str user)] [:div (str user)]
(hform/form-to [:post (path :user-edit)] (hform/form-to [:post (path :user-edit)]
(anti-forgery-field) (anti-forgery-field)

Loading…
Cancel
Save