makes it look like you can add a new invoice.
This commit is contained in:
@@ -66,12 +66,17 @@
|
|||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::swap-company
|
::swap-company
|
||||||
(fn [db [_ company]]
|
(fn [db [_ company]]
|
||||||
(println company)
|
|
||||||
(assoc db :company (:id company))))
|
(assoc db :company (:id company))))
|
||||||
|
|
||||||
|
(re-frame/reg-event-db
|
||||||
|
::change-form
|
||||||
|
(fn [db [_ location field value]]
|
||||||
|
(assoc-in db (into location field) value)))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::modal-status
|
::modal-status
|
||||||
(fn [db [_ id state]]
|
(fn [db [_ id state]]
|
||||||
|
(println "changing modal status" id "to")
|
||||||
(update-in db [:modal-state id] #(merge % state))))
|
(update-in db [:modal-state id] #(merge % state))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns auto-ap.views.components.modal
|
(ns auto-ap.views.components.modal
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
|
[reagent.core :as r]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.utils :refer [with-keys]]))
|
[auto-ap.views.utils :refer [with-keys]]))
|
||||||
@@ -13,8 +14,8 @@
|
|||||||
[:p.modal-card-title
|
[:p.modal-card-title
|
||||||
title]
|
title]
|
||||||
[:button.delete {:on-click (fn [] (re-frame/dispatch hide-event))}]]
|
[:button.delete {:on-click (fn [] (re-frame/dispatch hide-event))}]]
|
||||||
[:section.modal-card-body
|
(into [:section.modal-card-body]
|
||||||
(with-keys body)]
|
(r/children (r/current-component)))
|
||||||
|
|
||||||
(when foot
|
(when foot
|
||||||
[:footer.modal-card-foot
|
[:footer.modal-card-foot
|
||||||
@@ -23,16 +24,14 @@
|
|||||||
(defn action-modal [{:keys [title action-text id save-event]} & rest]
|
(defn action-modal [{:keys [title action-text id save-event]} & rest]
|
||||||
(let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])]
|
(let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])]
|
||||||
(when visible?
|
(when visible?
|
||||||
[modal {:title title
|
(-> [modal {:title title
|
||||||
:foot [:a.button.is-primary {:on-click (fn []
|
:foot [:a.button.is-primary {:on-click (fn []
|
||||||
(re-frame/dispatch [::events/modal-status id {:saving? true}])
|
(re-frame/dispatch [::events/modal-status id {:saving? true}])
|
||||||
(re-frame/dispatch save-event))
|
(re-frame/dispatch save-event))
|
||||||
:class (when saving?
|
:class (when saving?
|
||||||
"is-loading")}
|
"is-loading")}
|
||||||
[:span action-text]]
|
[:span action-text]]
|
||||||
:id id
|
:id id
|
||||||
:hide-event [::events/modal-status id {:visible? false}]}
|
:hide-event [::events/modal-status id {:visible? false}]}]
|
||||||
|
(into (r/children (r/current-component)) )
|
||||||
(with-keys rest)
|
(into [(when saving? [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])])))))
|
||||||
|
|
||||||
(when saving? [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])])))
|
|
||||||
|
|||||||
@@ -125,8 +125,7 @@
|
|||||||
[action-modal {:title (str "Edit " (:name (:user editing)))
|
[action-modal {:title (str "Edit " (:name (:user editing)))
|
||||||
:id ::edit-user
|
:id ::edit-user
|
||||||
:action-text "Save"
|
:action-text "Save"
|
||||||
:save-event [::save]
|
:save-event [::save]}
|
||||||
:editing editing}
|
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
[:label.label "Name"]
|
[:label.label "Name"]
|
||||||
[bind-field
|
[bind-field
|
||||||
@@ -139,15 +138,16 @@
|
|||||||
[horizontal-field
|
[horizontal-field
|
||||||
[:label.label "Role"]
|
[:label.label "Role"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[bind-field
|
[:div.select
|
||||||
[:select.select {:type "select"
|
[bind-field
|
||||||
:field [:user :role]
|
[:select {:type "select"
|
||||||
:spec ::entity/name
|
:field [:user :role]
|
||||||
:event ::change
|
:spec ::entity/name
|
||||||
:subscription editing}
|
:event ::change
|
||||||
[:option {:value "none"} "None"]
|
:subscription editing}
|
||||||
[:option {:value "user"} "User"]
|
[:option {:value "none"} "None"]
|
||||||
[:option {:value "admin"} "Admin"]]]]]
|
[:option {:value "user"} "User"]
|
||||||
|
[:option {:value "admin"} "Admin"]]]]]]
|
||||||
|
|
||||||
|
|
||||||
(when (= "user" (:role (:user editing)))
|
(when (= "user" (:role (:user editing)))
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[auto-ap.entities.companies :as company]
|
[auto-ap.entities.companies :as company]
|
||||||
[auto-ap.entities.vendors :as vendor]
|
[auto-ap.entities.vendors :as vendor]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field]]
|
||||||
[auto-ap.views.utils :refer [dispatch-event bind-field]]
|
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.views.pages.check :as check]
|
[auto-ap.views.pages.check :as check]
|
||||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
[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.subs :as subs]
|
||||||
[auto-ap.events :as events]))
|
[auto-ap.events :as events]))
|
||||||
|
|
||||||
@@ -26,6 +25,11 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db ::check-results)))
|
(-> db ::check-results)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::new-invoice
|
||||||
|
(fn [db]
|
||||||
|
(-> db ::new-invoice)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::params
|
::params
|
||||||
(fn [db]
|
(fn [db]
|
||||||
@@ -176,7 +180,17 @@
|
|||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params]]
|
||||||
{:dispatch [::params-change @(re-frame/subscribe [::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])
|
(let [{:keys [checked]} @(re-frame/subscribe [::invoice-page])
|
||||||
{:keys [shown? invoices printing?] :as advanced-print-checks} @(re-frame/subscribe [::advanced-print-checks])
|
{:keys [shown? invoices printing?] :as advanced-print-checks} @(re-frame/subscribe [::advanced-print-checks])
|
||||||
current-company @(re-frame/subscribe [::subs/company])]
|
current-company @(re-frame/subscribe [::subs/company])]
|
||||||
@@ -224,6 +238,56 @@
|
|||||||
:max outstanding-balance
|
:max outstanding-balance
|
||||||
:step "0.01"}]]]]]])]]])))
|
: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
|
(def unpaid-invoices-page
|
||||||
(with-meta
|
(with-meta
|
||||||
(fn []
|
(fn []
|
||||||
@@ -233,6 +297,7 @@
|
|||||||
[:div
|
[:div
|
||||||
[:h1.title "Unpaid invoices"]
|
[:h1.title "Unpaid invoices"]
|
||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
|
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
||||||
(when current-company
|
(when current-company
|
||||||
[:div.dropdown.is-right {:class (if print-checks-shown?
|
[:div.dropdown.is-right {:class (if print-checks-shown?
|
||||||
"is-active"
|
"is-active"
|
||||||
@@ -267,7 +332,8 @@
|
|||||||
:on-check-changed (fn [which]
|
:on-check-changed (fn [which]
|
||||||
(re-frame/dispatch [::toggle-check which]))}]
|
(re-frame/dispatch [::toggle-check which]))}]
|
||||||
|
|
||||||
[modal-dialog]
|
[print-checks-modal]
|
||||||
|
[new-invoice-modal]
|
||||||
(when check-results-shown?
|
(when check-results-shown?
|
||||||
[modal
|
[modal
|
||||||
{:title "Your checks are ready!"
|
{:title "Your checks are ready!"
|
||||||
|
|||||||
Reference in New Issue
Block a user