Adds the company drop down to new pages

This commit is contained in:
2023-01-20 10:45:50 -08:00
parent 447ee308b1
commit 7a8267f09f
9 changed files with 60 additions and 87 deletions

View File

@@ -1,6 +1,7 @@
(ns auto-ap.ssr.ui
(:require
[auto-ap.logging :as alog]
[auto-ap.ssr.company-dropdown :as company-dropdown]
[config.core :refer [env]]
[hiccup2.core :as hiccup]))
@@ -12,41 +13,9 @@
(hiccup/html
{}
hiccup))})
(defn client-dropdown []
(let [client nil
matching-clients nil]
[:div#company-dropdown.navbar-item.has-dropdown
[:a.navbar-link {"_" (hiccup/raw "on click toggle .is-active on <#company-dropdown />")} "Company"]
[:div.navbar-dropdown
[:input.input.navbar-item {:placeholder "Company name"
:autoFocus true} ]
]]
#_[navbar-drop-down {:header (str "Company: " (if @client (:name @client)
"All"))
:id :select-client}
[:div
[:a {:class "navbar-item"
:on-click (fn []
(re-frame/dispatch [:events/toggle-menu :select-client])
(re-frame/dispatch [:forms/form-closing :client-search])
(re-frame/dispatch [:events/swap-client nil]))} "All" ]
[:hr {:class "navbar-divider"}]
[form-builder/builder {:id :client-search
:submit-event [:client-searched]}
[form-builder/raw-field-v2 {:field :value}
[:input.input.navbar-item {:placeholder "Company name"
:auto-focus true}]]]
(for [{:keys [name id] :as client} (take 8 matching-clients)]
^{:key id }
[:a {:class "navbar-item"
:on-click (fn []
(re-frame/dispatch [:events/toggle-menu :select-client])
(re-frame/dispatch [:events/swap-client client]))
} name])]]))
(defn base-page [contents side-bar-contents]
(defn base-page [request contents side-bar-contents]
(html-page
[:html.has-navbar-fixed-top
[:head
@@ -64,13 +33,13 @@
[:link {:rel "stylesheet", :href "/finance-font/style.css"}]
[:link {:rel "stylesheet", :href "/css/main.css"}]
[:link {:rel "stylesheet", :href "https://unpkg.com/placeholder-loading/dist/css/placeholder-loading.min.css"}]
#_[:link {:rel "stylesheet", :href "https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/css/autoComplete.min.css"}]
[:script {:src "https://unpkg.com/hyperscript.org@0.9.7"}]
[:script {:src "https://unpkg.com/htmx.org@1.8.4"
:integrity "sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV"
:crossorigin= "anonymous"}]
[:script {:type "text/javascript", :src "https://cdn.yodlee.com/fastlink/v4/initialize.js", :async "async" }]]
[:script {:type "text/javascript", :src "https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"}]
[:body
[:div {:id "app"}
[:div
@@ -94,7 +63,7 @@
"Transactions" ]
[:a.navbar-item {:href "/ledger/"}
"Ledger" ]
(client-dropdown)]]]]
(company-dropdown/dropdown request)]]]]
[:div {:class "columns has-shadow", :id "mail-app", :style "margin-bottom: 0px; height: calc(100vh - 46px);"}
[:aside {:class "column aside menu is-2 "}
[:div {:class "main left-nav"}
@@ -105,38 +74,3 @@
[:div]
[:div {:id "dz-hidden"}]]]
[:div#modal-holder]]]))
(defn html-response [hiccup & {:keys [status] :or {status 200}}]
{:status status
:headers {"Content-Type" "text/html"}
:body (str
(hiccup/html
{}
hiccup))})
(defn wrap-error-response [handler]
(fn [request]
(try
(handler request)
(catch Exception e
(if-let [v (or (:validation-error (ex-data e))
(:validation-error (ex-data (.getCause e))))]
(do
(alog/warn ::request-validation-error
:exception e)
(html-response
[:div.notification.is-warning.is-light
v]
:status 400))
(do
(alog/error ::request-error
:exception e)
(when (= "dev" (:dd-env env))
(println e))
(html-response
[:div.notification.is-danger.is-light
"Server error occured."
(ex-message e)]
:status 500)))))))