diff --git a/src/clj/auto_ap/query_params.clj b/src/clj/auto_ap/query_params.clj index 9e3453db..c36837aa 100644 --- a/src/clj/auto_ap/query_params.clj +++ b/src/clj/auto_ap/query_params.clj @@ -61,9 +61,10 @@ (dissoc (condp = (source-key query-params) "week" - (assoc query-params - start-date-key (time/plus (time/now) (time/days -7)) - end-date-key (time/now)) + (let [last-monday (atime/last-monday)] + (assoc query-params + start-date-key (time/plus last-monday (time/days -7)) + end-date-key last-monday)) "month" (assoc query-params diff --git a/src/clj/auto_ap/ssr/components/aside.clj b/src/clj/auto_ap/ssr/components/aside.clj index f860cac3..1d57ff60 100644 --- a/src/clj/auto_ap/ssr/components/aside.clj +++ b/src/clj/auto_ap/ssr/components/aside.clj @@ -111,26 +111,26 @@ :active? (= "invoices" selected)} (menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes ::invoice-route/all-page) - {:date-range "month"}) + {:date-range "year"}) :active? (= ::invoice-route/all-page (:matched-route request)) :hx-boost "true"} "All") (menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes ::invoice-route/paid-page) - {:date-range "month"}) + {:date-range "year"}) :active? (= ::invoice-route/paid-page (:matched-route request)) :hx-boost "true"} "Paid") (menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes ::invoice-route/unpaid-page) - {:date-range "month"}) + {:date-range "year"}) :active? (= ::invoice-route/unpaid-page (:matched-route request)) :hx-boost "true"} "Unpaid") (menu-button- {:href (hu/url (bidi/path-for ssr-routes/only-routes ::invoice-route/voided-page) - {:date-range "month"}) + {:date-range "year"}) :active? (= ::invoice-route/voided-page (:matched-route request)) :hx-boost "true"} "Voided") diff --git a/src/clj/auto_ap/ssr/components/date_range.clj b/src/clj/auto_ap/ssr/components/date_range.clj index 6f740e1a..ff1306f1 100644 --- a/src/clj/auto_ap/ssr/components/date_range.clj +++ b/src/clj/auto_ap/ssr/components/date_range.clj @@ -1,26 +1,28 @@ (ns auto-ap.ssr.components.date-range (:require [auto-ap.ssr.components :as com] - [auto-ap.time :as atime])) + [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] }] +(defn date-range-field [{:keys [value id]}] [:div {:id id} (com/field {:label "Date Range"} - [:div.space-y-4 + [: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")) - ] + (com/button-group-button {:size :small :value "year" :hx-trigger "click"} "Year"))] [:div.flex.space-x-1.items-baseline.w-full.justify-start (com/date-input {:name "start-date" :value (some-> (:start value) - (atime/unparse-local atime/normal-date)) + (atime/unparse-local atime/normal-date)) :placeholder "Date" :size :small :class "shrink"}) - + (com/date-input {:name "end-date" :value (some-> (:end value) (atime/unparse-local atime/normal-date)) diff --git a/src/clj/auto_ap/ssr/components/link_dropdown.clj b/src/clj/auto_ap/ssr/components/link_dropdown.clj index 43a63f1c..a63f1523 100644 --- a/src/clj/auto_ap/ssr/components/link_dropdown.clj +++ b/src/clj/auto_ap/ssr/components/link_dropdown.clj @@ -20,6 +20,6 @@ [:div.flex.flex-col.gap-y-2 (for [l links] [:div.flex-initial - [:a {:href (:link l)} + [:a {:href (:link l) :target "_blank"} (com/pill {:color (or (:color l) :primary) :class "truncate block shrink grow-0"} (:content l))]])]]]])) \ No newline at end of file diff --git a/src/clj/auto_ap/ssr/components/multi_modal.clj b/src/clj/auto_ap/ssr/components/multi_modal.clj index 74c664c5..86a6fb49 100644 --- a/src/clj/auto_ap/ssr/components/multi_modal.clj +++ b/src/clj/auto_ap/ssr/components/multi_modal.clj @@ -114,7 +114,7 @@ :class "dark:text-blue-500"} "Back"]) -(defn default-next-button [linear-wizard step validation-route] +(defn default-next-button [linear-wizard step validation-route & {:keys [next-button-content]}] (let [steps (steps linear-wizard) last? (= (step-key step) (last steps)) next-step (when-not last? (->> steps @@ -131,9 +131,10 @@ {:from (encode-step-key (step-key step)) :to (encode-step-key (step-key next-step))}))) - (if next-step - (step-name next-step) - "Save") + (or next-button-content + (if next-step + (step-name next-step) + "Save")) (when-not last? [:div.w-5.h-5 svg/arrow-right])))) @@ -143,7 +144,8 @@ (defn default-step-footer [linear-wizard step & {:keys [validation-route discard-button - next-button]}] + next-button + next-button-content]}] [:div.flex.justify-end [:div.flex.items-baseline.gap-x-4 (com/form-errors {:errors (:errors (:step-params fc/*form-errors*))}) @@ -157,7 +159,8 @@ next-button validation-route - (default-next-button linear-wizard step validation-route) + (default-next-button linear-wizard step validation-route + :next-button-content next-button-content) :else [:div "No action possible."])]]) diff --git a/src/clj/auto_ap/ssr/invoices.clj b/src/clj/auto_ap/ssr/invoices.clj index 8edd2207..582c3a20 100644 --- a/src/clj/auto_ap/ssr/invoices.clj +++ b/src/clj/auto_ap/ssr/invoices.clj @@ -1003,7 +1003,8 @@ :name (fc/field-name) :error? (fc/error?)}))))))))))]]) :footer - (mm/default-step-footer linear-wizard this :validation-route ::route/pay-wizard-navigate) + (mm/default-step-footer linear-wizard this :validation-route ::route/pay-wizard-navigate + :next-button-content "Pay") :validation-route ::route/pay-wizard-navigate))) (defn add-handwritten-check [request wizard snapshot] diff --git a/src/clj/auto_ap/ssr/users.clj b/src/clj/auto_ap/ssr/users.clj index 4c8e7d6d..8f5bcdc0 100644 --- a/src/clj/auto_ap/ssr/users.clj +++ b/src/clj/auto_ap/ssr/users.clj @@ -48,7 +48,7 @@ "hx-target" "#user-table" "hx-indicator" "#user-table"} - [:fieldset.space-y-6 + [:fieldset.space-y-6 (com/field {:label "Name"} (com/text-input {:name "name" :id "name" @@ -57,6 +57,16 @@ :placeholder "Johnny Testerson" :size :small})) + (com/field {:label "Client"} + (com/typeahead {:name "client" + :placeholder "Search..." + :url (bidi/path-for ssr-routes/only-routes + :company-search) + :id (str "client-search") + :value (:client (:parsed-query-params request)) + :value-fn :db/id + :content-fn :client/name})) + (com/field {:label "Email"} (com/text-input {:name "email" :id "email" @@ -66,31 +76,22 @@ :size :small})) (com/field {:label "Role"} - (com/radio-card {:size :small - :name "role" - :options [{:value "" - :content "All"} - {:value "admin" - :content "Admin"} - {:value "power-user" - :content "Power user"} - {:value "manager" - :content "Manager"} - {:value "user" - :content "User"} - {:value "read-only" - :content "Read Only"} - {:value "none" - :content "None"}]})) - (com/field {:label "Client"} - (com/typeahead {:name "client" - :placeholder "Search..." - :url (bidi/path-for ssr-routes/only-routes - :company-search) - :id (str "client-search") - :value (:client (:parsed-query-params request)) - :value-fn :db/id - :content-fn :client/name}))]]) + (com/radio-card {:size :small + :name "role" + :options [{:value "" + :content "All"} + {:value "admin" + :content "Admin"} + {:value "power-user" + :content "Power user"} + {:value "manager" + :content "Manager"} + {:value "user" + :content "User"} + {:value "read-only" + :content "Read Only"} + {:value "none" + :content "None"}]}))]]) (def default-read '[:db/id :user/name diff --git a/src/clj/auto_ap/ssr/utils.clj b/src/clj/auto_ap/ssr/utils.clj index 56885f6a..ef21be4c 100644 --- a/src/clj/auto_ap/ssr/utils.clj +++ b/src/clj/auto_ap/ssr/utils.clj @@ -240,9 +240,10 @@ (if date-range-value (-> (condp = date-range-value "week" - (assoc m - start-date-key (time/plus (time/now) (time/days -7)) - end-date-key (time/now)) + (let [last-monday (atime/last-monday)] + (assoc m + start-date-key (time/plus last-monday (time/days -7)) + end-date-key last-monday)) "month" (assoc m diff --git a/src/clj/auto_ap/time.clj b/src/clj/auto_ap/time.clj index 1a3c7360..389e14d0 100644 --- a/src/clj/auto_ap/time.clj +++ b/src/clj/auto_ap/time.clj @@ -1,5 +1,6 @@ (ns auto-ap.time (:require [clj-time.core :as time] + [clj-time.coerce :as coerce] [clj-time.format :as f] [auto-ap.logging :as alog])) @@ -40,7 +41,7 @@ (defn unparse-local [v format] (try - + (f/unparse (f/with-zone (f/formatter format) (time/time-zone-for-id "America/Los_Angeles")) v) (catch Exception _ nil))) @@ -52,3 +53,14 @@ d (recur (time/plus d (time/days 1)))))] (iterate #(time/plus % (time/days 7)) next-day))) + +(defn local-today [] + (coerce/in-time-zone (time/now) (time/time-zone-for-id "America/Los_Angeles"))) + + +(defn last-monday [] + (loop [current (local-now)] + (if (= 1 (time/day-of-week current)) + current + (recur (time/minus current (time/days 1)))))) + \ No newline at end of file diff --git a/terraform/connect-ports-cloud-staging.sh b/terraform/connect-ports-cloud-staging.sh index 77db7143..9bcffd4a 100755 --- a/terraform/connect-ports-cloud-staging.sh +++ b/terraform/connect-ports-cloud-staging.sh @@ -1,2 +1,2 @@ #!/bin/sh -ssh -L 2049:172.31.32.90:2049 3.213.115.86 -L 8983:solr-staging.local:8983 -L 4334:integreat-datomic.local:4334 -L9001:integreat-app-staging.local:9000 +ssh -L 2049:172.31.32.90:2049 3.213.115.86 -L 8984:solr-staging.local:8983 -L 4334:integreat-datomic.local:4334 -L9001:integreat-app-staging.local:9000