Most grid pages auto-submitted their date-range filter on every change event, which fired mid-typing and re-rendered the date inputs, breaking manual date entry. Invoices and ledgers already gated date submission behind an explicit Apply button; this brings the other ten pages in line. - date-range component: stop `change` from the date inputs bubbling to the form (@change.stop) and always render the Apply button, so typed or picked dates submit only via the Apply button's `datesApplied` event. The All/Week/Month/Year presets and all other filters are unaffected. - payments, invoice import, transactions, import batches, sales summaries, expected deposits, cash drawer shifts, refunds, tenders, sales orders: add `datesApplied` to the form hx-trigger. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
39 lines
2.1 KiB
Clojure
39 lines
2.1 KiB
Clojure
(ns auto-ap.ssr.components.date-range
|
|
(:require [auto-ap.ssr.components :as com]
|
|
[auto-ap.ssr.components.buttons :as but]
|
|
[auto-ap.ssr.svg :as svg]
|
|
[auto-ap.time :as atime]
|
|
[clj-time.coerce :as c]
|
|
[clj-time.core :as t]
|
|
[clj-time.periodic :as per]))
|
|
|
|
(defn date-range-field [{:keys [value id]}]
|
|
[:div {:id id}
|
|
(com/field {:label "Date Range"}
|
|
[:div.space-y-4
|
|
[:div
|
|
(com/button-group {:name "date-range"}
|
|
(com/button-group-button {:size :small :value "all" :hx-trigger "click"} "All")
|
|
(com/button-group-button {:size :small :value "week" :hx-trigger "click"} "Week")
|
|
(com/button-group-button {:size :small :value "month" :hx-trigger "click"} "Month")
|
|
(com/button-group-button {:size :small :value "year" :hx-trigger "click"} "Year"))]
|
|
[:div.flex.space-x-1.items-baseline.w-full.justify-start {"@change.stop" ""}
|
|
(com/date-input {:name "start-date"
|
|
:value (some-> (:start value)
|
|
(atime/unparse-local atime/normal-date))
|
|
:placeholder "Date"
|
|
:size :small
|
|
:class "shrink date-filter-input"})
|
|
|
|
(com/date-input {:name "end-date"
|
|
:value (some-> (:end value)
|
|
(atime/unparse-local atime/normal-date))
|
|
:placeholder "Date"
|
|
:size :small
|
|
:class "shrink date-filter-input"})
|
|
(but/button- {:color :secondary
|
|
:size :small
|
|
:type "button"
|
|
"x-on:click" "$dispatch('datesApplied')"}
|
|
"Apply")]])])
|