From 5cd55676fc29cb6f684826959c3506eb3b83aa9e Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Fri, 7 Sep 2018 15:50:22 +0200 Subject: [PATCH] create attributes, switch back to english in ui, fixes --- src/wanijo/attribute/domain.clj | 4 ++-- src/wanijo/attribute/routes.clj | 3 +-- src/wanijo/framework/form.clj | 2 +- src/wanijo/framework/neo4j.clj | 6 +++++- src/wanijo/framework/view.clj | 8 +++---- src/wanijo/schema/domain.clj | 3 +-- src/wanijo/schema/view.clj | 38 ++++++++++++++++----------------- src/wanijo/user/view.clj | 2 +- 8 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/wanijo/attribute/domain.clj b/src/wanijo/attribute/domain.clj index 1329682..708c80e 100644 --- a/src/wanijo/attribute/domain.clj +++ b/src/wanijo/attribute/domain.clj @@ -8,7 +8,7 @@ (spec/def ::type (spec/and string? - #(some #{"date" "file" "string" "text"} %))) + #(some (partial = %) ["date" "file", "string" "text"]))) (spec/def ::required (spec/or :bool-val boolean? @@ -42,6 +42,6 @@ (neo4j/exec-query! create-new {:user_uuid user-uuid - :schem_uuid schema-uuid + :schema_uuid schema-uuid :type type :name name})) diff --git a/src/wanijo/attribute/routes.clj b/src/wanijo/attribute/routes.clj index 99c0cc6..759b310 100644 --- a/src/wanijo/attribute/routes.clj +++ b/src/wanijo/attribute/routes.clj @@ -16,8 +16,7 @@ (get-in req [:params :type]) schema-uuid (get-in req [:session :uuid])) - (resp/redirect (path :schema-show - schema-uuid))) + (resp/redirect (path :schema-show {:uuid schema-uuid}))) (view-schema/show-schema! (domain-schema/find-by-uuid! schema-uuid) (domain/find-by-schema! schema-uuid) diff --git a/src/wanijo/framework/form.clj b/src/wanijo/framework/form.clj index 4e0bb98..35e384e 100644 --- a/src/wanijo/framework/form.clj +++ b/src/wanijo/framework/form.clj @@ -41,7 +41,7 @@ (defn 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] {:pre [(spec/valid? ::form form-def)]} (let [field-def (get-in form-def [:fields field-id]) diff --git a/src/wanijo/framework/neo4j.clj b/src/wanijo/framework/neo4j.clj index 6c62caa..2877531 100644 --- a/src/wanijo/framework/neo4j.clj +++ b/src/wanijo/framework/neo4j.clj @@ -2,9 +2,13 @@ (:require [neo4j-clj.core :as db] [wanijo.framework.devmode :as devmode] [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))) +(spec/def ::date-str + #(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %)) + (def conn (delay (db/connect "bolt://localhost:7687" diff --git a/src/wanijo/framework/view.clj b/src/wanijo/framework/view.clj index 4939e8a..60ab297 100644 --- a/src/wanijo/framework/view.clj +++ b/src/wanijo/framework/view.clj @@ -33,15 +33,15 @@ [:h1.app-title "wan ijo" (when authed? [:small.app-title__hello - "O, " + "Hi, " [:a {:href (path :user-profile)} ident]])] (when authed? [:section.header-content (btnlink (path :schema-overview) - "Jaki ijo" + "Schemas" "header-content__link") (btnlink (path :auth-logout) - "Lape!" + "Logout!" "header-content__link")])] [:nav (when authed? "nav")] (vec (concat [:main] content)) @@ -51,5 +51,5 @@ (defn flash-error [content] [:section.flash--error - [:h2.flash__heading--error "Pakala"] + [:h2.flash__heading--error "Warning"] content]) diff --git a/src/wanijo/schema/domain.clj b/src/wanijo/schema/domain.clj index d25094a..3a6cc8c 100644 --- a/src/wanijo/schema/domain.clj +++ b/src/wanijo/schema/domain.clj @@ -6,8 +6,7 @@ (spec/and string? not-empty)) (spec/def ::created-at - (spec/and string? - #(re-matches #"\d{4}\d{2}\d{2}T\d{2}\d{2}\d{2}\.\d{3}Z" %))) + (spec/and string? ::neo4j/date-str)) (neo4j/defquery all-created-by diff --git a/src/wanijo/schema/view.clj b/src/wanijo/schema/view.clj index 636c2d8..6e88445 100644 --- a/src/wanijo/schema/view.clj +++ b/src/wanijo/schema/view.clj @@ -9,22 +9,22 @@ [wanijo.attribute.domain :as attr-domain])) (def new-form - {:fields {:schema-name {:label "Nimi" + {:fields {:schema-name {:label "Name" :required true :spec ::domain/name}}}) (def new-attr-form - {:fields {:name {:label "Nimi" + {:fields {:name {:label "Name" :required true :spec ::attr-domain/name} - :type {:label "Tomo" + :type {:label "Type" :required true :spec ::attr-domain/type - :options [["Lon e lipu" "string"] - ["Ali lon e lipu" "text"] - ["Kama" "date"] - ["Sitelen" "file"]]} - :required {:label "Wile" + :options [["String" "string"] + ["Text" "text"] + ["Date" "date"] + ["File" "file"]]} + :required {:label "Required" :required false :spec ::attr-domain/required}}}) @@ -35,12 +35,12 @@ (view/layout! :session session :content - [[:h1 "Ali jaki ijo"] + [[:h1 "All schemas"] [:table [:thead [:tr - [:th "Nimi"] - [:th "Tenpo kama"]]] + [:th "Name"] + [:th "Created"]]] [:tbody (for [schema schemas] [:tr @@ -49,33 +49,33 @@ (:name schema)]] [:td (prettify-dt (:created_at schema))]])]] - [:h1 "Pali sin e jaki ijo"] + [:h1 "New schema"] (hform/form-to [:post (path :schema-new)] (anti-forgery-field) (form/field new-form :schema-name req) - (hform/submit-button "Pali"))]))) + (hform/submit-button "Create"))]))) (defn show-schema! [schema attrs req] (view/layout! :session (:session req) :content - [[:h1 "Jaki ijo " + [[:h1 "Schema " [:span.schema-title__name (:name schema)]] (hform/form-to [:post "/schema/edit"]) - [:h2 "Lili wan e jaki ijo"] + [:h2 "Attributes"] [:ul (for [attr attrs] [:li (:name attr)])] - [:h3 "Pali lili wan"] + [:h3 "New attribute"] (hform/form-to [:post (path :attribute-new)] (anti-forgery-field) (hform/hidden-field "schema" (:uuid schema)) (form/field new-attr-form :name req) (form/drop-down new-attr-form :type req) (form/check-box new-attr-form :required req) - (hform/submit-button "Pali")) - [:h2 "Mute pali"] + (hform/submit-button "Save")) + [:h2 "Actions"] (hform/form-to {:class "inline"} [:delete (path :schema-delete schema)] (anti-forgery-field) - (hform/submit-button "Pakala!"))])) + (hform/submit-button "Delete!"))])) diff --git a/src/wanijo/user/view.clj b/src/wanijo/user/view.clj index 8b0fa88..0947dd1 100644 --- a/src/wanijo/user/view.clj +++ b/src/wanijo/user/view.clj @@ -21,7 +21,7 @@ (view/layout! :session (:session req) :content - [[:h1 "O, " (get-in req [:session :ident])] + [[:h1 "Hi, " (get-in req [:session :ident])] [:div (str user)] (hform/form-to [:post (path :user-edit)] (anti-forgery-field)