Quality of life improvements with client login
This commit is contained in:
@@ -37,7 +37,8 @@
|
||||
url-filters {:vendor (when-let [vendor-id (:vendor-id url-filters)]
|
||||
{:id (str vendor-id)
|
||||
:name (get-in vendors-by-id [(str vendor-id) :name] "Loading...")})
|
||||
:date-range (:date-range url-filters)
|
||||
:date-range {:raw (:date-range url-filters)
|
||||
:settled (:date-range url-filters)}
|
||||
:due-range (:due-range url-filters)
|
||||
:amount-range {:raw {:amount-gte (:amount-gte url-filters)
|
||||
:amount-lte (:amount-lte url-filters)}
|
||||
@@ -60,7 +61,7 @@
|
||||
|
||||
(fn [[filters ap ]]
|
||||
{:vendor-id (:id (:vendor filters))
|
||||
:date-range (:date-range filters)
|
||||
:date-range (:settled (:date-range filters))
|
||||
:due-range (:due-range filters)
|
||||
:amount-gte (:amount-gte (:settled (:amount-range filters)))
|
||||
:amount-lte (:amount-lte (:settled (:amount-range filters)))
|
||||
@@ -114,6 +115,25 @@
|
||||
:key ::amount-range}
|
||||
:db (assoc-in db [:raw which] value)}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::date-range-settled
|
||||
[(re-frame/path [::filters :date-range])]
|
||||
(fn [{:keys [db]} [_ which value]]
|
||||
{:db (assoc-in db [:settled which] value)
|
||||
:dispatch [::filter-changed :date-range [:settled] (assoc (:settled db) which value)]}))
|
||||
|
||||
;; TODO for some reason reloading is borken, and typing will unset stuff, has nothing to do with it being debounced
|
||||
(re-frame/reg-event-fx
|
||||
::date-range-changed
|
||||
[(re-frame/path [::filters :date-range])]
|
||||
(fn [{:keys [db]} [_ [which] value]]
|
||||
(println which value)
|
||||
{:dispatch-debounce
|
||||
{:event [::date-range-settled which value]
|
||||
:time 1000
|
||||
:key ::date-range}
|
||||
:db (assoc-in db [:raw which] value)}))
|
||||
|
||||
(defn invoice-number-filter []
|
||||
[:div.field
|
||||
[:div.control [:input.input {:placeholder "AP-123"
|
||||
@@ -171,8 +191,8 @@
|
||||
[:p.menu-label "Date Range"]
|
||||
[:div
|
||||
[date-range-filter
|
||||
{:on-change-event [::filter-changed :date-range]
|
||||
:value @(re-frame/subscribe [::filter :date-range])}]]
|
||||
{:on-change-event [::date-range-changed]
|
||||
:value (:raw @(re-frame/subscribe [::filter :date-range]))}]]
|
||||
|
||||
[:p.menu-label "Due Range"]
|
||||
[:div
|
||||
|
||||
@@ -90,71 +90,75 @@
|
||||
clients (re-frame/subscribe [::subs/clients])
|
||||
matching-clients @(re-frame/subscribe [::matching-clients])
|
||||
menu (re-frame/subscribe [::subs/menu])
|
||||
client-search @(re-frame/subscribe [::client-search])]
|
||||
client-search @(re-frame/subscribe [::client-search])
|
||||
is-initial-loading @(re-frame/subscribe [::subs/is-initial-loading?])]
|
||||
[:nav {:class "navbar has-shadow is-fixed-top"}
|
||||
[:div {:class "container"}
|
||||
[:div {:class "navbar-brand"}
|
||||
[:a {:class "navbar-item", :href "../"}
|
||||
[:img {:src "/img/logo.png"}]]]
|
||||
[:div.navbar-menu
|
||||
[:div.navbar-start
|
||||
[:a.navbar-item {:class [(active-when ap = :index)]
|
||||
:href (bidi/path-for routes/routes :index)}
|
||||
"Home" ]
|
||||
[:a.navbar-item {:class [(active-when ap #{:unpaid-invoices :paid-invoices})]
|
||||
:href (bidi/path-for routes/routes :unpaid-invoices)}
|
||||
"Invoices" ]
|
||||
[:a.navbar-item {:class [(active-when ap = :payments)]
|
||||
:href (bidi/path-for routes/routes :payments)}
|
||||
"Payments" ]
|
||||
[:a.navbar-item {:class [(active-when ap = :transactions)]
|
||||
:href (bidi/path-for routes/routes :transactions)}
|
||||
"Transactions" ]
|
||||
|
||||
(when (not= "manager" (:user/role @user))
|
||||
[:a.navbar-item {:class [(active-when ap = :ledger)]
|
||||
:href (bidi/path-for routes/routes :ledger)}
|
||||
"Ledger" ])]
|
||||
(when-not is-initial-loading
|
||||
[:div.navbar-start
|
||||
[:a.navbar-item {:class [(active-when ap = :index)]
|
||||
:href (bidi/path-for routes/routes :index)}
|
||||
"Home" ]
|
||||
[:a.navbar-item {:class [(active-when ap #{:unpaid-invoices :paid-invoices})]
|
||||
:href (bidi/path-for routes/routes :unpaid-invoices)}
|
||||
"Invoices" ]
|
||||
[:a.navbar-item {:class [(active-when ap = :payments)]
|
||||
:href (bidi/path-for routes/routes :payments)}
|
||||
"Payments" ]
|
||||
[:a.navbar-item {:class [(active-when ap = :transactions)]
|
||||
:href (bidi/path-for routes/routes :transactions)}
|
||||
"Transactions" ]
|
||||
|
||||
(when (not= "manager" (:user/role @user))
|
||||
[:a.navbar-item {:class [(active-when ap = :ledger)]
|
||||
:href (bidi/path-for routes/routes :ledger)}
|
||||
"Ledger" ])])
|
||||
[:div {:class "navbar-burger burger", :data-target "navMenu"}
|
||||
[:span]
|
||||
[:span]
|
||||
[:span]]
|
||||
[:div.navbar-end
|
||||
[:div.navbar-item
|
||||
[:a.button.is-primary.is-outlined
|
||||
{:on-click (dispatch-event [::vendor-dialog/started {}])}
|
||||
[:span.icon [:i.fa.fa-plus] ] [:span "Vendor"]]]
|
||||
|
||||
(when-not is-initial-loading
|
||||
[:div.navbar-end
|
||||
[:div.navbar-item
|
||||
[:a.button.is-primary.is-outlined
|
||||
{:on-click (dispatch-event [::vendor-dialog/started {}])}
|
||||
[:span.icon [:i.fa.fa-plus] ] [:span "Vendor"]]]
|
||||
|
||||
|
||||
(when (> (count @clients) 1)
|
||||
[navbar-drop-down {:header (str "Client: " (if @client (:name @client)
|
||||
"All"))
|
||||
:id ::select-client}
|
||||
[:div
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn []
|
||||
(re-frame/dispatch [::events/swap-client nil]))} "All" ]
|
||||
[:hr {:class "navbar-divider"}]
|
||||
[bind-field
|
||||
[:input.input.navbar-item {:placeholder "Client name"
|
||||
:auto-focus true
|
||||
:field [:value]
|
||||
:on-key-up (fn [k]
|
||||
(when (= 13 (.-which k))
|
||||
(do
|
||||
(re-frame/dispatch [::events/swap-client (first matching-clients)])
|
||||
(re-frame/dispatch [::events/toggle-menu ::select-client])
|
||||
(re-frame/dispatch [::client-search-changed [:value] nil])))
|
||||
)
|
||||
:event [::client-search-changed]
|
||||
:subscription client-search}]]
|
||||
(for [{:keys [name id] :as client} matching-clients]
|
||||
^{:key id }
|
||||
(when (> (count @clients) 1)
|
||||
[navbar-drop-down {:header (str "Client: " (if @client (:name @client)
|
||||
"All"))
|
||||
:id ::select-client}
|
||||
[:div
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn []
|
||||
(re-frame/dispatch [::events/swap-client client]))
|
||||
} name])]])]]
|
||||
[login-dropdown]]]))
|
||||
(re-frame/dispatch [::events/swap-client nil]))} "All" ]
|
||||
[:hr {:class "navbar-divider"}]
|
||||
[bind-field
|
||||
[:input.input.navbar-item {:placeholder "Client name"
|
||||
:auto-focus true
|
||||
:field [:value]
|
||||
:on-key-up (fn [k]
|
||||
(when (= 13 (.-which k))
|
||||
(do
|
||||
(re-frame/dispatch [::events/swap-client (first matching-clients)])
|
||||
(re-frame/dispatch [::events/toggle-menu ::select-client])
|
||||
(re-frame/dispatch [::client-search-changed [:value] nil])))
|
||||
)
|
||||
:event [::client-search-changed]
|
||||
:subscription client-search}]]
|
||||
(for [{:keys [name id] :as client} matching-clients]
|
||||
^{:key id }
|
||||
[:a {:class "navbar-item"
|
||||
:on-click (fn []
|
||||
(re-frame/dispatch [::events/swap-client client]))
|
||||
} name])]])])]
|
||||
(when-not is-initial-loading
|
||||
[login-dropdown])]]))
|
||||
|
||||
|
||||
(defn footer []
|
||||
@@ -170,7 +174,8 @@
|
||||
|
||||
(defn side-bar-layout [{:keys [side-bar main ap bottom right-side-bar]}]
|
||||
(let [ap @(re-frame/subscribe [::subs/active-page])
|
||||
client @(re-frame/subscribe [::subs/client])]
|
||||
client @(re-frame/subscribe [::subs/client])
|
||||
is-initial-loading @(re-frame/subscribe [::subs/is-initial-loading?])]
|
||||
[:div
|
||||
[navbar ap]
|
||||
[:div {:class "columns has-shadow", :style {:margin-bottom "0px" :height "calc(100vh - 46px)" } :id "mail-app" }
|
||||
@@ -190,7 +195,8 @@
|
||||
]
|
||||
#_[footer]
|
||||
[:div
|
||||
[vendor-dialog {}]
|
||||
(when-not is-initial-loading
|
||||
[vendor-dialog {}])
|
||||
bottom]
|
||||
[:div#dz-hidden]]))
|
||||
|
||||
@@ -198,3 +204,11 @@
|
||||
(defn side-bar [{:keys [on-close]} children]
|
||||
[:div [:a.delete.is-pulled-right {:on-click on-close}] [:div children]])
|
||||
|
||||
(defn loading-layout []
|
||||
[side-bar-layout
|
||||
{:main [:div.has-text-centered.hero.is-fullheight.is-vertically-centered.is-centered
|
||||
[:div.hero-body
|
||||
[:div.container
|
||||
[:div.column.is-4.is-offset-4.has-text-centered
|
||||
[:div.loader.is-loading.is-active.big.is-centered]]]]]}])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user