first step in making accounts editable.
This commit is contained in:
66
src/cljs/auto_ap/views/pages/admin/accounts/form.cljs
Normal file
66
src/cljs/auto_ap/views/pages/admin/accounts/form.cljs
Normal file
@@ -0,0 +1,66 @@
|
||||
(ns auto-ap.views.pages.admin.accounts.form
|
||||
(:require [auto-ap.forms :as forms]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||
[auto-ap.views.utils :refer [bind-field dispatch-event]]
|
||||
[auto-ap.views.components.layouts
|
||||
:refer
|
||||
[appearing-side-bar side-bar-layout]]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(def types [:dividend :expense :asset :liability :equities :revenue])
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(-> db
|
||||
(forms/start-form ::form which))))
|
||||
|
||||
(defn form []
|
||||
(let [{error :error account :data } @(re-frame/subscribe [::forms/form ::form])
|
||||
change-event [::forms/change ::form]]
|
||||
|
||||
[forms/side-bar-form {:form ::form}
|
||||
[:form
|
||||
[:h1.title.is-2 "Add/edit account"]
|
||||
[:div.field
|
||||
[:p.help "Code"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :numeric-code
|
||||
#_:spec #_:entity/name
|
||||
:event change-event
|
||||
:subscription account}]]]]
|
||||
|
||||
[:div.field
|
||||
[:p.help "Name"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :name
|
||||
#_:spec #_:entity/name
|
||||
:event change-event
|
||||
:subscription account}]]]]
|
||||
|
||||
[:div.field
|
||||
[:p.help "Location"]
|
||||
[:div.control
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field :type
|
||||
:spec (set types)
|
||||
:event change-event
|
||||
:subscription account}
|
||||
(map (fn [l] [:option {:value l} (name l)]) types)]]]]]
|
||||
|
||||
(when error
|
||||
[:div.notification.is-warning.animated.fadeInUp
|
||||
error])
|
||||
|
||||
|
||||
[:submit.button.is-large.is-primary {#_:disabled #_(if (s/valid? :entity/client @(re-frame/subscribe [::new-client-request]))
|
||||
""
|
||||
"disabled")
|
||||
:on-click (dispatch-event [::account-saving])
|
||||
:class (str @(re-frame/subscribe [::forms/loading-class ::form]) (when error " animated shake"))} "Save"]]]))
|
||||
Reference in New Issue
Block a user