admins copy IDs
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
(ns auto-ap.views.components.grid
|
(ns auto-ap.views.components.grid
|
||||||
(:require [reagent.core :as r]
|
(:require [reagent.core :as r]
|
||||||
[auto-ap.views.utils :refer [appearing]]
|
[auto-ap.views.utils :refer [appearing copy-to-clipboard]]
|
||||||
[auto-ap.utils :refer [default-pagination-size]]
|
[auto-ap.utils :refer [default-pagination-size]]
|
||||||
[react :as react]
|
[react :as react]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[auto-ap.views.pages.data-page :as data-page]))
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
|
[auto-ap.subs :as subs]))
|
||||||
|
|
||||||
(defonce grid-context (react/createContext "default"))
|
(defonce grid-context (react/createContext "default"))
|
||||||
(def Provider (.-Provider grid-context))
|
(def Provider (.-Provider grid-context))
|
||||||
@@ -151,7 +153,10 @@
|
|||||||
(r/children (r/current-component))))
|
(r/children (r/current-component))))
|
||||||
|
|
||||||
(defn row [{:keys [class id checkable? entity] }]
|
(defn row [{:keys [class id checkable? entity] }]
|
||||||
(let [children (r/children (r/current-component))]
|
(let [children (r/children (r/current-component))
|
||||||
|
is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||||
|
|
||||||
|
]
|
||||||
[:> Consumer {}
|
[:> Consumer {}
|
||||||
(fn [consume]
|
(fn [consume]
|
||||||
(let [on-check-changed (aget consume "on-check-changed")
|
(let [on-check-changed (aget consume "on-check-changed")
|
||||||
@@ -178,6 +183,15 @@
|
|||||||
(on-check-changed (conj checked id)))))))}
|
(on-check-changed (conj checked id)))))))}
|
||||||
(boolean? checkable?) (assoc :disabled (not checkable?))) ]]))
|
(boolean? checkable?) (assoc :disabled (not checkable?))) ]]))
|
||||||
|
|
||||||
|
(when is-admin?
|
||||||
|
(r/as-element
|
||||||
|
(cond
|
||||||
|
(not id) [:th {:style {:width "4em"}}]
|
||||||
|
id [:th {:style {:width "4em"}} [:button.button.is-link.is-light
|
||||||
|
{:on-click (fn []
|
||||||
|
(copy-to-clipboard id))}
|
||||||
|
[:span.icon [:i.fa.fa-files-o]]
|
||||||
|
]])))
|
||||||
(map r/as-element children))))]))
|
(map r/as-element children))))]))
|
||||||
|
|
||||||
(defn button-cell [params]
|
(defn button-cell [params]
|
||||||
@@ -190,12 +204,14 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
(defn body []
|
(defn body []
|
||||||
(let [children (r/children (r/current-component))]
|
(let [children (r/children (r/current-component))
|
||||||
|
is-admin? @(re-frame/subscribe [::subs/is-admin?])]
|
||||||
[:> Consumer {}
|
[:> Consumer {}
|
||||||
(fn [consume]
|
(fn [consume]
|
||||||
(let [{:strs [column-count status check-boxes?]} (js->clj consume)
|
(let [{:strs [column-count status check-boxes?]} (js->clj consume)
|
||||||
column-count (cond-> column-count
|
column-count (cond-> column-count
|
||||||
check-boxes? inc)]
|
check-boxes? inc
|
||||||
|
is-admin? inc)]
|
||||||
(r/as-element
|
(r/as-element
|
||||||
(cond (= :loading (:state status))
|
(cond (= :loading (:state status))
|
||||||
^{:key "loading-body"}
|
^{:key "loading-body"}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [id numeric-code name type location class] :as account} (:data accounts)]
|
(for [{:keys [id numeric-code name type location class] :as account} (:data accounts)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[grid/row {:class (:class account)}
|
[grid/row {:class (:class account) :id id}
|
||||||
[grid/cell {} numeric-code]
|
[grid/cell {} numeric-code]
|
||||||
[grid/cell {} name]
|
[grid/cell {} name]
|
||||||
[grid/cell {} type]
|
[grid/cell {} type]
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [id name email code locations] :as c} (:data page)]
|
(for [{:keys [id name email code locations] :as c} (:data page)]
|
||||||
^{:key (str name "-" id )}
|
^{:key (str name "-" id )}
|
||||||
[grid/row
|
[grid/row {:id id}
|
||||||
[grid/cell {} name]
|
[grid/cell {} name]
|
||||||
[grid/cell {} code]
|
[grid/cell {} code]
|
||||||
[grid/cell {} (str/join ", " locations)]
|
[grid/cell {} (str/join ", " locations)]
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
:owns-state {:single [::data-page/page ::page]}
|
:owns-state {:single [::data-page/page ::page]}
|
||||||
:query-obj {:venia/queries [[:transaction_rule_page
|
:query-obj {:venia/queries [[:transaction_rule_page
|
||||||
{:sort (:sort params)
|
{:sort (:sort params)
|
||||||
:start (:start params)
|
:start (:start params 0)
|
||||||
:per-page (:per-page params)
|
:per-page (:per-page params)
|
||||||
:vendor-id (:id (:vendor params))
|
:vendor-id (:id (:vendor params))
|
||||||
:client-id (:id @(re-frame/subscribe [::subs/client]))}
|
:client-id (:id @(re-frame/subscribe [::subs/client]))}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [client bank-account description amount-lte amount-gte note id] :as r} (:data data)]
|
(for [{:keys [client bank-account description amount-lte amount-gte note id] :as r} (:data data)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[grid/row {:class (:class r)}
|
[grid/row {:class (:class r) :id id}
|
||||||
[grid/cell {} (:name client)]
|
[grid/cell {} (:name client)]
|
||||||
[grid/cell {} (:name bank-account)]
|
[grid/cell {} (:name bank-account)]
|
||||||
[grid/cell {} description]
|
[grid/cell {} description]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [id name role clients] :as c} (:data page)]
|
(for [{:keys [id name role clients] :as c} (:data page)]
|
||||||
^{:key (str name "-" id )}
|
^{:key (str name "-" id )}
|
||||||
[grid/row {:class (:class c)}
|
[grid/row {:class (:class c) :id id}
|
||||||
[grid/cell {} name]
|
[grid/cell {} name]
|
||||||
[grid/cell {} role]
|
[grid/cell {} role]
|
||||||
[grid/cell {} (str/join ", " (map :name clients))]
|
[grid/cell {} (str/join ", " (map :name clients))]
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
[grid/body
|
[grid/body
|
||||||
(for [v (:data page)]
|
(for [v (:data page)]
|
||||||
^{:key (str (:id v))}
|
^{:key (str (:id v))}
|
||||||
[grid/row {:class (:class v)}
|
[grid/row {:class (:class v) :id (:id v)}
|
||||||
[grid/cell {} (:name v)]
|
[grid/cell {} (:name v)]
|
||||||
[grid/cell {} (:email (:primary-contact v))]
|
[grid/cell {} (:email (:primary-contact v))]
|
||||||
[grid/cell {} (-> v :default-account :id accounts :name)]
|
[grid/cell {} (-> v :default-account :id accounts :name)]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
(defn ledger-row [{{:keys [client vendor status date amount id line-items] :as i} :row
|
(defn ledger-row [{{:keys [client vendor status date amount id line-items] :as i} :row
|
||||||
:keys [selected-client accounts-by-id bank-accounts-by-id]}]
|
:keys [selected-client accounts-by-id bank-accounts-by-id]}]
|
||||||
[:<>
|
[:<>
|
||||||
[grid/row {:class (:class i)}
|
[grid/row {:class (:class i) :id id}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[grid/cell {} (:name client)])
|
[grid/cell {} (:name client)])
|
||||||
[grid/cell {} (if vendor
|
[grid/cell {} (if vendor
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
states :states
|
states :states
|
||||||
}]
|
}]
|
||||||
(let [{:keys [client s3-url bank-account payments type check-number date amount id vendor status invoices] :as check} check]
|
(let [{:keys [client s3-url bank-account payments type check-number date amount id vendor status invoices] :as check} check]
|
||||||
[grid/row {:class (:class check)}
|
[grid/row {:class (:class check) :id id}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[grid/cell {} (:name client)])
|
[grid/cell {} (:name client)])
|
||||||
[grid/cell {} (:name vendor)]
|
[grid/cell {} (:name vendor)]
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
(defn row [{sales-order :sales-order
|
(defn row [{sales-order :sales-order
|
||||||
selected-client :selected-client}]
|
selected-client :selected-client}]
|
||||||
(let [{:keys [client date total tax tip charges line-items]} sales-order]
|
(let [{:keys [client date total tax tip charges line-items id]} sales-order]
|
||||||
[grid/row {:class (:class sales-order)}
|
[grid/row {:class (:class sales-order) :id id}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[grid/cell {} (:name client)])
|
[grid/cell {} (:name client)])
|
||||||
[grid/cell {} (date->str date) ]
|
[grid/cell {} (date->str date) ]
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [client account vendor approval-status payment status bank-account description-original date amount id yodlee-merchant ] :as i} (:data data)]
|
(for [{:keys [client account vendor approval-status payment status bank-account description-original date amount id yodlee-merchant ] :as i} (:data data)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[grid/row {:class (:class i)}
|
[grid/row {:class (:class i) :id id}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[grid/cell {} (:name client)])
|
[grid/cell {} (:name client)])
|
||||||
|
|
||||||
|
|||||||
@@ -464,3 +464,12 @@
|
|||||||
(- (t/in-days (t/interval (t/minus d (t/days 1)) today)))
|
(- (t/in-days (t/interval (t/minus d (t/days 1)) today)))
|
||||||
(t/in-days (t/interval today d )))]
|
(t/in-days (t/interval today d )))]
|
||||||
in))
|
in))
|
||||||
|
|
||||||
|
(defn copy-to-clipboard [text]
|
||||||
|
(let [el (js/document.createElement "textarea")]
|
||||||
|
|
||||||
|
(set! (.-value el) text)
|
||||||
|
(.appendChild js/document.body el)
|
||||||
|
(.select el)
|
||||||
|
(js/document.execCommand "copy")
|
||||||
|
(.removeChild js/document.body el)))
|
||||||
|
|||||||
Reference in New Issue
Block a user