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}]
[:div.shrink {:x-data (hx/json {:value (:value params)
:tippy nil
:dp nil})
"@change-date.camel" "$dispatch('change')"
}
@@ -344,9 +345,14 @@
(update :class (fnil hh/add-class "") default-input-classes)
(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-init "$nextTick(() => tippy = $el.__x_tippy); ")
(assoc :type "text")
(assoc "autocomplete" "off")
(assoc "@change" "value = $event.target.value;")
(assoc "@keydown.escape" "tippy.hide(); " )
#_(assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\") "))
(update :class #(str % (use-size size) " w-full"))
(dissoc :size))]
@@ -365,7 +371,7 @@
(assoc "@htmx:before-history-save" "destroyDatepicker(dp)")
(assoc "@htmx:before-cleanup-element" "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"))
(dissoc :size :name :x-model :x-modelable))]]]])

View File

@@ -255,19 +255,22 @@
(if date-range-value
(-> (condp = date-range-value
"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
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"
(assoc m
start-date-key (time/plus (time/now) (time/months -1))
end-date-key nil)
(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))))]
(assoc m
start-date-key (time/first-day-of-the-month end-of-month)
end-date-key end-of-month))
"year"
(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)
"all"