diff --git a/src/main/frontend/components/reference.cljs b/src/main/frontend/components/reference.cljs index 094642f0cc8..07cea7a4f09 100644 --- a/src/main/frontend/components/reference.cljs +++ b/src/main/frontend/components/reference.cljs @@ -10,6 +10,7 @@ [frontend.db.model :as model-db] [frontend.handler.block :as block-handler] [frontend.handler.page :as page-handler] + [frontend.search :as search] [frontend.state :as state] [frontend.ui :as ui] [frontend.util :as util] @@ -18,11 +19,7 @@ (rum/defcs filter-dialog-inner < rum/reactive (rum/local "" ::filterSearch) [state filters-atom _close-fn references page-name] (let [filter-search (get state ::filterSearch) - filtered-references (filter (fn [ref] - (if (string/includes? (util/page-name-sanity-lc (ref 0)) (util/page-name-sanity-lc @filter-search)) true false)) - references)] - (println filtered-references) - ;; (println (search/fuzzy-search references (util/page-name-sanity-lc filter-search) :limit 20)) + filtered-references (search/fuzzy-search references @filter-search :limit 20 :extract-fn (fn [arg] (arg 0)))] [:div.filters [:div.sm:flex.sm:items-start [:div.mx-auto.flex-shrink-0.flex.items-center.justify-center.h-12.w-12.rounded-full.bg-gray-200.text-gray-500.sm:mx-0.sm:h-10.sm:w-10 @@ -32,10 +29,10 @@ [:span.text-xs "Click to include and shift-click to exclude. Click again to remove."]]] [:div.cp__filters-input-panel.flex (ui/icon "search") [:input.cp__filters-input.w-full - {:placeholder (t :filter/search) - :auto-focus true - :on-change (fn [e] - (reset! filter-search (util/evalue e)))}]] + {:placeholder (t :filter/search) + :auto-focus true + :on-change (fn [e] + (reset! filter-search (util/evalue e)))}]] (when (seq filtered-references) (let [filters (rum/react filters-atom)] [:div.mt-5.sm:mt-4.sm:flex.sm.gap-1.flex-wrap @@ -47,11 +44,11 @@ false "text-red-400" nil)] [:button.border.rounded.px-1.mb-1.mr-1.select-none {:key (reference 0) :class color :style {:border-color "currentColor"} - :on-click (fn [e] - (swap! filters-atom #(if (nil? (get filters lc-reference)) - (assoc % lc-reference (not (.-shiftKey e))) - (dissoc % lc-reference))) - (page-handler/save-filter! page-name @filters-atom))} + :on-click (fn [e] + (swap! filters-atom #(if (nil? (get filters lc-reference)) + (assoc % lc-reference (not (.-shiftKey e))) + (dissoc % lc-reference))) + (page-handler/save-filter! page-name @filters-atom))} (reference 0) [:sub " " (reference 1)]]))]))])) (defn filter-dialog