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

@@ -10974,12 +10974,6 @@ span[data-tooltip].has-tooltip-primary-two {
overflow: auto;
}
.typeahead input[disabeld] {
background-color: whitesmoke;
border-color: whitesmoke;
box-shadow: none;
}
.typeahead-suggestion {
display: block;
overflow: visible;
@@ -11043,4 +11037,23 @@ tbody tr.live-added {
border-width: 2.5px;
}
.autocomplete-suggestion {
display: block;
overflow: visible;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #333333;
white-space: nowrap;
}
.autocomplete-suggestion.highlighted, .autocomplete-suggestion:hover {
color: white;
text-decoration: none;
outline: 0;
background-color: #79b52e;
cursor: pointer;
}
/*# sourceMappingURL=bulma.min.css.map */

File diff suppressed because one or more lines are too long

View File

@@ -469,3 +469,4 @@ table.balance-sheet th.total {
border-color: whitesmoke !important;
box-shadow: none;
}

View File

@@ -1,4 +1,3 @@
@/charset "utf-8";
/* latin */
@font-face {
font-family: 'Calibri';
@@ -165,4 +164,21 @@ tbody tr.live-added {
border-width: 2.5px;
}
// For autocompletejs on non-react views
.autocomplete-suggestion {
display: block;
overflow: visible;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #333333;
white-space: nowrap;
}
.autocomplete-suggestion.highlighted, .autocomplete-suggestion:hover {
color: $white;
text-decoration: none;
outline: 0;
background-color: $primary;
cursor: pointer;
}

View File

@@ -3,7 +3,8 @@
[auto-ap.datomic :refer [conn]]
[auto-ap.logging :as alog]
[auto-ap.shared-views.admin.side-bar :refer [admin-side-bar]]
[auto-ap.ssr.ui :refer [base-page html-response]]
[auto-ap.ssr.ui :refer [base-page]]
[auto-ap.ssr.utils :refer [html-response]]
[auto-ap.time :as atime]
[clj-time.coerce :as coerce]
[clojure.string :as str]
@@ -149,7 +150,7 @@
(if (get (:headers request) "hx-request")
(html-response
(table entity-id best-guess-entity history))
(base-page (page-template :table (table entity-id best-guess-entity history)
(base-page request (page-template :table (table entity-id best-guess-entity history)
:entity-id entity-id)
(admin-side-bar :admin-history))))
(catch NumberFormatException _
@@ -189,8 +190,9 @@
[:div.notification.is-danger.is-light
"Cannot parse the entity-id " entity-id ". It should be a number."]))))
(defn history [{:keys [matched-route]}]
(base-page (page-template )
(defn history [{:keys [matched-route] :as request}]
(base-page request
(page-template )
(admin-side-bar matched-route)))

View File

@@ -4,7 +4,8 @@
[auto-ap.graphql.utils :refer [can-see-client? is-admin?]]
[auto-ap.shared-views.company.sidebar :refer [company-side-bar]]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.ui :refer [base-page html-response]]
[auto-ap.ssr.ui :refer [base-page]]
[auto-ap.ssr.utils :refer [html-response]]
[bidi.bidi :as bidi]
[clojure.string :as str]
[datomic.api :as d]
@@ -307,6 +308,7 @@
(defn page [{:keys [identity matched-route] :as request}]
(base-page
request
[:div
[:div#vendor-table {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-table

View File

@@ -3,12 +3,15 @@
[auto-ap.routes.utils
:refer [wrap-admin wrap-client-redirect-unauthenticated wrap-secure]]
[auto-ap.ssr.admin :as admin]
[auto-ap.ssr.company.company-1099 :as company-1099]))
[auto-ap.ssr.company.company-1099 :as company-1099]
[auto-ap.ssr.company-dropdown :as company-dropdown]))
;; from auto-ap.ssr-routes, because they're shared
(def key->handler {:admin-history (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/history)))
:admin-history-search (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/history-search)))
:admin-history-inspect (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin admin/inspect)))
:active-client (wrap-client-redirect-unauthenticated (wrap-secure (wrap-admin company-dropdown/active-client)))
:company-dropdown-contents (wrap-client-redirect-unauthenticated (wrap-secure company-dropdown/dropdown-contents))
:company-1099 (wrap-client-redirect-unauthenticated (wrap-secure company-1099/page))
:company-1099-vendor-table (wrap-client-redirect-unauthenticated (wrap-secure company-1099/vendor-table))
:company-1099-vendor-dialog (wrap-client-redirect-unauthenticated (wrap-secure company-1099/vendor-dialog))

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)))))))

View File

@@ -5,7 +5,9 @@
#"/search/?" :admin-history-search
["/" [#"\d+" :entity-id] #"/?"] :admin-history-search
["/inspect/" [#"\d+" :entity-id] #"/?"] :admin-history-inspect}}
"company" {"/1099" :company-1099
"company" {"/dropdown" :company-dropdown-contents
"/active" {:put :active-client}
"/1099" :company-1099
"/1099/table" {:get :company-1099-vendor-table}
"/1099/vendor-dialog" {["/" [#"\d+" :vendor-id]] {:get :company-1099-vendor-dialog
:post :company-1099-vendor-save}}}})