Supports editing expense accounts

This commit is contained in:
Bryce Covert
2019-04-12 12:00:42 -07:00
parent bdb06d802b
commit e64820d71a
6 changed files with 119 additions and 53 deletions

View File

@@ -16,35 +16,36 @@
(-> db
(update :accounts replace-by :id edit-account))))
(defn accounts-table [{:keys [accounts]} ]
(defn accounts-table [{:keys [accounts]}]
[:div
(for [[account-set accounts] (group-by :account-set accounts)]
(do (println accounts)
^{:key account-set}
[:div
[:h2.title.is-4 account-set]
[:table.table.compact
[:thead
[:th "Code"]
[:th "Name"]
[:th "Type"]
[:th {:style {:width "5em"}}]
]
[:tbody
(for [{:keys [id numeric-code name type] :as account} (sort-by :numeric-code accounts)]
^{:key id}
[:tr
[:td numeric-code]
[:td name]
[:td type]
[:td [:a.button {:on-click (dispatch-event [::account-form/editing account])} [:span [:span.icon [:i.fa.fa-pencil]]]]]])]]]))])
^{:key (or account-set "blank")}
[:div
[:h2.title.is-4 account-set]
[:table.table.compact.is-fullwidth
[:thead
[:tr
[:th "Code"]
[:th "Name"]
[:th "Type"]
[:th {:style {:width "5em"}}]]]
[:tbody
(for [{:keys [id numeric-code name type] :as account} (sort-by :numeric-code accounts)]
^{:key id}
[:tr
[:td numeric-code]
[:td name]
[:td type]
[:td [:a.button {:on-click (dispatch-event [::account-form/editing account])} [:span [:span.icon [:i.fa.fa-pencil]]]]]])]]])])
(defn admin-accounts-content []
[:div
(let [accounts @(re-frame/subscribe [::subs/accounts])]
[:div
[:h1.title "Accounts"]
[:div.is-pulled-right
[:a.button.is-success {:on-click (dispatch-event [::account-form/editing {:type :asset
:account-set "default"}])} "New Account"]]
[accounts-table {:accounts accounts}]])])
(defn admin-accounts-page []