summaryrefslogtreecommitdiff
path: root/lisp/webapps/resume
diff options
context:
space:
mode:
authorckonstanski <kostcarl@isu.edu>2026-08-18 20:00:23 -0600
committerckonstanski <kostcarl@isu.edu>2026-08-18 20:00:23 -0600
commit26a106b0d9687be8448e37658887c8bc2937804e (patch)
treec13e2b04583802f7e3c407dc9a7c9f945cc15bfb /lisp/webapps/resume
parentc3b8f1326a874ae08b394020c6279237b0413293 (diff)
notification cleanup and message marking
Diffstat (limited to 'lisp/webapps/resume')
-rw-r--r--lisp/webapps/resume/clojurescript/resume/src/resume/core.clj16
-rw-r--r--lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs152
2 files changed, 80 insertions, 88 deletions
diff --git a/lisp/webapps/resume/clojurescript/resume/src/resume/core.clj b/lisp/webapps/resume/clojurescript/resume/src/resume/core.clj
index c02b686..7d61812 100644
--- a/lisp/webapps/resume/clojurescript/resume/src/resume/core.clj
+++ b/lisp/webapps/resume/clojurescript/resume/src/resume/core.clj
@@ -132,12 +132,7 @@
(for [rec# results#]
(let [tr-attributes# (atom {:id (str "tr-" ~component "-" (get rec# "id"))
:key (str "tr-" ~component "-" (get rec# "id"))})
- selected-p# (= (str (get rec# "id"))
- (str (get (get (deref ~(symbol (str component "-view-state")))
- (keyword ~component))
- "id")))]
- (when selected-p#
- (swap! tr-attributes# assoc :class "selected"))
+ td-attributes# (atom {:on-click #()})]
[:tr @tr-attributes#
(for [key# (filter #(not (str/includes? % "_id")) keys#)]
[:td (str (get rec# key#))])
@@ -150,7 +145,6 @@
(defn ~(symbol (str "handler-" component "-view")) [response#]
(let [jsonobj# (cljs.core/js->clj (js/JSON.parse response#))]
- (notifications jsonobj#)
(~(symbol (str "reset-" component "-view-state")) jsonobj#)))
(defn ~(symbol (str "render-" component "-view")) []
@@ -165,7 +159,6 @@
(defn ~(symbol (str "handler-" component "-add")) [response#]
(let [jsonobj# (cljs.core/js->clj (js/JSON.parse response#))]
- (auth-notifications jsonobj#)
(~(symbol (str "reset-" component "-add-state")) jsonobj#)
(.modal (jquery (str "#modal-" ~component "-add")))))
@@ -183,7 +176,7 @@
(defn ~(symbol (str "handler-" component "-add-submit")) [response#]
(let [jsonobj# (cljs.core/js->clj (js/JSON.parse response#))]
(auth-notifications jsonobj#)
- (on-menu-clicked ~(str "/resume/" component))))
+ (~(symbol (str "render-" component "-view")))))
(defn ~(symbol (str "render-" component "-add-submit")) []
(ajax.core/POST ~(str "/resume/" component "/add/submit")
@@ -199,7 +192,6 @@
(defn ~(symbol (str "handler-" component "-modify")) [response#]
(let [jsonobj# (cljs.core/js->clj (js/JSON.parse response#))]
- (auth-notifications jsonobj#)
(~(symbol (str "reset-" component "-modify-state")) jsonobj#)
(.modal (jquery (str "#modal-" ~component "-modify")))))
@@ -219,7 +211,7 @@
(defn ~(symbol (str "handler-" component "-modify-submit")) [response#]
(let [jsonobj# (cljs.core/js->clj (js/JSON.parse response#))]
(auth-notifications jsonobj#)
- (on-menu-clicked (str "/resume/" ~component))))
+ (~(symbol (str "render-" component "-view")))))
(defn ~(symbol (str "render-" component "-modify-submit")) []
(ajax.core/POST (str "/resume/" ~component "/modify/submit")
@@ -234,7 +226,7 @@
(defn ~(symbol (str "handler-" component "-delete")) [response#]
(let [jsonobj# (cljs.core/js->clj (js/JSON.parse response#))]
(auth-notifications jsonobj#)
- (on-menu-clicked ~(str "/resume/" component))))
+ (~(symbol (str "render-" component "-view")))))
(defn ~(symbol (str "render-" component "-delete")) [id#]
(ajax.core/DELETE (str "/resume/" ~component "/delete/" id#)
diff --git a/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs b/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs
index 967ee47..52059f7 100644
--- a/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs
+++ b/lisp/webapps/resume/clojurescript/resume/src/resume/core.cljs
@@ -24,7 +24,8 @@
(declare reset-contact-us-state)
(declare reset-contact-us-view-state)
(declare reset-messages-state)
-(declare reset-messages-results-state)
+(declare reset-messages-view-state)
+(declare reset-messages-mode-state)
(declare reset-users-state)
(declare reset-users-view-state)
(declare reset-users-add-state)
@@ -35,6 +36,7 @@
(declare markdown-to-html)
(declare reduce-checkboxes)
(declare form-fields-to-map)
+(declare clear-notifications)
(declare notifications)
(declare auth-notifications)
(declare comp-menu-main)
@@ -96,9 +98,9 @@
(declare handler-messages)
(declare render-messages)
(declare on-messages-mode-clicked)
-(declare comp-messages-results)
-(declare handler-messages-results)
-(declare render-messages-results)
+(declare comp-messages-view)
+(declare handler-messages-view)
+(declare render-messages-view)
(declare on-messages-mark)
(declare handler-messages-mark)
(declare render-messages-mark)
@@ -171,7 +173,8 @@
(def contact-us-state (r/atom {}))
(def contact-us-view-state (r/atom {}))
(def messages-state (r/atom {}))
-(def messages-results-state (r/atom {}))
+(def messages-view-state (r/atom {}))
+(def messages-mode-state (r/atom "unread"))
(def users-state (r/atom {}))
(def users-view-state (r/atom {}))
(def users-add-state (r/atom {}))
@@ -223,8 +226,11 @@
(defn reset-messages-state [jsonobj]
(reset! messages-state jsonobj))
-(defn reset-messages-results-state [jsonobj]
- (reset! messages-results-state jsonobj))
+(defn reset-messages-view-state [jsonobj]
+ (reset! messages-view-state jsonobj))
+
+(defn reset-messages-mode-state [mode]
+ (reset! messages-mode-state mode))
(defn reset-users-state [jsonobj]
(reset! users-state jsonobj))
@@ -278,6 +284,9 @@
;; notifications
+(defn clear-notifications []
+ (notifications {:message nil :errormsg nil}))
+
(defn notifications [jsonobj]
(ck-notifications/reset-message (get jsonobj "message"))
(ck-notifications/reset-errormsg (get jsonobj "errormsg")))
@@ -347,8 +356,8 @@
(defn handler-login [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (reset-login-state jsonobj)
- (notifications jsonobj)))
+ (notifications jsonobj)
+ (reset-login-state jsonobj)))
(defn render-login []
(GET "/login" {:handler handler-login}))
@@ -363,13 +372,8 @@
(defn handler-login-authenticate [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (cond (get jsonobj "errormsg")
- (goto-location "/login")
- (get jsonobj "message")
- (do
- (reset-location "/home")
- (render-home)
- (render-menu)))))
+ (cond (get jsonobj "errormsg") (goto-location "/login")
+ (get jsonobj "message") (on-menu-clicked "/home"))))
(defn render-login-authenticate []
(POST "/login/authenticate"
@@ -461,8 +465,7 @@
(defn handler-profile-view [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (reset-profile-view-state jsonobj)
- (auth-notifications jsonobj)))
+ (reset-profile-view-state jsonobj)))
(defn render-profile-view []
(GET "/profile/view" {:handler handler-profile-view}))
@@ -477,7 +480,6 @@
(defn handler-profile-modify [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (auth-notifications jsonobj)
(reset-profile-modify-state jsonobj)
(.modal (jquery "#modify-profile"))))
@@ -496,7 +498,7 @@
(defn handler-profile-modify-submit [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
- (on-menu-clicked "/profile")))
+ (render-profile-view)))
(defn render-profile-modify-submit []
(POST "/profile/modify/submit"
@@ -513,7 +515,6 @@
(defn handler-password [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (notifications jsonobj)
(reset-password-state jsonobj)))
(defn render-password []
@@ -529,8 +530,8 @@
(defn handler-password-submit [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (auth-notifications jsonobj)
- (on-menu-clicked "/password")))
+ (notifications jsonobj)
+ (render-password)))
(defn render-password-submit []
(POST "/password/submit"
@@ -569,9 +570,9 @@
(defn handler-about-us [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
+ (notifications jsonobj)
(reset-about-us-category-state (get jsonobj "category"))
(reset-about-us-state jsonobj)
- (notifications jsonobj)
(render-about-us-view)))
(defn render-home
@@ -612,7 +613,6 @@
(defn handler-about-us-modify [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (auth-notifications jsonobj)
(reset-about-us-modify-state jsonobj)
(.modal (jquery "#modify-about-us"))))
@@ -631,8 +631,8 @@
(defn handler-about-us-modify-submit [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (reset-about-us-view-state jsonobj)
- (auth-notifications jsonobj)))
+ (auth-notifications jsonobj)
+ (render-about-us-view)))
(defn render-about-us-modify-submit []
(POST (str "/" @about-us-category-state "/modify/submit")
@@ -679,7 +679,6 @@
(defn handler-contact-us-view [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (notifications jsonobj)
(reset-contact-us-view-state jsonobj)))
(defn render-contact-us-view []
@@ -694,7 +693,7 @@
(render-contact-us-email-submit)))
(defn handler-contact-us-email-submit [response]
- (on-menu-clicked "/contact-us"))
+ (render-contact-us-view))
(defn render-contact-us-email-submit []
(POST "/contact-us/email"
@@ -708,28 +707,26 @@
[:div {:style {:display (cond (or (= @location-state "/messages")) "block" :else "none")}}
[:h3 {:style {:text-align "center"}} (get @messages-state "title")]
[:div {:dangerouslySetInnerHTML (r/unsafe-html (ck-form/template-generic-form (get @messages-state "form") (namespace ::x)))}]
- [comp-messages-results]])
+ [comp-messages-view]])
(defn handler-messages [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(notifications jsonobj)
- (reset-messages-state jsonobj)))
+ (reset-messages-state jsonobj)
+ (render-messages-view)))
(defn render-messages []
(GET "/messages" {:handler handler-messages}))
-;; messages-results
-
-(defn on-messages-mode-clicked [read]
- (dommy/set-value! (dommy/sel1 :#messages_select_mode_form-read) read)
- (render-messages-results))
+;; messages-view
-(defn comp-messages-results []
- (let [results (get @messages-results-state "results")
+(defn comp-messages-view []
+ (let [results (get @messages-view-state "results")
keys (remove (fn [x]
(not (get (first results) x)))
(keys (first results)))]
[:div
+ [:h3 {:style {:text-align "center"}} (str @messages-mode-state " messages")]
(cond (empty? results)
[:h5 {:style {:text-align "center"}} "No results found."]
:else
@@ -739,37 +736,42 @@
(for [key keys]
[:th key])
[:th
- (str "Mark " (cond (= (dommy/value (dommy/sel1 :#messages_select_mode_form-read)) "read")
+ (str "Mark " (cond (= @messages-mode-state "read")
"unread"
:else
"read"))]]]
[:tbody
(for [rec results]
- (let [onclick "void()"]
- [:tr
- (for [key keys]
- [:td {:onclick onclick} (get rec key)])
- [:td [:img {:src (str "/static/images/"
- (cond (= (dommy/value (dommy/sel1 :#messages_select_mode_form-read)) "read")
- "edit-undo.png"
- :else
- "edit-redo.png"))
- :on-click #(on-messages-mark (cond (= (dommy/value (dommy/sel1 :#messages_select_mode_form-read)) "read")
- "'unread'"
- :else
- "'read'")
- (get rec "id"))}]]]))]])]))
+ [:tr {:key (str "messages-select-mode-" (get rec "id"))}
+ (for [key keys]
+ [:td (get rec key)])
+ [:td [:img {:src (str "/static/images/"
+ (cond (= @messages-mode-state "read")
+ "edit-undo.png"
+ :else
+ "edit-redo.png"))
+ :on-click #(on-messages-mark (cond (= @messages-mode-state "read")
+ "unread"
+ :else
+ "read")
+ (get rec "id"))}]]])]])]))
-(defn handler-messages-results [response]
+(defn handler-messages-view [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (auth-notifications jsonobj)
- (reset-messages-results-state jsonobj)))
+ (reset-messages-view-state jsonobj)))
-(defn render-messages-results []
- (POST "/messages/results"
+(defn render-messages-view []
+ (POST "/messages/view"
{:format :raw
- :params (form-fields-to-map "#messages-select-mode-form :input")
- :handler handler-messages-results}))
+ :params {:read @messages-mode-state}
+ :handler handler-messages-view}))
+
+;; messages-read/unread
+
+(defn on-messages-mode-clicked [mode]
+ (clear-notifications)
+ (reset-messages-mode-state mode)
+ (render-messages-view))
;; messages-mark
@@ -779,12 +781,13 @@
(defn handler-messages-mark [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
- (on-menu-clicked "/messages")))
+ (render-messages-view)))
(defn render-messages-mark [read id]
(POST "/messages/mark"
{:format :raw
- :params (merge (form-fields-to-map "#messages-select-mode-form :input") {"id" (str id)})
+ :params {:read read
+ :id (str id)}
:handler handler-messages-mark}))
;; users
@@ -865,12 +868,13 @@
[:th {:scope "col"} "Del"]]]
[:tbody
(for [user (get @users-view-state "users")]
- [:tr
- [:td [:img {:src (cond (get user "active")
- "/static/images/yes.png"
- :else
- "/static/images/no.png")
- :on-click #(on-users-toggle-active-clicked (get user "id"))}]]
+ [:tr {:key (str "users-view-" (get user "id"))}
+ [:td
+ [:img {:src (cond (get user "active")
+ "/static/images/yes.png"
+ :else
+ "/static/images/no.png")
+ :on-click #(on-users-toggle-active-clicked (get user "id"))}]]
[:td (get user "last_name")]
[:td (get user "first_name")]
[:td (get user "username")]
@@ -885,7 +889,6 @@
(defn handler-users-view [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (notifications jsonobj)
(reset-users-view-state jsonobj)))
(defn render-users-view []
@@ -901,7 +904,6 @@
(defn handler-users-add [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (auth-notifications jsonobj)
(reset-users-add-state jsonobj)
(.modal (jquery "#modal-users-add"))))
@@ -920,7 +922,7 @@
(defn handler-users-add-submit [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
- (on-menu-clicked "/users")))
+ (render-users-view)))
(defn render-users-add-submit []
(POST "/users/add/submit"
@@ -964,7 +966,6 @@
(defn handler-users-register-form [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (notifications jsonobj)
(reset-users-register-form-state jsonobj)))
(defn render-users-register-form [hash]
@@ -1002,7 +1003,6 @@
(defn handler-users-modify [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
- (auth-notifications jsonobj)
(reset-users-modify-state jsonobj)
(.modal (jquery "#modal-users-modify"))))
@@ -1024,7 +1024,7 @@
(defn handler-users-modify-submit [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
- (on-menu-clicked "/users")))
+ (render-users-view)))
(defn render-users-modify-submit []
(POST "/users/modify/submit"
@@ -1041,7 +1041,7 @@
(defn handler-users-toggle-active [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
- (on-menu-clicked "/users")))
+ (render-users-view)))
(defn render-users-toggle-active [id]
(POST "/users/toggle-active"
@@ -1058,7 +1058,7 @@
(defn handler-users-delete [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
- (on-menu-clicked "/users")))
+ (render-users-view)))
(defn render-users-delete [id]
(DELETE (str "/users/delete/" id)