cleaned up how these are generated.

This commit is contained in:
2022-07-25 05:15:16 -07:00
parent bc07ad8f01
commit f6f73a6110
7 changed files with 122 additions and 117 deletions

View File

@@ -6,7 +6,8 @@
[re-frame.core :as re-frame]
[auto-ap.views.pages.data-page :as data-page]
[auto-ap.views.components.buttons :as buttons]
[auto-ap.subs :as subs]))
[auto-ap.subs :as subs]
[react-dom :as react-dom]))
(set! *warn-on-infer* true)
(defonce ^js/React.Context grid-context ( react/createContext "default"))
@@ -116,7 +117,7 @@
[:a.tag.is-medium.is-delete {:on-click (fn []
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
(defn controls [{:keys [start end count total per-page] :as para}]
(defn controls [{:keys [start end count total per-page action-buttons] :as para}]
(let [children (r/children (r/current-component))]
[:> Consumer {}
(fn [consume]
@@ -134,7 +135,8 @@
[sort-by-list {:sort (:sort params)
:on-change on-params-change}]]]
(mapv (fn [c]
[:div.level-item c]) children))]]))))]))
[:div.level-item c]) children))
[:div.level-right action-buttons]]]))))]))
(defn table [{:keys [fullwidth class style]}]

View File

@@ -237,7 +237,7 @@
:class (status/class-for (get unautopay-states (:id i)))
:event [::unautopay i]}])]]]))
(defn invoice-table [{:keys [check-boxes overrides actions data-page checkable-fn]}]
(defn invoice-table [{:keys [check-boxes overrides actions data-page checkable-fn action-buttons]}]
(let [{:keys [data status params table-params]} @(re-frame/subscribe [::data-page/page data-page])
selected-client @(re-frame/subscribe [::subs/client])
is-loading? (= :loading (:state status))
@@ -260,10 +260,11 @@
[grid/grid {:data-page data-page
:check-boxes? check-boxes
:column-count (if selected-client 8 9)}
[grid/controls data
[grid/controls {:action-buttons action-buttons}
[:div.level-item
"Outstanding " (nf (:outstanding data))
" Total " (nf (:total-amount data))]]
[:div.tags
[:div.tag.is-info.is-light "Outstanding " (nf (:outstanding data))]
[:div.tag.is-info.is-light " Total " (nf (:total-amount data))]]]]
(for [invoices invoice-groups]
^{:key (or (:id (first invoices)) "init")}
[grid/table {:fullwidth true}

View File

@@ -133,11 +133,8 @@
(defn action-buttons []
(let [checked-payments @(re-frame/subscribe [::data-page/checked ::page])]
[:div
[:div.is-pulled-right
[:div.buttons
[void-selected-button]]]
[:div.is-pulled-right {:style {:margin-right "0.5rem"}}
[:<>
[:div.level-item
(into [:div.tags ] (map (fn [[z {:keys [id check-number type amount]}]]
(if (= z "header")
[:span.tag.is-medium "All visible payments"
@@ -149,15 +146,18 @@
:else (gstring/format "Check #%d (%s)" check-number (nf amount )))
[:button.delete.is-small {:on-click
(dispatch-event [::data-page/remove-check ::page id])}]]))
checked-payments))]]))
checked-payments))]
[:div.level-item
[:div.buttons
[void-selected-button]]]]))
(defn content []
[:div
[:h1.title "Payments"]
[action-buttons]
[status/status-notification {:statuses [[::status/last-multi ::table/void]]}]
[table/table {:id :payments
:data-page ::page}]])
:data-page ::page
:action-buttons [action-buttons]}]])
(defn payments-page []
(reagent/create-class

View File

@@ -103,14 +103,14 @@
[buttons/sl-icon {:event [::void-check check] :icon :icon-bin-2
:class (status/class-for (get states (:id check)))}])]]]))
(defn table [{:keys [data-page]}]
(defn table [{:keys [data-page action-buttons]}]
(let [selected-client @(re-frame/subscribe [::subs/client])
{:keys [data params]} @(re-frame/subscribe [::data-page/page data-page])
states @(re-frame/subscribe [::status/multi ::void])]
[grid/grid {:data-page data-page
:check-boxes? true
:column-count (if selected-client 7 8)}
[grid/controls data]
[grid/controls {:action-buttons action-buttons} data]
[grid/table {:fullwidth true}
[grid/header {}
[grid/row {:id "header"

View File

@@ -129,27 +129,28 @@
(when (:sample-error result)
(str " Sample error: " (:info (:sample-error result)))))])}]}))
(defn content []
(defn action-buttons []
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])
params @(re-frame/subscribe [::data-page/params ::page])
checked @(re-frame/subscribe [::data-page/checked ::page])]
[:div
[:h1.title "Transactions"]
[status/status-notification {:statuses [[::status/single ::delete-selected]
[::status/single ::manual-import]]}]
(when is-admin?
[:div.is-pulled-right
params @(re-frame/subscribe [::data-page/params ::page])
checked @(re-frame/subscribe [::data-page/checked ::page])]
(when is-admin?
[:<>
[:div.level-item
[:div.tags
(map (fn [[z {:keys [id]}]]
(if (= "header" z)
^{:key "header"}
[:span.tag.is-medium {:on-click
(dispatch-event [::data-page/remove-check ::page "header"])}
"All visible transactions"]
^{:key id}
[:span.tag.is-medium id
[:button.delete.is-small {:on-click
(dispatch-event [::data-page/remove-check ::page id])}]]))
checked)]]
[:div.level-item
[:div.buttons
(into [:div.tags ] (map (fn [[z {:keys [id]}]]
(if (= "header" z)
[:span.tag.is-medium {:on-click
(dispatch-event [::data-page/remove-check ::page "header"])}
"All visible transactions"]
[:span.tag.is-medium id
[:button.delete.is-small {:on-click
(dispatch-event [::data-page/remove-check ::page id])}]]))
checked))
[:button.button.is-outlined.is-primary {:on-click (dispatch-event [::manual/opening])}
"Manual Yodlee Import"]
(when (:client-id params)
@@ -161,10 +162,20 @@
"Delete"]
[:button.button.is-danger {:on-click (dispatch-event [::delete-selected-requested params true])
:disabled (not (seq checked))}
"Suppress"]]])
"Suppress"]]]])))
(defn content []
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])]
[:div
[:h1.title "Transactions"]
[status/status-notification {:statuses [[::status/single ::delete-selected]
[::status/single ::manual-import]]}]
[table/table {:id :transactions
:check-boxes? is-admin?
:data-page ::page}]]))
:data-page ::page
:action-buttons [action-buttons]}]]))
(defn transactions-page [{:keys [approval-status]}]

View File

@@ -74,14 +74,15 @@
(fn [{table-params :db} [_ params :as z]]
{:db (merge table-params params)}))
(defn table [{:keys [data-page check-boxes?]}]
(defn table [{:keys [data-page check-boxes? action-buttons]}]
(let [selected-client @(re-frame/subscribe [::subs/client])
{:keys [data params]} @(re-frame/subscribe [::data-page/page data-page])
states @(re-frame/subscribe [::status/multi ::edits])]
[grid/grid {:data-page data-page
:column-count (if selected-client 6 7)
:check-boxes? check-boxes?}
[grid/controls data]
[grid/controls {:action-buttons action-buttons}
data]
[grid/table {:fullwidth true}
[grid/header {}
[grid/row {:id "header"

View File

@@ -30,7 +30,8 @@
[re-frame.core :as re-frame]
[reagent.core :as r]
[vimsical.re-frame.fx.track :as track]
[vimsical.re-frame.cofx.inject :as inject]))
[vimsical.re-frame.cofx.inject :as inject]
[react-dom :as react-dom]))
(re-frame/reg-event-fx
::params-change
@@ -212,94 +213,83 @@
(let [current-client @(re-frame/subscribe [::subs/client])
checked-invoices @(re-frame/subscribe [::data-page/checked :invoices])
print-checks-status @(re-frame/subscribe [::status/single ::print-checks])]
[:div
[:div.is-pulled-right
[:div.buttons
[void-selected-button]
[buttons/new-button {:event [::new-invoice-clicked]
:name "Invoice"
:class "is-primary"}]
(when current-client
(let [balance (->> checked-invoices
vals
(map (comp js/parseFloat :outstanding-balance))
(reduce + 0)
)]
[drop-down {:header [:button.button.is-primary {:aria-haspopup true
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
:disabled (or (status/disabled-for print-checks-status) (not (seq checked-invoices)))
:class (status/class-for @(re-frame/subscribe [::status/single ::print-checks]))}
"Pay "
(when (> (count checked-invoices ) 0)
(str
(count checked-invoices)
" invoices "
"(" (gstring/format "$%.2f" balance ) ")"))
[:span " "]
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:id ::print-checks
:is-right? true}
[:div
(list
(for [{:keys [id number name type]} (->> (:bank-accounts current-client) (filter :visible) (sort-by :sort-order))]
(if (= :cash type)
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])
:disabled (status/disabled-for print-checks-status)} "With cash"]
(if (> balance 0.001)
(list
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :check])
:disabled (status/disabled-for print-checks-status)} "Print checks from " name]
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :debit])
:disabled (status/disabled-for print-checks-status)} "Debit from " name])
(list
^{:key (str id "-credit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :credit])
:disabled (status/disabled-for print-checks-status)} "Credit from " name]
))))
[:div.buttons
[void-selected-button]
[buttons/new-button {:event [::new-invoice-clicked]
:name "Invoice"
:class "is-primary"}]
(when current-client
(let [balance (->> checked-invoices
vals
(map (comp js/parseFloat :outstanding-balance))
(reduce + 0)
)]
[drop-down {:header [:button.button.is-primary {:aria-haspopup true
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
:disabled (or (status/disabled-for print-checks-status) (not (seq checked-invoices)))
:class (status/class-for @(re-frame/subscribe [::status/single ::print-checks]))}
"Pay "
(when (> (count checked-invoices ) 0)
(str
(count checked-invoices)
" invoices "
"(" (gstring/format "$%.2f" balance ) ")"))
[:span " "]
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
:id ::print-checks
:is-right? true}
[:div
(list
(for [{:keys [id number name type]} (->> (:bank-accounts current-client) (filter :visible) (sort-by :sort-order))]
(if (= :cash type)
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])
:disabled (status/disabled-for print-checks-status)} "With cash"]
(if (> balance 0.001)
(list
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :check])
:disabled (status/disabled-for print-checks-status)} "Print checks from " name]
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :debit])
:disabled (status/disabled-for print-checks-status)} "Debit from " name])
(list
^{:key (str id "-credit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::print-checks id :credit])
:disabled (status/disabled-for print-checks-status)} "Credit from " name]
))))
^{:key "advanced-divider"} [:hr.dropdown-divider]
^{:key "advanced-divider"} [:hr.dropdown-divider]
(when (and (> (count checked-invoices) 1)
(= 1 (count (set (map (comp :id :vendor) (vals checked-invoices)))))
(< balance 0.001))
^{:key (str "balance-credit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::pay-invoices-from-balance])
:disabled (status/disabled-for print-checks-status)} "Pay invoices using balance "])
(when (and (> (count checked-invoices) 1)
(= 1 (count (set (map (comp :id :vendor) (vals checked-invoices)))))
(< balance 0.001))
^{:key (str "balance-credit")} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::pay-invoices-from-balance])
:disabled (status/disabled-for print-checks-status)} "Pay invoices using balance "])
(when (and (= 1 (count (set (map (comp :id :vendor) (vals checked-invoices)))))
(> balance 0.001))
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::handwritten-checks/show (vals checked-invoices)])
:disabled (status/disabled-for print-checks-status)} "Handwritten Check..."])
(when (> balance 0.001)
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::advanced-print-checks/show (vals checked-invoices)])
:disabled (status/disabled-for print-checks-status)} "Advanced..."]))]]))]]
[:div.is-pulled-right {:style {:margin-right "0.5rem"}}
(into [:div.tags ] (map (fn [[z {:keys [id invoice-number]}]]
(if (= z "header")
[:span.tag.is-medium "All visible invoices"
[:button.delete.is-small {:on-click
(dispatch-event [::data-page/remove-check :invoices z])}]]
[:span.tag.is-medium invoice-number
[:button.delete.is-small {:on-click
(dispatch-event [::data-page/remove-check :invoices id])}]]))
checked-invoices))]]))
(when (and (= 1 (count (set (map (comp :id :vendor) (vals checked-invoices)))))
(> balance 0.001))
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::handwritten-checks/show (vals checked-invoices)])
:disabled (status/disabled-for print-checks-status)} "Handwritten Check..."])
(when (> balance 0.001)
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event-with-propagation [::advanced-print-checks/show (vals checked-invoices)])
:disabled (status/disabled-for print-checks-status)} "Advanced..."]))]]))]))
(defn unpaid-invoices-content [{:keys [status]}]
(let [page @(re-frame/subscribe [::data-page/page :invoices])
(let [page @(re-frame/subscribe [::data-page/page :invoices])
current-client @(re-frame/subscribe [::subs/client])]
[:div
[:h1.title (str (str/capitalize (name (or status :all))) " invoices")]
[status/status-notification {:statuses [[::status/single ::print-checks]
[::status/last-multi ::table/void]
[::status/last-multi ::table/unvoid]]}]
(when (= status :unpaid)
[pay-button])
[table/invoice-table {:id (:id page)
:data-page :invoices
:check-boxes (= status :unpaid)
:checkable-fn (fn [i] (not (:scheduled-payment i)))
:actions #{:edit :void :expense-accounts}}]]))
[table/invoice-table {:id (:id page)
:data-page :invoices
:check-boxes (= status :unpaid)
:checkable-fn (fn [i] (not (:scheduled-payment i)))
:actions #{:edit :void :expense-accounts}
:action-buttons (when (= status :unpaid)
[pay-button])}]]))
(defn layout [params]
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]