makes user page better.

This commit is contained in:
2023-10-12 23:27:49 -07:00
parent d9fec54062
commit 1e4dabfa07
7 changed files with 166 additions and 73 deletions

View File

@@ -80,9 +80,9 @@
"limit" 300}))))
valid-clients (for [n name-like-ids
:when (valid-client-ids n)]
{"id" n "text" (pull-attr (dc/db conn) :client/name n)}
{"value" n "label" (pull-attr (dc/db conn) :client/name n)}
)]
{:body {"results" valid-clients}}))
{:body (take 10 valid-clients)}))
(def search (wrap-json-response search))

View File

@@ -1,12 +1,13 @@
(ns auto-ap.ssr.components.inputs
(:require [hiccup2.core :as hiccup]
[auto-ap.ssr.svg :as svg]
[bidi.bidi :as bidi]))
(:require
[hiccup2.core :as hiccup]))
(defn select- [params & children]
(into
[:select {:class (str (:class params) " bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 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")
:name (:name params)}
[:select (-> params
(dissoc :allow-blank? :value :options)
(update
:class str " bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 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"))
(cond->>
(map (fn [[k v]]
[:option {:value k :selected (= k (:value params))} v])
@@ -15,35 +16,39 @@
children))
(defn typeahead- [params]
[:div {:class (:class params)}
[:div {}
[:select (-> params
(dissoc :url)
(assoc :width ""))
(dissoc :value)
(assoc :width "")
)
(for [[k v] (:value params)]
[:option {:value k :selected true} v]
)
[:script {:lang "javascript"}
(hiccup/raw (format "$(document).ready(function() {$(\"#%s\").select2({ajax: {url: '%s', dataType: 'json'}, minimumInputLength: 4, placeholder: \"%s\"})})"
(:id params)
(:url params)
(or (:placeholder params)
"Type to search")))]]])
]
[:script {:lang "javascript"}
(hiccup/raw (format "
(function () {
var element = document.getElementById('%s');
var c = new Choices(element, {removeItems: true, removeItemButton:true, searchFloor: 3});
element.addEventListener('search', function (e) {
let data = fetch('%s?q=' + e.detail.value)
.then(res => res.json())
.then(data => {
c.setChoices(data, 'value', 'label', true)
});
});
element.addEventListener('choice', function (e) {
c.clearChoices();
})
})();
"
(:id params)
(:url params)
))]])
(defn typeahead-results- [{:keys [options]}]
[:ul
(for [{:keys [id name]} options]
[:li
[:div {:class "flex items-center pl-2 rounded hover:bg-green-100 dark:hover:bg-green-600"}
[:a {:href "#"
:class "w-full py-2 ml-2 text-sm font-medium text-gray-900 rounded dark:text-gray-300"
#_#_:hx-put (bidi/path-for ssr-routes/only-routes
:active-client
:request-method :put)
:hx-target "#company-dropdown"
:hx-headers (format "{\"x-clients\": \"[%d]\"}" id)
:hx-swap "outerHTML"
:hx-trigger "click"}
name]]])])
(defn use-size [size]
(if (= :small size)

View File

@@ -23,7 +23,7 @@
[:link {:rel "icon" :type "image/png" :href "/favicon.png"}]
[:link {:rel "stylesheet", :href "/output.css"}]
[:script {:src "https://code.jquery.com/jquery-3.7.1.min.js"}]
#_[:script {:src "https://code.jquery.com/jquery-3.7.1.min.js"}]
[:script {:src "https://unpkg.com/hyperscript.org@0.9.7/dist/_hyperscript.min.js"}]
[:script {:src "https://unpkg.com/@popperjs/core@2.11.8/dist/umd/popper.min.js"}]
[:script {:src "https://cdn.plaid.com/link/v2/stable/link-initialize.js"}]
@@ -35,8 +35,12 @@
[: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/select2@4.1.0-rc.0/dist/js/select2.min.js"}]
[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css"}]
#_[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/choices.js@9.0.1/public/assets/styles/base.min.css"}]
[:link {:rel "stylesheet" :href "https://cdn.jsdelivr.net/npm/choices.js@9.0.1/public/assets/styles/choices.min.css"}]
[:script {:src "https://cdn.jsdelivr.net/npm/choices.js@9.0.1/public/assets/scripts/choices.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"}]
[:style

View File

@@ -19,10 +19,10 @@
[auto-ap.time :as atime]
[bidi.bidi :as bidi]
[buddy.sign.jwt :as jwt]
[clj-http.client :as client]
[clojure.string :as str]
[config.core :refer [env]]
[datomic.api :as dc]))
[datomic.api :as dc]
[malli.core :as mc]))
(defn filters [request]
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
@@ -290,6 +290,7 @@
(com/field {:label "Role"}
(com/select {:name "role"
:class "w-36"
:autofocus true
:id "role"
:value (name (:user/role user))
:options [["none" "None"]
@@ -304,7 +305,7 @@
:multiple "multiple"
:url (bidi/path-for ssr-routes/only-routes
:company-search)
:id "role"
:id "clients"
:value (map
(fn [client]
[(:db/id client) (:client/name client)])

View File

@@ -52,7 +52,7 @@
:icon-class "icon icon-single-neutral-book"
:test-route #{:admin-users}
:active-route active-route
:route :admin-users
:route :users
:icon-style {:font-size "25px"}})
(menu-item {:label "Accounts"
:icon-class "icon icon-list-bullets"