From 8ab94f4677f8d56655a45bb636917429dcddda24 Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Mon, 20 Jul 2026 21:09:54 -0600 Subject: got contact info working --- .../resume/clojurescript/resume/src/core.cljs | 209 ++++++++++++++++++++- lisp/webapps/resume/site.lisp | 29 ++- 2 files changed, 236 insertions(+), 2 deletions(-) (limited to 'lisp/webapps/resume') diff --git a/lisp/webapps/resume/clojurescript/resume/src/core.cljs b/lisp/webapps/resume/clojurescript/resume/src/core.cljs index 34108b7..cde1a89 100644 --- a/lisp/webapps/resume/clojurescript/resume/src/core.cljs +++ b/lisp/webapps/resume/clojurescript/resume/src/core.cljs @@ -149,6 +149,29 @@ (declare on-resumes-delete-clicked) (declare handler-resumes-delete) (declare render-resumes-delete) +(declare template-contactinfo) +(declare handler-contactinfo) +(declare render-contactinfo) +(declare template-contactinfo-view) +(declare handler-contactinfo-view) +(declare render-contactinfo-view) +(declare on-contactinfo-add-clicked) +(declare template-contactinfo-add) +(declare handler-contactinfo-add) +(declare render-contactinfo-add) +(declare on-contactinfo-add-submit-clicked) +(declare handler-contactinfo-add-submit) +(declare render-contactinfo-add-submit) +(declare on-contactinfo-modify-clicked) +(declare template-contactinfo-modify) +(declare handler-contactinfo-modify) +(declare render-contactinfo-modify) +(declare on-contactinfo-modify-submit-clicked) +(declare handler-contactinfo-modify-submit) +(declare render-contactinfo-modify-submit) +(declare on-contactinfo-delete-clicked) +(declare handler-contactinfo-delete) +(declare render-contactinfo-delete) (declare on-menu-clicked) (declare handler-location) (declare goto-location) @@ -1190,6 +1213,189 @@ {:format :raw :handler handler-resumes-delete})) +;; contactinfo + +(hiccups/defhtml template-contactinfo [jsonobj] + [:h3 {:style "text-align: center"} (get jsonobj "title")] + [:div {:id "content"}] + [:div {:id "modify" + :class "modal fade" + :role "dialog" + :tabindex "-1"} + [:div {:class "modal-dialog modal-lg"} + [:div {:class "modal-content"} + [:div {:class "modal-header"} + [:h5 [:span {:id "modify-title"}]] + [:button {:type "button" + :class "close" + :data-dismiss "modal"} + "×"]] + [:div {:id "modify-body" + :class "modal-body" + :style "height: 450px;"}] + [:div {:class "modal-footer"} + [:button {:type "submit" + :class "btn btn-danger btn-default" + :data-dismiss "modal"} + [:span {:class "glyphicon glyphicon-remove"}] + "Cancel"]]]]]) + +(defn handler-contactinfo [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (notifications jsonobj) + (dommy/set-html! (dommy/sel1 :#body) (template-contactinfo jsonobj)) + (render-contactinfo-view))) + +(defn render-contactinfo [] + (GET "/resumes/contactinfo" {:handler handler-contactinfo})) + +;; contactinfo-view + +(hiccups/defhtml template-contactinfo-view [jsonobj] + [:div {:style "text-align: right"} + [:img {:src "/static/images/add.png" + :style "cursor:pointer; cursor:hand" + :onclick (str (namespace ::x) ".on_contactinfo_add_clicked()")}]] + [:table {:class "table table-striped table-hover table-sm"} + [:thead + [:tr + [:th {:scope "col"} "Address"] + [:th {:scope "col"} "City"] + [:th {:scope "col"} "State"] + [:th {:scope "col"} "Phone"] + [:th {:scope "col"} "Email"] + [:th {:scope "col"} "VISA Status"] + [:th {:scope "col"} "Mod"] + [:th {:scope "col"} "Del"]]] + [:tbody + (for [contactinfo (get jsonobj "contactinfos")] + [:tr + [:td (get contactinfo "address")] + [:td (get contactinfo "city")] + [:td (get contactinfo "state_abbr")] + [:td (get contactinfo "phone")] + [:td (get contactinfo "email")] + [:td (get contactinfo "visastatus")] + [:td {:width "30"} + [:img {:src "/static/images/modify.png" + :onclick (str (namespace ::x) ".on_contactinfo_modify_clicked(" (get contactinfo "id") ")")}]] + [:td {:width "30"} + [:img {:src "/static/images/delete.png" + :onclick (str (namespace ::x) ".on_contactinfo_delete_clicked(" (get contactinfo "id") ", '" (str (get contactinfo "address") ", " (get contactinfo "city") " " (get contactinfo "state_abbr")) "')")}]]])]]) + +(defn handler-contactinfo-view [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (dommy/set-html! (dommy/sel1 :#content) (template-contactinfo-view jsonobj)))) + +(defn render-contactinfo-view [] + (GET "/resumes/contactinfo/view" {:handler handler-contactinfo-view})) + +;; contactinfo-add + +(defn on-contactinfo-add-clicked [] + (render-contactinfo-add)) + +(hiccups/defhtml template-contactinfo-add [jsonobj] + (ck-form/template-generic-form (get jsonobj "form") (namespace ::x))) + +(defn handler-contactinfo-add [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (dommy/set-html! (dommy/sel1 :#modify-title) (get jsonobj "title")) + (dommy/set-html! (dommy/sel1 :#modify-body) (template-contactinfo-add jsonobj)) + (.modal (jquery "#modify")))) + +(defn render-contactinfo-add [] + (POST "/resumes/contactinfo/add" {:handler handler-contactinfo-add})) + +;; contactinfo-add-submit + +(defn on-contactinfo-add-submit-clicked [] + (when (-> (jquery "#contactinfo-add-form") + (.get "0") + (.checkValidity)) + (.modal (jquery "#modify") "hide") + (render-contactinfo-add-submit))) + +(defn handler-contactinfo-add-submit [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (on-menu-clicked "/resumes/contactinfo"))) + +(defn render-contactinfo-add-submit [] + (POST "/resumes/contactinfo/add/submit" + {:format :raw + :params {:address (dommy/value (dommy/sel1 :#address)) + :city (dommy/value (dommy/sel1 :#city)) + :state_id (dommy/value (dommy/sel1 :#state_id)) + :phone (dommy/value (dommy/sel1 :#phone)) + :email (dommy/value (dommy/sel1 :#email)) + :visastatus_id (dommy/value (dommy/sel1 :#visastatus_id))} + :handler handler-contactinfo-add-submit})) + +;; contactinfo-modify + +(defn on-contactinfo-modify-clicked [id] + (render-contactinfo-modify id)) + +(hiccups/defhtml template-contactinfo-modify [jsonobj] + (ck-form/template-generic-form (get jsonobj "form") (namespace ::x))) + +(defn handler-contactinfo-modify [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (dommy/set-html! (dommy/sel1 :#modify-title) (get jsonobj "title")) + (dommy/set-html! (dommy/sel1 :#modify-body) (template-contactinfo-modify jsonobj)) + (.modal (jquery "#modify")))) + +(defn render-contactinfo-modify [id] + (POST "/resumes/contactinfo/modify" + {:format :raw + :params {:id id} + :handler handler-contactinfo-modify})) + +;; contactinfo-modify-submit + +(defn on-contactinfo-modify-submit-clicked [] + (when (-> (jquery "#contactinfo-modify-form") + (.get "0") + (.checkValidity)) + (.modal (jquery "#modify") "hide") + (render-contactinfo-modify-submit))) + +(defn handler-contactinfo-modify-submit [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (on-menu-clicked "/resumes/contactinfo"))) + +(defn render-contactinfo-modify-submit [] + (POST "/resumes/contactinfo/modify/submit" + {:format :raw + :params {:id (dommy/value (dommy/sel1 :#id)) + :address (dommy/value (dommy/sel1 :#address)) + :city (dommy/value (dommy/sel1 :#city)) + :state_id (dommy/value (dommy/sel1 :#state_id)) + :phone (dommy/value (dommy/sel1 :#phone)) + :email (dommy/value (dommy/sel1 :#email)) + :visastatus_id (dommy/value (dommy/sel1 :#visastatus_id))} + :handler handler-contactinfo-modify-submit})) + +;; contactinfo-delete + +(defn on-contactinfo-delete-clicked [id name] + (when (js/confirm (str "Are you sure you want to delete " name "? This action cannot be undone.")) + (render-contactinfo-delete id))) + +(defn handler-contactinfo-delete [response] + (let [jsonobj (js->clj (js/JSON.parse response))] + (auth-notifications jsonobj) + (on-menu-clicked "/resumes/contactinfo"))) + +(defn render-contactinfo-delete [id] + (DELETE (str "/resumes/contactinfo/delete/" id) + {:format :raw + :handler handler-contactinfo-delete})) + ;; location (defn on-menu-clicked [handler] @@ -1203,7 +1409,8 @@ (= handler "/contact-us") (render-contact-us) (= handler "/messages") (render-messages) (= handler "/users") (render-users) - (= handler "/resumes") (render-resumes))) + (= handler "/resumes") (render-resumes) + (= handler "/resumes/contactinfo") (render-contactinfo))) (defn handler-location [response] (let [jsonobj (js->clj (js/JSON.parse response))] diff --git a/lisp/webapps/resume/site.lisp b/lisp/webapps/resume/site.lisp index 80bdbe1..2142c9c 100644 --- a/lisp/webapps/resume/site.lisp +++ b/lisp/webapps/resume/site.lisp @@ -152,6 +152,27 @@ (defmacro .resumes-delete () `(resumes-delete-json id)) +(defmacro .contactinfo () + `(contactinfo-json)) + +(defmacro .contactinfo-view () + `(contactinfo-view-json)) + +(defmacro .contactinfo-add () + `(contactinfo-add-json)) + +(defmacro .contactinfo-add-submit () + `(contactinfo-add-submit-json address city state_id phone email visastatus_id)) + +(defmacro .contactinfo-modify () + `(contactinfo-modify-json id)) + +(defmacro .contactinfo-modify-submit () + `(contactinfo-modify-submit-json id address city state_id phone email visastatus_id)) + +(defmacro .contactinfo-delete () + `(contactinfo-delete-json id)) + (define-endpoint ("/" :method :get) () .base) (define-endpoint ("/location" :method :post) (&post (location :parameter-type 'string)) .location) (define-endpoint ("/home" :method :get) () .home-get) @@ -189,7 +210,6 @@ (define-endpoint ("/users/modify/submit" :method :post) (&post (id :parameter-type 'integer) (role_groups :parameter-type 'string) (username :parameter-type 'string) (first_name :parameter-type 'string) (last_name :parameter-type 'string) (email :parameter-type 'string) (phone :parameter-type 'string)) .users-modify-submit) (define-endpoint ("/users/toggle-active" :method :post) (&post (id :parameter-type 'integer)) .users-toggle-active) (define-endpoint ("/users/delete/:id" :method :delete) (&path (id 'integer)) .users-delete) - (define-endpoint ("/resumes" :method :get) () .resumes) (define-endpoint ("/resumes/view" :method :get) () .resumes-view) (define-endpoint ("/resumes/add" :method :post) () .resumes-add) @@ -197,3 +217,10 @@ (define-endpoint ("/resumes/modify" :method :post) (&post (id :parameter-type 'integer)) .resumes-modify) (define-endpoint ("/resumes/modify/submit" :method :post) (&post (id :parameter-type 'integer) (name :parameter-type 'string)) .resumes-modify-submit) (define-endpoint ("/resumes/delete/:id" :method :delete) (&path (id 'integer)) .resumes-delete) +(define-endpoint ("/resumes/contactinfo" :method :get) () .contactinfo) +(define-endpoint ("/resumes/contactinfo/view" :method :get) () .contactinfo-view) +(define-endpoint ("/resumes/contactinfo/add" :method :post) () .contactinfo-add) +(define-endpoint ("/resumes/contactinfo/add/submit" :method :post) (&post (address :parameter-type 'string) (city :parameter-type 'string) (state_id :parameter-type 'integer) (phone :parameter-type 'string) (email :parameter-type 'string) (visastatus_id :parameter-type 'integer)) .contactinfo-add-submit) +(define-endpoint ("/resumes/contactinfo/modify" :method :post) (&post (id :parameter-type 'integer)) .contactinfo-modify) +(define-endpoint ("/resumes/contactinfo/modify/submit" :method :post) (&post (id :parameter-type 'integer) (address :parameter-type 'string) (city :parameter-type 'string) (state_id :parameter-type 'integer) (phone :parameter-type 'string) (email :parameter-type 'string) (visastatus_id :parameter-type 'integer)) .contactinfo-modify-submit) +(define-endpoint ("/resumes/contactinfo/delete/:id" :method :delete) (&path (id 'integer)) .contactinfo-delete) -- cgit v1.3