Maybe using new datepicker
This commit is contained in:
@@ -16,3 +16,7 @@ htmx.defineExtension('disable-submit', {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
initDatepicker = function(elem) {
|
||||||
|
elem.dp = new Datepicker(elem, {format: "mm/dd/yyyy", autohide: true});
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
(ns auto-ap.ssr.components.inputs)
|
(ns auto-ap.ssr.components.inputs
|
||||||
|
(:require [hiccup2.core :as hiccup]))
|
||||||
|
|
||||||
(defn select- [params & children]
|
(defn select- [params & children]
|
||||||
(into
|
(into
|
||||||
@@ -37,13 +38,17 @@
|
|||||||
])
|
])
|
||||||
|
|
||||||
(defn date-input- [{:keys [size] :as params}]
|
(defn date-input- [{:keys [size] :as params}]
|
||||||
[:input
|
[:div
|
||||||
(-> params
|
[:input
|
||||||
(update
|
(-> params
|
||||||
:class str " bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500")
|
(update
|
||||||
(assoc :type "date")
|
:class str " bg-gray-50 border border-gray-300 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500")
|
||||||
(update :class #(str % (use-size size)))
|
(assoc :type "text")
|
||||||
(dissoc :size))])
|
(assoc "_" (hiccup/raw "init initDatepicker(me)"))
|
||||||
|
(assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\")
|
||||||
|
htmx:beforeCleanupElement: this.dp.destroy()"))
|
||||||
|
(update :class #(str % (use-size size)))
|
||||||
|
(dissoc :size))]])
|
||||||
|
|
||||||
(defn field- [params & rest]
|
(defn field- [params & rest]
|
||||||
(into
|
(into
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
[cemerick.url :as url]
|
[cemerick.url :as url]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[auto-ap.ssr.svg :as svg]
|
[auto-ap.ssr.svg :as svg]
|
||||||
[unilog.context :as lc]
|
|
||||||
[com.brunobonacci.mulog :as mu]
|
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[clj-time.core :as time]))
|
[clj-time.core :as time]))
|
||||||
|
|
||||||
@@ -181,23 +179,23 @@
|
|||||||
(condp = date-range
|
(condp = date-range
|
||||||
"week"
|
"week"
|
||||||
(assoc query-params
|
(assoc query-params
|
||||||
:start-date (atime/unparse-local (time/plus (time/now) (time/days -7)) atime/iso-date)
|
:start-date (atime/unparse-local (time/plus (time/now) (time/days -7)) atime/normal-date)
|
||||||
:end-date (atime/unparse-local (time/now) atime/iso-date))
|
:end-date (atime/unparse-local (time/now) atime/normal-date))
|
||||||
|
|
||||||
"month"
|
"month"
|
||||||
(assoc query-params
|
(assoc query-params
|
||||||
:start-date (atime/unparse-local (time/plus (time/now) (time/months -1)) atime/iso-date)
|
:start-date (atime/unparse-local (time/plus (time/now) (time/months -1)) atime/normal-date)
|
||||||
:end-date (atime/unparse-local (time/now) atime/iso-date))
|
:end-date (atime/unparse-local (time/now) atime/normal-date))
|
||||||
|
|
||||||
"year"
|
"year"
|
||||||
(assoc query-params
|
(assoc query-params
|
||||||
:start-date (atime/unparse-local (time/plus (time/now) (time/years -1)) atime/iso-date)
|
:start-date (atime/unparse-local (time/plus (time/now) (time/years -1)) atime/normal-date)
|
||||||
:end-date (atime/unparse-local (time/now) atime/iso-date))
|
:end-date (atime/unparse-local (time/now) atime/normal-date))
|
||||||
|
|
||||||
"all"
|
"all"
|
||||||
(assoc query-params
|
(assoc query-params
|
||||||
:start-date (atime/unparse-local (time/plus (time/now) (time/years -3)) atime/iso-date)
|
:start-date (atime/unparse-local (time/plus (time/now) (time/years -3)) atime/normal-date)
|
||||||
:end-date (atime/unparse-local (time/now) atime/iso-date))
|
:end-date (atime/unparse-local (time/now) atime/normal-date))
|
||||||
|
|
||||||
query-params))
|
query-params))
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,10 @@
|
|||||||
[auto-ap.ssr.grid-page-helper :as helper]
|
[auto-ap.ssr.grid-page-helper :as helper]
|
||||||
[auto-ap.ssr.svg :as svg]
|
[auto-ap.ssr.svg :as svg]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]))
|
||||||
[clj-time.coerce :as coerce]))
|
|
||||||
|
|
||||||
;; TODO refunds
|
;; TODO refunds
|
||||||
;; TODO expected deposits
|
;; TODO expected deposits
|
||||||
;; TODO loading screen
|
|
||||||
;; always should be fast
|
;; always should be fast
|
||||||
;; make params parsing composable
|
;; make params parsing composable
|
||||||
|
|
||||||
@@ -30,17 +28,27 @@
|
|||||||
]
|
]
|
||||||
[:div.flex.space-x-1.items-baseline
|
[:div.flex.space-x-1.items-baseline
|
||||||
(com/date-input {:name "start-date"
|
(com/date-input {:name "start-date"
|
||||||
:value (:start-date (:parsed-query-params params))
|
:value (some-> params
|
||||||
|
:parsed-query-params
|
||||||
|
:start-date
|
||||||
|
(atime/parse atime/normal-date)
|
||||||
|
(atime/unparse-local
|
||||||
|
atime/normal-date))
|
||||||
:placeholder "Date"
|
:placeholder "Date"
|
||||||
:size :small})
|
:size :small})
|
||||||
|
|
||||||
(com/date-input {:name "end-date"
|
(com/date-input {:name "end-date"
|
||||||
:value (:end-date (:parsed-query-params params))
|
:value (some-> params
|
||||||
|
:parsed-query-params
|
||||||
|
:end-date
|
||||||
|
(atime/parse atime/normal-date)
|
||||||
|
(atime/unparse-local
|
||||||
|
atime/normal-date))
|
||||||
:placeholder "Date"
|
:placeholder "Date"
|
||||||
:size :small})]]
|
:size :small})]]
|
||||||
)])
|
)])
|
||||||
(defn filters [params]
|
(defn filters [params]
|
||||||
[:form {"hx-trigger" "change delay:500ms, keyup from:.hot-filter delay:1000ms"
|
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||||
:pos-sales-table)
|
:pos-sales-table)
|
||||||
"hx-target" "#sales-table"
|
"hx-target" "#sales-table"
|
||||||
@@ -125,11 +133,11 @@
|
|||||||
:date-range {:start (some-> args
|
:date-range {:start (some-> args
|
||||||
:parsed-query-params
|
:parsed-query-params
|
||||||
:start-date
|
:start-date
|
||||||
(atime/parse atime/iso-date))
|
(atime/parse atime/normal-date))
|
||||||
:end (some-> args
|
:end (some-> args
|
||||||
:parsed-query-params
|
:parsed-query-params
|
||||||
:end-date
|
:end-date
|
||||||
(atime/parse atime/iso-date))}
|
(atime/parse atime/normal-date))}
|
||||||
:total-gte (some-> args :raw-query-params (get "total-gte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
:total-gte (some-> args :raw-query-params (get "total-gte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
||||||
:total-lte (some-> args :raw-query-params (get "total-lte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
:total-lte (some-> args :raw-query-params (get "total-lte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
||||||
:type-name (condp = (:payment-method (:parsed-query-params args))
|
:type-name (condp = (:payment-method (:parsed-query-params args))
|
||||||
@@ -146,11 +154,11 @@
|
|||||||
:nav (com/main-aside-nav)
|
:nav (com/main-aside-nav)
|
||||||
:page-specific-nav filters
|
:page-specific-nav filters
|
||||||
:id-fn :db/id
|
:id-fn :db/id
|
||||||
:fetch-page (fn [user args]
|
:fetch-page (fn [_ args]
|
||||||
(d-sales/get-graphql
|
(d-sales/get-graphql
|
||||||
(args->graphql-params args)))
|
(args->graphql-params args)))
|
||||||
:oob-render
|
:oob-render
|
||||||
(fn [user params]
|
(fn [_ params]
|
||||||
[(assoc-in (date-range-field* params) [1 :hx-swap-oob] true)])
|
[(assoc-in (date-range-field* params) [1 :hx-swap-oob] true)])
|
||||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||||
:company)}
|
:company)}
|
||||||
@@ -162,7 +170,7 @@
|
|||||||
:title "Sales orders"
|
:title "Sales orders"
|
||||||
:entity-name "Sales orders"
|
:entity-name "Sales orders"
|
||||||
:route :pos-sales-table
|
:route :pos-sales-table
|
||||||
:action-buttons (fn [user args]
|
:action-buttons (fn [_ args]
|
||||||
(let [{:keys [total tax]} (d-sales/summarize-graphql (args->graphql-params args))]
|
(let [{:keys [total tax]} (d-sales/summarize-graphql (args->graphql-params args))]
|
||||||
[
|
[
|
||||||
(com/pill {:color :primary}
|
(com/pill {:color :primary}
|
||||||
@@ -171,17 +179,10 @@
|
|||||||
(com/pill {:color :secondary}
|
(com/pill {:color :secondary}
|
||||||
(format "Tax $%.2f" tax )
|
(format "Tax $%.2f" tax )
|
||||||
)]))
|
)]))
|
||||||
:row-buttons (fn [user e]
|
:row-buttons (fn [_ e]
|
||||||
|
|
||||||
(when (:sales-order/reference-link e)
|
(when (:sales-order/reference-link e)
|
||||||
[(com/a-icon-button {:href (:sales-order/reference-link e)}
|
[(com/a-icon-button {:href (:sales-order/reference-link e)}
|
||||||
svg/external-link)
|
svg/external-link)]))
|
||||||
#_(when (is-admin? user)
|
|
||||||
(com/icon-button {:hx-delete (str (bidi/path-for ssr-routes/only-routes
|
|
||||||
:company-reports-delete
|
|
||||||
:request-method :delete))
|
|
||||||
:hx-target "closest tr"}
|
|
||||||
svg/trash))]))
|
|
||||||
:headers [
|
:headers [
|
||||||
{:key "client"
|
{:key "client"
|
||||||
:name "Client"
|
:name "Client"
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
[:title (str "Integreat | " page-name)]
|
[:title (str "Integreat | " page-name)]
|
||||||
[:link {:href "/css/font.min.css", :rel "stylesheet"}]
|
[:link {:href "/css/font.min.css", :rel "stylesheet"}]
|
||||||
[:link {:rel "icon" :type "image/png" :href "/favicon.png"}]
|
[:link {:rel "icon" :type "image/png" :href "/favicon.png"}]
|
||||||
[:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}]
|
#_[:link {:rel "stylesheet", :href "/css/react-datepicker.min.inc.css"}]
|
||||||
[:link {:rel "stylesheet", :href "/output.css"}]
|
[:link {:rel "stylesheet", :href "/output.css"}]
|
||||||
|
|
||||||
[:script {:src "https://unpkg.com/hyperscript.org@0.9.7/dist/_hyperscript.min.js"}]
|
[:script {:src "https://unpkg.com/hyperscript.org@0.9.7/dist/_hyperscript.min.js"}]
|
||||||
@@ -35,6 +35,9 @@
|
|||||||
[:script {:src "https://unpkg.com/htmx.org/dist/ext/debug.js"}]
|
[:script {:src "https://unpkg.com/htmx.org/dist/ext/debug.js"}]
|
||||||
[:script {:src "/js/htmx-disable.js"}]
|
[:script {:src "/js/htmx-disable.js"}]
|
||||||
[:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async"}]]
|
[:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async"}]]
|
||||||
|
[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/css/datepicker.min.css"}]
|
||||||
|
|
||||||
|
[:script {:type "text/javascript" :src "https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/datepicker-full.min.js"}]
|
||||||
[:script {:type "text/javascript", :src "https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"}]
|
[:script {:type "text/javascript", :src "https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"}]
|
||||||
[:script {:src "https://unpkg.com/dropzone@5.9.3/dist/min/dropzone.min.js"}]
|
[:script {:src "https://unpkg.com/dropzone@5.9.3/dist/min/dropzone.min.js"}]
|
||||||
[:link {:rel "stylesheet" :href "https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" :type "text/css"}]
|
[:link {:rel "stylesheet" :href "https://unpkg.com/dropzone@5/dist/min/dropzone.min.css" :type "text/css"}]
|
||||||
|
|||||||
Reference in New Issue
Block a user