approach
This commit is contained in:
@@ -107,7 +107,6 @@
|
|||||||
[:> Consumer {}
|
[:> Consumer {}
|
||||||
(fn [consume]
|
(fn [consume]
|
||||||
(let [{:strs [on-params-change params] :as consume} (js->clj consume)]
|
(let [{:strs [on-params-change params] :as consume} (js->clj consume)]
|
||||||
(println "PARAMS" params)
|
|
||||||
(r/as-element (into
|
(r/as-element (into
|
||||||
[:div {:style {:margin-bottom "1rem"}}
|
[:div {:style {:margin-bottom "1rem"}}
|
||||||
[:div.level
|
[:div.level
|
||||||
@@ -139,7 +138,7 @@
|
|||||||
:class class}]
|
:class class}]
|
||||||
(r/children (r/current-component))))
|
(r/children (r/current-component))))
|
||||||
|
|
||||||
(defn row [{:keys [class id checkable?]}]
|
(defn row [{:keys [class id checkable? entity] }]
|
||||||
(let [children (r/children (r/current-component))]
|
(let [children (r/children (r/current-component))]
|
||||||
[:> Consumer {}
|
[:> Consumer {}
|
||||||
(fn [consume]
|
(fn [consume]
|
||||||
@@ -153,9 +152,15 @@
|
|||||||
"")
|
"")
|
||||||
:on-change (fn [x e]
|
:on-change (fn [x e]
|
||||||
(let [checked (or checked #{})]
|
(let [checked (or checked #{})]
|
||||||
(if (get checked id)
|
;; TODO only map once everything is moved over to data-page
|
||||||
(on-check-changed (disj checked id))
|
(if (map? checked)
|
||||||
(on-check-changed (conj checked id)))))}
|
(if (get checked id)
|
||||||
|
(on-check-changed (dissoc checked id))
|
||||||
|
(on-check-changed (assoc checked id entity)))
|
||||||
|
|
||||||
|
(if (get checked id)
|
||||||
|
(on-check-changed (disj checked id))
|
||||||
|
(on-check-changed (conj checked id))))))}
|
||||||
(boolean? checkable?) (assoc :disabled (not checkable?))) ]]))
|
(boolean? checkable?) (assoc :disabled (not checkable?))) ]]))
|
||||||
|
|
||||||
(map r/as-element children))))]))
|
(map r/as-element children))))]))
|
||||||
|
|||||||
@@ -95,7 +95,7 @@
|
|||||||
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor checkable?] :as i} invoice
|
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor checkable?] :as i} invoice
|
||||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
||||||
account->name #(:name (accounts-by-id (:id %)))]
|
account->name #(:name (accounts-by-id (:id %)))]
|
||||||
[grid/row {:class (:class i) :id id :checkable? checkable?}
|
[grid/row {:class (:class i) :id id :checkable? checkable? :entity invoice}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[grid/cell {}
|
[grid/cell {}
|
||||||
(if-let [client-override (:client overrides)]
|
(if-let [client-override (:client overrides)]
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::checked
|
::checked
|
||||||
(fn [db [_ id]]
|
(fn [db [_ id]]
|
||||||
(get-in db [::checked id] #{})))
|
(get-in db [::checked id] {})))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::toggle-check
|
::toggle-check
|
||||||
@@ -20,13 +20,17 @@
|
|||||||
(update-in db
|
(update-in db
|
||||||
[::checked id]
|
[::checked id]
|
||||||
(fn [checked]
|
(fn [checked]
|
||||||
(let [checked (or checked #{})]
|
(let [checked (or checked {})]
|
||||||
(disj checked to-remove))))))
|
(dissoc checked to-remove))))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::checked-set
|
||||||
|
(fn [db [_ id]]
|
||||||
|
(keys (get-in db [::checked id] {}))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::reset-checked
|
::reset-checked
|
||||||
(fn [db [_ id]]
|
(fn [db [_ id]]
|
||||||
|
|
||||||
(update db ::checked dissoc id)))
|
(update db ::checked dissoc id)))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
@@ -82,14 +86,16 @@
|
|||||||
[(re-frame/subscribe [::data id])
|
[(re-frame/subscribe [::data id])
|
||||||
(re-frame/subscribe [::status/single [::page id]])
|
(re-frame/subscribe [::status/single [::page id]])
|
||||||
(re-frame/subscribe [::checked id])
|
(re-frame/subscribe [::checked id])
|
||||||
|
(re-frame/subscribe [::checked-set id])
|
||||||
(re-frame/subscribe [::params id])
|
(re-frame/subscribe [::params id])
|
||||||
(re-frame/subscribe [::table-params id])
|
(re-frame/subscribe [::table-params id])
|
||||||
(re-frame/subscribe [::filters id])])
|
(re-frame/subscribe [::filters id])])
|
||||||
(fn [[data status checked params table-params filters] [_ id]]
|
(fn [[data status checked checked-set params table-params filters] [_ id]]
|
||||||
{:id id
|
{:id id
|
||||||
:data data
|
:data data
|
||||||
:status status
|
:status status
|
||||||
:checked checked
|
:checked checked
|
||||||
|
:checked-set checked-set
|
||||||
:params params
|
:params params
|
||||||
:filters filters
|
:filters filters
|
||||||
:table-params table-params}))
|
:table-params table-params}))
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
::invalidated
|
::invalidated
|
||||||
(fn [{:keys [db]} [_ params]]
|
(fn [{:keys [db]} [_ params]]
|
||||||
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
|
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
|
||||||
[::data-page/reset-checked :import-invoices]/]
|
[::data-page/reset-checked :import-invoices]]
|
||||||
:db (update db ::batch inc)}
|
:db (update db ::batch inc)}
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::received
|
::received
|
||||||
(fn [_ [_ data]]
|
(fn [_ [_ data]]
|
||||||
{:dispatch [::data-page/toggle-check :import-invoices (set (map :id data))]}))
|
{:dispatch [::data-page/toggle-check :import-invoices (by :id data)]}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::reject-invoices-clicked
|
::reject-invoices-clicked
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
[:div {:class "card-header"}
|
[:div {:class "card-header"}
|
||||||
[:span {:class "card-header-title"} "Found Invoices"]]
|
[:span {:class "card-header-title"} "Found Invoices"]]
|
||||||
[:div {:class "card-content"}
|
[:div {:class "card-content"}
|
||||||
[approve-reject-button (:checked page)]
|
[approve-reject-button (:checked-set page)]
|
||||||
(if (seq (:data (:data page)))
|
(if (seq (:data (:data page)))
|
||||||
[invoice-table {:id :approved
|
[invoice-table {:id :approved
|
||||||
:data-page :import-invoices
|
:data-page :import-invoices
|
||||||
|
|||||||
@@ -75,14 +75,6 @@
|
|||||||
[::checks-printed invoices pdf-url])}]}))
|
[::checks-printed invoices pdf-url])}]}))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
|
||||||
::checked-invoices
|
|
||||||
:<- [::data-page/data :invoices]
|
|
||||||
:<- [::data-page/checked :invoices]
|
|
||||||
(fn [[data checked]]
|
|
||||||
(filter (comp #(get checked %) :id) (:data data))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn print-checks-query [invoice-payments bank-account-id type client-id]
|
(defn print-checks-query [invoice-payments bank-account-id type client-id]
|
||||||
{:venia/operation {:operation/type :mutation
|
{:venia/operation {:operation/type :mutation
|
||||||
:operation/name "PrintChecks"}
|
:operation/name "PrintChecks"}
|
||||||
@@ -104,7 +96,7 @@
|
|||||||
:query-obj (print-checks-query (map (fn [{:keys [id outstanding-balance] }]
|
:query-obj (print-checks-query (map (fn [{:keys [id outstanding-balance] }]
|
||||||
{:invoice-id id
|
{:invoice-id id
|
||||||
:amount outstanding-balance})
|
:amount outstanding-balance})
|
||||||
@(re-frame/subscribe [::checked-invoices]))
|
(vals @(re-frame/subscribe [::data-page/checked :invoices])))
|
||||||
bank-account-id
|
bank-account-id
|
||||||
type
|
type
|
||||||
(:client db))
|
(:client db))
|
||||||
@@ -140,7 +132,7 @@
|
|||||||
|
|
||||||
(defn pay-button []
|
(defn pay-button []
|
||||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||||
checked-invoices @(re-frame/subscribe [::checked-invoices])]
|
checked-invoices (vals @(re-frame/subscribe [::data-page/checked :invoices]))]
|
||||||
[:div
|
[:div
|
||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
|
|||||||
Reference in New Issue
Block a user