Makes tooltip, also makes date ranges work the way Ben asked for

This commit is contained in:
2024-12-12 08:20:57 -08:00
parent aaeafae871
commit ef7c127cd5
2 changed files with 16 additions and 7 deletions

View File

@@ -336,6 +336,7 @@
(defn date-input- [{:keys [size] :as params}] (defn date-input- [{:keys [size] :as params}]
[:div.shrink {:x-data (hx/json {:value (:value params) [:div.shrink {:x-data (hx/json {:value (:value params)
:tippy nil
:dp nil}) :dp nil})
"@change-date.camel" "$dispatch('change')" "@change-date.camel" "$dispatch('change')"
} }
@@ -344,9 +345,14 @@
(update :class (fnil hh/add-class "") default-input-classes) (update :class (fnil hh/add-class "") default-input-classes)
(assoc :x-model "value") (assoc :x-model "value")
(assoc "x-tooltip.on.focus" "{content: ()=>$refs.tooltip.innerHTML, theme: 'light', onMount(i) { htmx.process(i.popper); }, allowHTML: true, interactive:true}") (assoc "x-tooltip.on.focus" "{content: ()=>$refs.tooltip.innerHTML, theme: 'light', onMount(i) { htmx.process(i.popper); }, allowHTML: true, interactive:true}")
(assoc :x-init "$nextTick(() => tippy = $el.__x_tippy); ")
(assoc :type "text") (assoc :type "text")
(assoc "autocomplete" "off") (assoc "autocomplete" "off")
(assoc "@change" "value = $event.target.value;") (assoc "@change" "value = $event.target.value;")
(assoc "@keydown.escape" "tippy.hide(); " )
#_(assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\") ")) #_(assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\") "))
(update :class #(str % (use-size size) " w-full")) (update :class #(str % (use-size size) " w-full"))
(dissoc :size))] (dissoc :size))]
@@ -365,7 +371,7 @@
(assoc "@htmx:before-history-save" "destroyDatepicker(dp)") (assoc "@htmx:before-history-save" "destroyDatepicker(dp)")
(assoc "@htmx:before-cleanup-element" "destroyDatepicker(dp)") (assoc "@htmx:before-cleanup-element" "destroyDatepicker(dp)")
(assoc "x-destroy" "destroyDatepicker(dp)") (assoc "x-destroy" "destroyDatepicker(dp)")
(assoc "@change-date.camel" "value = dp.getDate(\"mm/dd/yyyy\"); ") (assoc "@change-date.camel" "value = dp.getDate(\"mm/dd/yyyy\");")
(update :class #(str % (use-size size) " w-full")) (update :class #(str % (use-size size) " w-full"))
(dissoc :size :name :x-model :x-modelable))]]]]) (dissoc :size :name :x-model :x-modelable))]]]])

View File

@@ -255,19 +255,22 @@
(if date-range-value (if date-range-value
(-> (condp = date-range-value (-> (condp = date-range-value
"week" "week"
(let [last-monday (coerce/to-date-time (atime/last-monday))] (let [last-monday (atime/as-local-time (coerce/to-date-time (atime/last-monday)))]
(assoc m (assoc m
start-date-key (time/plus last-monday (time/days -7)) start-date-key (time/plus last-monday (time/days -7))
end-date-key last-monday)) end-date-key (time/plus last-monday (time/days -1))))
"month" "month"
(assoc m (let [end-of-month (atime/as-local-time (coerce/to-date-time (time/plus (time/first-day-of-the-month (atime/local-today)) (time/days -1))))]
start-date-key (time/plus (time/now) (time/months -1)) (assoc m
end-date-key nil) start-date-key (time/first-day-of-the-month end-of-month)
end-date-key end-of-month))
"year" "year"
(assoc m (assoc m
start-date-key (time/plus (time/now) (time/years -1)) start-date-key (atime/as-local-time (time/date-time (time/year (atime/local-today))
1
1))
end-date-key nil) end-date-key nil)
"all" "all"