Makes A&J Produce findable.
This commit is contained in:
@@ -76,3 +76,9 @@ document.addEventListener('alpine:init', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function addQueryParam(url, k, v) {
|
||||||
|
let z = new URL(url, window.location.origin);
|
||||||
|
z.searchParams.append(k, v);
|
||||||
|
return z
|
||||||
|
}
|
||||||
@@ -53,9 +53,7 @@
|
|||||||
]))
|
]))
|
||||||
|
|
||||||
(defn typeahead- [params]
|
(defn typeahead- [params]
|
||||||
[:div.relative {:x-data (hx/json { :baseUrl (if (str/includes? (:url params) "?")
|
[:div.relative {:x-data (hx/json { :baseUrl (:url params)
|
||||||
(str (:url params) "&q=")
|
|
||||||
(str (:url params) "?q="))
|
|
||||||
:value {:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}
|
:value {:value ((:value-fn params identity) (:value params)) :label ((:content-fn params identity) (:value params))}
|
||||||
:tippy nil
|
:tippy nil
|
||||||
:search ""
|
:search ""
|
||||||
@@ -112,7 +110,7 @@
|
|||||||
"@keydown.down.prevent" "active ++; active = active >= elements.length - 1 ? elements.length - 1 : active"
|
"@keydown.down.prevent" "active ++; active = active >= elements.length - 1 ? elements.length - 1 : active"
|
||||||
"@keydown.up.prevent" "active --; active = active < 0 ? 0 : active"
|
"@keydown.up.prevent" "active --; active = active < 0 ? 0 : active"
|
||||||
"@keydown.enter.prevent.stop" "tippy.hide(); value = elements.length > 0 ? $data.elements[active] : {'value': '', label: ''}; $refs.input.focus()"
|
"@keydown.enter.prevent.stop" "tippy.hide(); value = elements.length > 0 ? $data.elements[active] : {'value': '', label: ''}; $refs.input.focus()"
|
||||||
"x-init" "$el.focus(); $watch('search', s => { if($el.value.length > 2) {fetch(baseUrl + s).then(data=>data.json()).then(data => {elements = data; active=-1; tippy.popperInstance.update()}) }})"}]
|
"x-init" "$el.focus(); $watch('search', s => { if($el.value.length > 2) {fetch(addQueryParam(baseUrl, 'q', s)).then(data=>data.json()).then(data => {elements = data; active=-1; tippy.popperInstance.update()}) }})"}]
|
||||||
[:div.dropdown-options {:class "rounded-b-lg overflow-hidden"}
|
[:div.dropdown-options {:class "rounded-b-lg overflow-hidden"}
|
||||||
[:template {:x-for "(element, index) in elements"}
|
[:template {:x-for "(element, index) in elements"}
|
||||||
[:li [:a {:class "px-4 py-2 flex gap-2 items-center outline-0 focus:bg-neutral-100 hover:bg-neutral-100 whitespace-nowrap [&.active]:bg-primary-500 [&.active]:dark:bg-primary-700 text-gray-800 dark:text-gray-100"
|
[:li [:a {:class "px-4 py-2 flex gap-2 items-center outline-0 focus:bg-neutral-100 hover:bg-neutral-100 whitespace-nowrap [&.active]:bg-primary-500 [&.active]:dark:bg-primary-700 text-gray-800 dark:text-gray-100"
|
||||||
@@ -147,7 +145,7 @@
|
|||||||
"@keydown.down.prevent" "active ++; active = active >= elements.length - 1 ? elements.length - 1 : active"
|
"@keydown.down.prevent" "active ++; active = active >= elements.length - 1 ? elements.length - 1 : active"
|
||||||
"@keydown.up.prevent" "active --; active = active < 0 ? 0 : active"
|
"@keydown.up.prevent" "active --; active = active < 0 ? 0 : active"
|
||||||
"@keydown.enter.prevent.stop" "if ($data.elements[active]) { if (value.has($data.elements[active].value)) { value.delete($data.elements[active].value) } else {value.add($data.elements[active].value); lookup[$data.elements[active].value] = $data.elements[active].label} } "
|
"@keydown.enter.prevent.stop" "if ($data.elements[active]) { if (value.has($data.elements[active].value)) { value.delete($data.elements[active].value) } else {value.add($data.elements[active].value); lookup[$data.elements[active].value] = $data.elements[active].label} } "
|
||||||
"x-init" " $el.focus(); $watch('search', s => { if($el.value.length > 2) {fetch(baseUrl + s).then(data=>data.json()).then(data => reset_elements(data)) }})"}]]
|
"x-init" " $el.focus(); $watch('search', s => { if($el.value.length > 2) {fetch(addQueryParam(baseUrl, 'q', s)).then(data=>data.json()).then(data => reset_elements(data)) }})"}]]
|
||||||
[:div.dropdown-options {:class "overflow-hidden divide-y divide-gray-200 "}
|
[:div.dropdown-options {:class "overflow-hidden divide-y divide-gray-200 "}
|
||||||
[:template {:x-for "(element, index) in elements"}
|
[:template {:x-for "(element, index) in elements"}
|
||||||
[:li {":style" "index == 0 && 'border: 0 !important;'"}
|
[:li {":style" "index == 0 && 'border: 0 !important;'"}
|
||||||
@@ -189,9 +187,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn multi-typeahead- [params]
|
(defn multi-typeahead- [params]
|
||||||
[:div.relative {:x-data (hx/json {:baseUrl (if (str/includes? (:url params) "?")
|
[:div.relative {:x-data (hx/json {:baseUrl (:url params)
|
||||||
(str (:url params) "&q=")
|
|
||||||
(str (:url params) "?q="))
|
|
||||||
:reset_elements (js-fn "function(e) {
|
:reset_elements (js-fn "function(e) {
|
||||||
this.elements = [{value: 'all', label:'All'}].concat(e);
|
this.elements = [{value: 'all', label:'All'}].concat(e);
|
||||||
this.active = -1
|
this.active = -1
|
||||||
|
|||||||
@@ -662,10 +662,7 @@
|
|||||||
_ (assert-can-see-client identity (:db/id (:invoice/client invoice)))
|
_ (assert-can-see-client identity (:db/id (:invoice/client invoice)))
|
||||||
_ (assert-not-locked (:db/id (:invoice/client invoice)) (:invoice/date invoice)) ]
|
_ (assert-not-locked (:db/id (:invoice/client invoice)) (:invoice/date invoice)) ]
|
||||||
(alog/info ::undoing-autopay :transaction :tx)
|
(alog/info ::undoing-autopay :transaction :tx)
|
||||||
@(dc/transact conn [[:upsert-invoice {:db/id id
|
|
||||||
:invoice/outstanding-balance (:invoice/total entity)
|
|
||||||
:invoice/status :invoice-status/unpaid
|
|
||||||
:invoice/scheduled-payment nil}]])
|
|
||||||
(html-response
|
(html-response
|
||||||
(row* identity (assoc (dc/pull (dc/db conn) default-read id)
|
(row* identity (assoc (dc/pull (dc/db conn) default-read id)
|
||||||
:invoice/status :invoice-status/unpaid) {:flash? true
|
:invoice/status :invoice-status/unpaid) {:flash? true
|
||||||
|
|||||||
@@ -34,3 +34,42 @@
|
|||||||
{:body (take 10 valid-clients)}))
|
{:body (take 10 valid-clients)}))
|
||||||
|
|
||||||
(def search (wrap-json-response search))
|
(def search (wrap-json-response search))
|
||||||
|
|
||||||
|
#_(comment
|
||||||
|
(count (let [valid-ids (->> (dc/q '[:find ?v
|
||||||
|
:in $
|
||||||
|
:where [?v :vendor/name]]
|
||||||
|
(dc/db conn))
|
||||||
|
(map first)
|
||||||
|
(into #{}))]
|
||||||
|
(for [v (solr/query solr/impl "vendors"
|
||||||
|
{"query" "*"
|
||||||
|
"limit" 10000})
|
||||||
|
:when (not (valid-ids (Long/parseLong (:id v))))]
|
||||||
|
v)))
|
||||||
|
|
||||||
|
(let [name-like-ids (when (not-empty "A&J")
|
||||||
|
(map (comp (juxt identity #(Long/parseLong %)) :id)
|
||||||
|
(solr/query solr/impl "vendors"
|
||||||
|
{"query" (cond-> (format "name:(%s*)" (str/upper-case "A&J"))
|
||||||
|
(not (is-admin? identity)) (str " hidden:false"))
|
||||||
|
"fields" "id,name"
|
||||||
|
"limit" 300})))
|
||||||
|
valid-clients (for [[z n] name-like-ids]
|
||||||
|
{"value" n "internal-label" z "label" (dc/pull (dc/db conn) '[*] n)})]
|
||||||
|
(take 5 valid-clients))
|
||||||
|
|
||||||
|
|
||||||
|
(solr/query solr/impl "vendors"
|
||||||
|
{"query" (cond-> (format "name:(%s*)" (str/upper-case (solr/escape "A&J Pr")))
|
||||||
|
(not true) (str " hidden:false"))
|
||||||
|
"fields" "id, name"
|
||||||
|
"limit" 300})
|
||||||
|
|
||||||
|
(solr/escape "A&J")
|
||||||
|
|
||||||
|
(first (solr/query solr/impl "vendors"
|
||||||
|
{"query" (cond-> (format "name:(A\\&J PRO*)")
|
||||||
|
(not true) (str " hidden:false"))
|
||||||
|
"fields" "id, name"
|
||||||
|
"limit" 300})))
|
||||||
Reference in New Issue
Block a user