dropdown fixed.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout appearing-side-bar]]
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.views.components.dropdown :refer [drop-down drop-down-contents]]
|
||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog]
|
||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]
|
||||
[auto-ap.views.components.vendor-filter :refer [vendor-filter]]
|
||||
@@ -102,10 +103,7 @@
|
||||
(dissoc x id)
|
||||
(assoc x id invoice))))))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::print-checks-clicked
|
||||
(fn [db _]
|
||||
(update-in db [::invoice-page :print-checks-shown?] #(not %) )))
|
||||
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::advanced-print-checks
|
||||
@@ -757,53 +755,49 @@
|
||||
[:div.buttons
|
||||
[:button.button.is-success {:on-click (dispatch-event [::new-invoice-clicked])} "New Invoice"]
|
||||
(when current-client
|
||||
[:div.dropdown.is-right {:class (if print-checks-shown?
|
||||
"is-active"
|
||||
"")}
|
||||
[:div.dropdown-trigger
|
||||
[:button.button.is-success {:aria-haspopup true
|
||||
:on-click (dispatch-event [::print-checks-clicked ])
|
||||
:disabled (if (and (seq checked-invoices)
|
||||
(->> checked-invoices
|
||||
vals
|
||||
(group-by #(get-in % [:vendor :id]))
|
||||
(reduce-kv (fn [negative? _ invoices]
|
||||
(or negative? (< (reduce + 0 (map (fn [x] (-> x :outstanding-balance js/parseFloat)) invoices) ) 0)))
|
||||
false)
|
||||
not))
|
||||
""
|
||||
"disabled")
|
||||
[drop-down {:header [:button.button.is-success {:aria-haspopup true
|
||||
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
|
||||
:disabled (if (and (seq checked-invoices)
|
||||
(->> checked-invoices
|
||||
vals
|
||||
(group-by #(get-in % [:vendor :id]))
|
||||
(reduce-kv (fn [negative? _ invoices]
|
||||
(or negative? (< (reduce + 0 (map (fn [x] (-> x :outstanding-balance js/parseFloat)) invoices) ) 0)))
|
||||
false)
|
||||
not))
|
||||
""
|
||||
"disabled")
|
||||
|
||||
:class (if print-checks-loading?
|
||||
"is-loading"
|
||||
"")}
|
||||
"Pay "
|
||||
(when (> (count checked-invoices ))
|
||||
(str
|
||||
(count checked-invoices)
|
||||
" invoices "
|
||||
"(" (->> checked-invoices
|
||||
vals
|
||||
(map (comp js/parseFloat :outstanding-balance))
|
||||
(reduce + 0)
|
||||
(gstring/format "$%.2f" ))
|
||||
")"))
|
||||
[:span " "]
|
||||
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]]
|
||||
[:div.dropdown-menu {:role "menu"}
|
||||
[:div.dropdown-content
|
||||
(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])} "With cash"]
|
||||
(list
|
||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :check])} "Print checks from " name]
|
||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :debit])} "Debit from " name])))
|
||||
^{:key "advanced-divider"} [:hr.dropdown-divider]
|
||||
:class (if print-checks-loading?
|
||||
"is-loading"
|
||||
"")}
|
||||
"Pay "
|
||||
(when (> (count checked-invoices ))
|
||||
(str
|
||||
(count checked-invoices)
|
||||
" invoices "
|
||||
"(" (->> checked-invoices
|
||||
vals
|
||||
(map (comp js/parseFloat :outstanding-balance))
|
||||
(reduce + 0)
|
||||
(gstring/format "$%.2f" ))
|
||||
")"))
|
||||
[:span " "]
|
||||
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]
|
||||
:id ::print-checks}
|
||||
[: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])} "With cash"]
|
||||
(list
|
||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :check])} "Print checks from " name]
|
||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :debit])} "Debit from " name])))
|
||||
^{:key "advanced-divider"} [:hr.dropdown-divider]
|
||||
|
||||
(when (= 1 (count checked-invoices))
|
||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event [::handwrite-checks])} "Handwritten Check..."])
|
||||
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event [::advanced-print-checks])} "Advanced..."])]]])]]
|
||||
(when (= 1 (count checked-invoices))
|
||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event [::handwrite-checks])} "Handwritten Check..."])
|
||||
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event [::advanced-print-checks])} "Advanced..."])]])]]
|
||||
[:div.is-pulled-right
|
||||
(into [:div.tags {:style {:margin-right ".5 rem;"}}] (map (fn [[id invoice]] [:span.tag.is-medium (:invoice-number invoice) [:button.delete.is-small {:on-click (dispatch-event [::toggle-check id invoice])}]]) checked-invoices))]]
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user