Fixing minor bugs.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
[goog.string :as gstring]
|
||||
[auto-ap.utils :refer [dollars-0? by ]]
|
||||
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
|
||||
[auto-ap.views.utils :refer [date->str date-picker bind-field standard pretty dispatch-event local-now ->% ->$ str->date with-user]]
|
||||
[auto-ap.views.utils :refer [date->str date-picker bind-field standard pretty dispatch-event local-today ->% ->$ str->date with-user]]
|
||||
[cljs-time.core :as t]
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.status :as status]))
|
||||
@@ -199,6 +199,7 @@
|
||||
(re-frame/reg-event-fx
|
||||
::date-picked
|
||||
(fn [cofx [_ [_ period which] date]]
|
||||
(println date (str->date date standard))
|
||||
{:dispatch [::range-selected (assoc-in @(re-frame/subscribe [::periods]) [period which] (str->date date standard)) nil]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
@@ -493,8 +494,8 @@
|
||||
{:class (when (= (:selected params) "13 periods") "is-active")
|
||||
:on-click (dispatch-event
|
||||
[::range-selected
|
||||
(let [this-month (t/local-date (t/year (local-now))
|
||||
(t/month (local-now))
|
||||
(let [this-month (t/local-date (t/year (local-today))
|
||||
(t/month (local-today))
|
||||
1)]
|
||||
(into
|
||||
[[this-month (t/minus (t/plus this-month (t/months 1)) (t/days 1))]]
|
||||
@@ -509,7 +510,7 @@
|
||||
[:a.button
|
||||
{:class (when (= (:selected params) "Last week") "is-active")
|
||||
:on-click (dispatch-event
|
||||
(let [last-sunday (loop [current (local-now)]
|
||||
(let [last-sunday (loop [current (local-today)]
|
||||
(if (= 7 (t/day-of-week current))
|
||||
current
|
||||
(recur (t/minus current (t/period :days 1)))))]
|
||||
@@ -521,23 +522,23 @@
|
||||
[:a.button
|
||||
{:class (when (= (:selected params) "Week to date") "is-active")
|
||||
:on-click (dispatch-event [::range-selected
|
||||
(and-last-year [(loop [current (local-now)]
|
||||
(and-last-year [(loop [current (local-today)]
|
||||
(if (= 1 (t/day-of-week current))
|
||||
current
|
||||
(recur (t/minus current (t/period :days 1)))))
|
||||
(local-now)])
|
||||
(local-today)])
|
||||
"Week to date"])}
|
||||
"Week to date"]]
|
||||
[:div.control
|
||||
[:a.button
|
||||
{:class (when (= (:selected params) "Last Month") "is-active")
|
||||
:on-click (dispatch-event [::range-selected
|
||||
(and-last-year [(t/minus (t/local-date (t/year (local-now))
|
||||
(t/month (local-now))
|
||||
(and-last-year [(t/minus (t/local-date (t/year (local-today))
|
||||
(t/month (local-today))
|
||||
1)
|
||||
(t/period :months 1))
|
||||
(t/minus (t/local-date (t/year (local-now))
|
||||
(t/month (local-now))
|
||||
(t/minus (t/local-date (t/year (local-today))
|
||||
(t/month (local-today))
|
||||
1)
|
||||
(t/period :days 1))])
|
||||
"Last Month"])}
|
||||
@@ -546,27 +547,27 @@
|
||||
[:a.button
|
||||
{:class (when (= (:selected params) "Month to date") "is-active")
|
||||
:on-click (dispatch-event [::range-selected
|
||||
(and-last-year [(t/local-date (t/year (local-now))
|
||||
(t/month (local-now))
|
||||
(and-last-year [(t/local-date (t/year (local-today))
|
||||
(t/month (local-today))
|
||||
1)
|
||||
(local-now)])
|
||||
(local-today)])
|
||||
"Month to date"])}
|
||||
"Month to date"]]
|
||||
[:div.control
|
||||
[:a.button
|
||||
{:class (when (= (:selected params) "Year to date") "is-active")
|
||||
:on-click (dispatch-event [::range-selected
|
||||
(and-last-year [(t/local-date (t/year (local-now)) 1 1)
|
||||
(local-now)])
|
||||
(and-last-year [(t/local-date (t/year (local-today)) 1 1)
|
||||
(local-today)])
|
||||
"Year to date"])}
|
||||
"Year to date"]]
|
||||
[:div.control
|
||||
[:a.button
|
||||
{:class (when (= (:selected params) "Full year") "is-active")
|
||||
:on-click (dispatch-event [::range-selected
|
||||
(and-last-year [(t/plus (t/minus (local-now) (t/period :years 1))
|
||||
(and-last-year [(t/plus (t/minus (local-today) (t/period :years 1))
|
||||
(t/period :days 1))
|
||||
(local-now)])
|
||||
(local-today)])
|
||||
"Full year"])}
|
||||
"Full year"]]]]
|
||||
(for [[_ i] (map vector periods (range))]
|
||||
@@ -635,7 +636,7 @@
|
||||
^{:key location}
|
||||
[location-rows location]
|
||||
)]]]])])))
|
||||
{:component-will-mount #(do (re-frame/dispatch-sync [::range-selected (and-last-year [(t/minus (local-now) (t/period :years 1)) (local-now)]) nil])) }))
|
||||
{:component-will-mount #(do (re-frame/dispatch-sync [::range-selected (and-last-year [(t/minus (local-today) (t/period :years 1)) (local-today)]) nil])) }))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user