From 1b80712742f68bb56aa05568c7248b9e0a888f97 Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 29 Apr 2024 20:56:37 -0700 Subject: [PATCH] charts --- resources/public/js/alpine-vals.js | 7 +++++++ resources/public/js/htmx-disable.js | 14 +++++++++++--- src/clj/auto_ap/plaid/core.clj | 6 ------ src/clj/auto_ap/ssr/components/aside.clj | 1 + src/clj/auto_ap/ssr/components/inputs.clj | 10 ++++++---- src/clj/auto_ap/ssr/components/page.clj | 3 ++- src/clj/auto_ap/ssr/dashboard.clj | 2 +- 7 files changed, 28 insertions(+), 15 deletions(-) diff --git a/resources/public/js/alpine-vals.js b/resources/public/js/alpine-vals.js index 4dcd57d0..aab0168d 100644 --- a/resources/public/js/alpine-vals.js +++ b/resources/public/js/alpine-vals.js @@ -35,4 +35,11 @@ Alpine.directive('hx-header', (el, { value, expression }, { evaluateLater, effec }) }) }) + Alpine.directive( + "destroy", + (el, { expression }, { evaluateLater, cleanup }) => { + const onDestroy = evaluateLater(expression); + cleanup(onDestroy); + } + ); }) \ No newline at end of file diff --git a/resources/public/js/htmx-disable.js b/resources/public/js/htmx-disable.js index 50891c95..b46f79a4 100644 --- a/resources/public/js/htmx-disable.js +++ b/resources/public/js/htmx-disable.js @@ -107,7 +107,6 @@ htmx.defineExtension('trigger-filter', { onEvent: function(name , evt) { if (name=="htmx:beforeRequest") { var element = evt.detail.elt; - console.log("HEREEE", element.lastParams, evt.detail.requestConfig.parameters) if (!deepEqual(element.lastParams, evt.detail.requestConfig.parameters)) { element.lastParams = evt.detail.requestConfig.parameters; } else { @@ -122,13 +121,21 @@ htmx.defineExtension('trigger-filter', { initDatepicker = function(elem) { const modalParent = elem.closest('#modal-content'); if (modalParent) { - elem.dp = new Datepicker(elem, {format: "mm/dd/yyyy", autohide: true, container: "#modal-content .modal-card"}); + return new Datepicker(elem, {format: "mm/dd/yyyy", autohide: true, container: "#modal-content .modal-card"}); } else { - elem.dp = new Datepicker(elem, {format: "mm/dd/yyyy", autohide: true}); + return new Datepicker(elem, {format: "mm/dd/yyyy", autohide: true}); } } +destroyDatepicker = function(dp) { + try { + dp.destroy() + } catch { + + } +} + countRows = function(id) { var table = document.querySelector(id); var rows = table.querySelectorAll("tbody tr"); @@ -171,3 +178,4 @@ htmx.onLoad(function(content) { console.error('Failed to copy text to clipboard:', err); } } + diff --git a/src/clj/auto_ap/plaid/core.clj b/src/clj/auto_ap/plaid/core.clj index f489dade..9b39a422 100644 --- a/src/clj/auto_ap/plaid/core.clj +++ b/src/clj/auto_ap/plaid/core.clj @@ -11,12 +11,6 @@ (def client-id (-> env :plaid :client-id)) (def secret-key (-> env :plaid :secret-key)) -(def base-url "https://production.plaid.com") - - (def client-id "61bfab05f7e762001b323f79") - -(def secret-key "2be026ca5e7f7e9f23f2fb4d7c914d") - (defn get-link-token [client-code] (-> (client/post (str base-url "/link/token/create") {:as :json diff --git a/src/clj/auto_ap/ssr/components/aside.clj b/src/clj/auto_ap/ssr/components/aside.clj index b9c5dd1e..bef8c966 100644 --- a/src/clj/auto_ap/ssr/components/aside.clj +++ b/src/clj/auto_ap/ssr/components/aside.clj @@ -67,6 +67,7 @@ :x-show "leftNavShow" ":aria-hidden" "leftNavShow ? 'false' : 'true'"} + ;; TODO this causes a leftNavShow error when hitting back button. maybe amke a container [:template {:x-teleport "body"} [:div.fixed.inset-0.lg:hidden {:x-show "leftNavShow" :x-transition:enter "transition duration-500" :x-transition:enter-start "opacity-0" :x-transition:enter-end "opacity-100" diff --git a/src/clj/auto_ap/ssr/components/inputs.clj b/src/clj/auto_ap/ssr/components/inputs.clj index 01f5531e..c525216b 100644 --- a/src/clj/auto_ap/ssr/components/inputs.clj +++ b/src/clj/auto_ap/ssr/components/inputs.clj @@ -175,10 +175,12 @@ (update :class (fnil hh/add-class "") default-input-classes) (assoc :x-modelable "value") (assoc :type "text") - (assoc "_" (hiccup/raw "init initDatepicker(me)")) - (assoc "@change" "value = $event.target.value; console.log(value)") - (assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\") - htmx:beforeCleanupElement: this.dp.destroy()")) + (assoc :x-data (hx/json {:dp nil}) ) + (assoc :x-init " dp = initDatepicker($el);") + (assoc "@htmx:before-history-save" "destroyDatepicker(dp)" ) + (assoc "@htmx:before-cleanup-element" "destroyDatepicker(dp)" ) + (assoc "@change" "value = $event.target.value;") + (assoc "hx-on" (hiccup/raw "changeDate: htmx.trigger(this, \"change\") ")) (update :class #(str % (use-size size) " w-full")) (dissoc :size))]]) diff --git a/src/clj/auto_ap/ssr/components/page.clj b/src/clj/auto_ap/ssr/components/page.clj index 6410af1f..b51a40b6 100644 --- a/src/clj/auto_ap/ssr/components/page.clj +++ b/src/clj/auto_ap/ssr/components/page.clj @@ -11,7 +11,8 @@ on notification from body put event.detail.value into #notification-details then add .htmx-added to #notification-holder then remove .hidden from #notification-holder then wait 30ms then remove .htmx-added from #notification-holder on htmx:responseError put event.detail.xhr.response into #error-details then add .htmx-added to #error-holder then remove .hidden from #error-holder then wait 30ms then remove .htmx-added from #error-holder" ) - :x-data (hx/json {:leftNavShow true})} + :x-data (hx/json {:leftNavShow true}) + } (navbar- {:client-selection client-selection :clients clients :client client diff --git a/src/clj/auto_ap/ssr/dashboard.clj b/src/clj/auto_ap/ssr/dashboard.clj index b6ac4be4..7f7fd626 100644 --- a/src/clj/auto_ap/ssr/dashboard.clj +++ b/src/clj/auto_ap/ssr/dashboard.clj @@ -250,7 +250,7 @@ (com/link {:href (hu/url (bidi.bidi/path-for ssr-routes/only-routes ::i-routes/unpaid-page) {:date-range "year"}) - :hx-boost "true"} + } "Pay now") ])