makes it look like you can add a new invoice.
This commit is contained in:
@@ -125,8 +125,7 @@
|
||||
[action-modal {:title (str "Edit " (:name (:user editing)))
|
||||
:id ::edit-user
|
||||
:action-text "Save"
|
||||
:save-event [::save]
|
||||
:editing editing}
|
||||
:save-event [::save]}
|
||||
[horizontal-field
|
||||
[:label.label "Name"]
|
||||
[bind-field
|
||||
@@ -139,15 +138,16 @@
|
||||
[horizontal-field
|
||||
[:label.label "Role"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:select.select {:type "select"
|
||||
:field [:user :role]
|
||||
:spec ::entity/name
|
||||
:event ::change
|
||||
:subscription editing}
|
||||
[:option {:value "none"} "None"]
|
||||
[:option {:value "user"} "User"]
|
||||
[:option {:value "admin"} "Admin"]]]]]
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field [:user :role]
|
||||
:spec ::entity/name
|
||||
:event ::change
|
||||
:subscription editing}
|
||||
[:option {:value "none"} "None"]
|
||||
[:option {:value "user"} "User"]
|
||||
[:option {:value "admin"} "Admin"]]]]]]
|
||||
|
||||
|
||||
(when (= "user" (:role (:user editing)))
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field]]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field]]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.views.pages.check :as check]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[auto-ap.views.components.modal :refer [modal]]
|
||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]))
|
||||
|
||||
@@ -26,6 +25,11 @@
|
||||
(fn [db]
|
||||
(-> db ::check-results)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::new-invoice
|
||||
(fn [db]
|
||||
(-> db ::new-invoice)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::params
|
||||
(fn [db]
|
||||
@@ -176,7 +180,17 @@
|
||||
(fn [cofx [_ params]]
|
||||
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
|
||||
|
||||
(defn modal-dialog []
|
||||
(re-frame/reg-event-fx
|
||||
::new-invoice
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch [::events/modal-status ::new-invoice {:visible? true}]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::create-invoice
|
||||
(fn [{:keys [db]} _]
|
||||
{}))
|
||||
|
||||
(defn print-checks-modal []
|
||||
(let [{:keys [checked]} @(re-frame/subscribe [::invoice-page])
|
||||
{:keys [shown? invoices printing?] :as advanced-print-checks} @(re-frame/subscribe [::advanced-print-checks])
|
||||
current-company @(re-frame/subscribe [::subs/company])]
|
||||
@@ -224,6 +238,56 @@
|
||||
:max outstanding-balance
|
||||
:step "0.01"}]]]]]])]]])))
|
||||
|
||||
(defn new-invoice-modal []
|
||||
(let [data @(re-frame/subscribe [::new-invoice])
|
||||
change-event [::events/change-form [::new-invoice]]]
|
||||
[action-modal {:id ::new-invoice
|
||||
:title "New Invoice"
|
||||
:action-text "Create"
|
||||
:save-event [::create-invoice]}
|
||||
[horizontal-field
|
||||
[:label.label "Vendor"]
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field [:vendor]
|
||||
:event change-event
|
||||
:subscription data}]]]
|
||||
[horizontal-field
|
||||
[:label.label "Date"]
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field [:date]
|
||||
:event change-event
|
||||
:subscription data}]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Company"]
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field [:company]
|
||||
:event change-event
|
||||
:subscription data}]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Invoice #"]
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field [:invoice-number]
|
||||
:event change-event
|
||||
:subscription data}]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Total"]
|
||||
[:div.field.has-addons.is-extended
|
||||
[:p.control [:a.button.is-static "$"]]
|
||||
[:p.control
|
||||
[bind-field
|
||||
[:input.input {:type "number"
|
||||
:field [:total]
|
||||
:event change-event
|
||||
:subscription data
|
||||
:step "0.01"}]]]]]]))
|
||||
|
||||
(def unpaid-invoices-page
|
||||
(with-meta
|
||||
(fn []
|
||||
@@ -233,6 +297,7 @@
|
||||
[:div
|
||||
[:h1.title "Unpaid invoices"]
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
||||
(when current-company
|
||||
[:div.dropdown.is-right {:class (if print-checks-shown?
|
||||
"is-active"
|
||||
@@ -267,7 +332,8 @@
|
||||
:on-check-changed (fn [which]
|
||||
(re-frame/dispatch [::toggle-check which]))}]
|
||||
|
||||
[modal-dialog]
|
||||
[print-checks-modal]
|
||||
[new-invoice-modal]
|
||||
(when check-results-shown?
|
||||
[modal
|
||||
{:title "Your checks are ready!"
|
||||
|
||||
Reference in New Issue
Block a user