Add the search for articles for the admin panel.
This commit is contained in:
@@ -26,10 +26,12 @@
|
||||
[client]
|
||||
(fn [req res]
|
||||
(let [channel (chan)
|
||||
id (.-id (.-params req))]
|
||||
search (.-search (.-query req))]
|
||||
(go
|
||||
(try
|
||||
(let [articles (<! (db/get-articles-briefly client channel))]
|
||||
(let [articles (if (nil? search)
|
||||
(<! (db/get-articles-briefly client channel))
|
||||
(<! (db/search-articles-briefly client search channel)))]
|
||||
(res/status 200)
|
||||
(.render res "admin_panel"
|
||||
(-> {:articles articles
|
||||
@@ -133,6 +135,23 @@
|
||||
(res/status 500)
|
||||
(res/send (ex-message err))))))))
|
||||
|
||||
(defn htmx-admin-search-articles-handler-factory
|
||||
[client]
|
||||
(fn [req res]
|
||||
(let [channel (chan)
|
||||
search (.-search (.-body req))]
|
||||
(go
|
||||
(try
|
||||
(let [articles (<! (db/search-articles-briefly client search channel))]
|
||||
(res/status 200)
|
||||
(.render res "article_rows"
|
||||
(-> {:articles articles
|
||||
:layout false}
|
||||
(cljs.core/clj->js))))
|
||||
(catch js/Error err
|
||||
(res/status 500)
|
||||
(res/send (ex-message err))))))))
|
||||
|
||||
(defn htmx-create-article-handler-factory
|
||||
[client]
|
||||
(fn [req res]
|
||||
|
||||
@@ -79,6 +79,9 @@
|
||||
(. app get "/htmx/articles/:id"
|
||||
(handlers/htmx-get-article-handler-factory client))
|
||||
|
||||
(. app post "/htmx/admin/search/articles/"
|
||||
(handlers/htmx-admin-search-articles-handler-factory client))
|
||||
|
||||
(. app get "/htmx/admin/rows/article/:id/"
|
||||
(handlers/htmx-get-article-row-handler-factory client))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user