summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/service/resume-service.lisp71
-rw-r--r--lisp/webapps/resume/clojurescript/resume/src/core.cljs13
2 files changed, 60 insertions, 24 deletions
diff --git a/lisp/service/resume-service.lisp b/lisp/service/resume-service.lisp
index abbb005..af85714 100644
--- a/lisp/service/resume-service.lisp
+++ b/lisp/service/resume-service.lisp
@@ -697,7 +697,7 @@
;; (progn
;; (delete-record resume-pkg ,,component-s)
;; (setf (session-value :message) (format nil "~a deleted successfully." ,,component)))
-;; (setf (session-value :errormsg) (format nil "Error: could not delete ~a: not found." ,,component)))))))
+;; (setf (session-value :errormsg) (format nil "Error: could not delete ~a: not found." ,,component)))))
(defmacro define-resume-component ((component-s rest-args input-add-fields input-modify-fields))
"`component-s' is a symbol that matches the component's record object
@@ -709,22 +709,19 @@ forms. In the form like this example: ((id :parameter-type 'integer))
`input-add-fields' and `input-modify-fields' are lists of generic form
fields that get inserted into the add and modify forms."
- (let* (
- (component (symbol-name component-s))
+ (let* ((component (symbol-name component-s))
(component-lcase (string-downcase component))
(components-s (intern (format nil "~aS" component)))
- ;; (components-k (intern (format nil "~aS" component) 'keyword))
(arg-names (loop for arg in rest-args collect (car arg)))
(func-root-s (intern (format nil "~a-JSON" component)))
(func-view-s (intern (format nil "~a-VIEW-JSON" component)))
(func-add-s (intern (format nil "~a-ADD-JSON" component)))
(func-add-submit-s (intern (format nil "~a-ADD-SUBMIT-JSON" component)))
- ;; (func-modify-s (intern (format nil "~a-MODIFY-JSON" component)))
- ;; (func-modify-submit-s (intern (format nil "~a-MODIFY-SUBMIT-JSON" component)))
- ;; (func-delete-s (intern (format nil "~a-DELETE-JSON" component)))
+ (func-modify-s (intern (format nil "~a-MODIFY-JSON" component)))
+ (func-modify-submit-s (intern (format nil "~a-MODIFY-SUBMIT-JSON" component)))
+ (func-delete-s (intern (format nil "~a-DELETE-JSON" component)))
(form-add (format nil "~a-add-form" component-lcase))
- ;; (form-modify (format nil "~a-modify-form" component-lcase))
- )
+ (form-modify (format nil "~a-modify-form" component-lcase)))
`(progn
(defun ,func-root-s ()
(with-auth (instance resume-service "resume-view")
@@ -771,11 +768,45 @@ fields that get inserted into the add and modify forms."
(error (e)
(setf (session-value :errormsg) (format nil "Error creating ~a. ~a" ,component e)))))))
- ;; (defun ,func-modify-s ()
- ;; (,func-modify-s id))
+ (defun ,func-modify-s (id)
+ (with-auth (instance resume-component/modify-service "resume-modify")
+ (setf (title instance) (format nil "~a - Modify" ,component))
+ (with-resume-database
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (,component-s (get-record resume-pkg (make-instance ',component-s
+ :id id
+ :user_id (id user)
+ :*table "resume.contactinfo_v"))))
+ (if ,component-s
+ (setf (form instance) (make-form ,form-modify
+ nil
+ t
+ ,input-modify-fields))
+ (setf (session-value :errormsg) (format nil "Error: could not modify ~a. Not found." ,component)))))))
- ;; (defun ,func-modify-submit-s ()
- ;; (,func-modify-submit-s ,@(append '(id) arg-names)))
+ (defun ,func-modify-submit-s (,@(append '(id) arg-names))
+ (declare (special ,@(append '(id) arg-names)))
+ (with-auth (instance resume-component/modify-service "resume-modify")
+ (setf (title instance) (format nil "~a - Modify" ,component))
+ (with-resume-database
+ (handler-case
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (,component-s (get-record resume-pkg (make-instance ',component-s
+ :id id
+ :user_id (id user)
+ :*table "resume.contactinfo_v"))))
+ (if ,component-s
+ (let ((new-component (make-instance ',component-s)))
+ (loop for param in (sb-introspect:function-lambda-list #',func-modify-submit-s)
+ do (setf (slot-value new-component param) (symbol-value param)))
+ (setf (user_id new-component) (id user))
+ (update-record-no-nulls resume-pkg new-component)
+ (setf (session-value :message) (format nil "~a modified successfully." ,component)))
+ (error (format nil "~a error" ,component))))
+ (error (e)
+ (setf (session-value :errormsg) (format nil "Error modifying ~a. ~a" ,component e)))))))
;; (defun ,func-delete-s ()
;; (,func-delete-s id))
@@ -784,8 +815,8 @@ fields that get inserted into the add and modify forms."
(define-endpoint (,(format nil "/resume/~a/view" component-lcase) :method :get) () ,func-view-s)
(define-endpoint (,(format nil "/resume/~a/add" component-lcase) :method :post) () ,func-add-s)
(define-endpoint (,(format nil "/resume/~a/add/submit" component-lcase) :method :post) (&post ,@rest-args) ,func-add-submit-s ,@arg-names)
- ;; (define-endpoint (,(format nil "/resume/~a/modify" component-lcase) :method :post) (&post (id :parameter-type 'integer)) ,func-modify-s)
- ;; (define-endpoint (,(format nil "/resume/~a/modify/submit" component-lcase) :method :post) (&post (id :parameter-type 'integer) ,@rest-args) ,func-modify-submit-s)
+ (define-endpoint (,(format nil "/resume/~a/modify" component-lcase) :method :post) (&post (id :parameter-type 'integer)) ,func-modify-s id)
+ (define-endpoint (,(format nil "/resume/~a/modify/submit" component-lcase) :method :post) (&post (id :parameter-type 'integer) ,@rest-args) ,func-modify-submit-s ,@(append '(id) arg-names))
;; (define-endpoint (,(format nil "/resume/~a/delete/:id" component-lcase) :method :delete) (&path (id 'integer)) ,func-delete-s)
)))
@@ -799,12 +830,12 @@ fields that get inserted into the add and modify forms."
(:name "url" :label "URL" :field-type "text")
(:name "visastatus_id" :label "VISA Status" :field-type "select" :options ,(visastatus-options (get-records resume-pkg (make-instance 'visastatus) "visastatus asc")) :required "required")
(:label "Add CONTACTINFO" :field-type "button" :onclick "on_contactinfo_add_submit_clicked()"))
- `((:name "address" :label "Address" :field-type "text" :value ,(address contactinfo) :required "required")
+ `((:name "id" :field-type "hidden" :value ,(id contactinfo) :required "required")
+ (:name "address" :label "Address" :field-type "text" :value ,(address contactinfo) :required "required")
(:name "city" :label "City" :field-type "text" :value ,(city contactinfo) :required "required")
- ;;(:name "state_id" :label "State" :field-type "select" :value ,(state_id contactinfo) :options ,(state-options states) :required "required")
+ (:name "state_id" :label "State" :field-type "select" :value ,(state_id contactinfo) :options ,(state-options (get-records resume-pkg (make-instance 'states) "abbr asc")) :required "required")
(:name "phone" :label "Phone" :field-type "text" :value ,(phone contactinfo) :required "required")
(:name "email" :label "Email" :field-type "text" :value ,(email contactinfo) :required "required")
(:name "url" :label "URL" :field-type "text" :value ,(url contactinfo))
- ;;(:name "visastatus_id" :label "VISA Status" :field-type "select" :value (visastatus_id contactinfo-v) :options (visastatus-options visastatuses) :required "required"))
- )))
-
+ (:name "visastatus_id" :label "VISA Status" :field-type "select" :value (visastatus_id contactinfo) :options ,(visastatus-options (get-records resume-pkg (make-instance 'visastatus) "visastatus asc")) :required "required")
+ (:label "Modify CONTACTINFO" :field-type "button" :onclick ,(format nil "on_contactinfo_modify_submit_clicked(~a)" id)))))
diff --git a/lisp/webapps/resume/clojurescript/resume/src/core.cljs b/lisp/webapps/resume/clojurescript/resume/src/core.cljs
index 0e9d9f8..d82358f 100644
--- a/lisp/webapps/resume/clojurescript/resume/src/core.cljs
+++ b/lisp/webapps/resume/clojurescript/resume/src/core.cljs
@@ -1333,6 +1333,7 @@
[:th {:scope "col"} "State"]
[:th {:scope "col"} "Phone"]
[:th {:scope "col"} "Email"]
+ [:th {:scope "col"} "URL"]
[:th {:scope "col"} "VISA Status"]
[:th {:scope "col"} "Mod"]
[:th {:scope "col"} "Del"]]]
@@ -1344,6 +1345,7 @@
[:td (get contactinfo "state_abbr")]
[:td (get contactinfo "phone")]
[:td (get contactinfo "email")]
+ [:td (get contactinfo "url")]
[:td (get contactinfo "visastatus")]
[:td {:width "30"}
[:img {:src "/static/images/modify.png"
@@ -1399,6 +1401,7 @@
:state_id (dommy/value (dommy/sel1 :#state_id))
:phone (dommy/value (dommy/sel1 :#phone))
:email (dommy/value (dommy/sel1 :#email))
+ :url (dommy/value (dommy/sel1 :#url))
:visastatus_id (dommy/value (dommy/sel1 :#visastatus_id))}
:handler handler-contactinfo-add-submit}))
@@ -1425,27 +1428,29 @@
;; contactinfo-modify-submit
-(defn on-contactinfo-modify-submit-clicked []
+(defn on-contactinfo-modify-submit-clicked [id]
(when (-> (jquery "#contactinfo-modify-form")
(.get "0")
(.checkValidity))
(.modal (jquery "#modify") "hide")
- (render-contactinfo-modify-submit)))
+ (js/alert id)
+ (render-contactinfo-modify-submit id)))
(defn handler-contactinfo-modify-submit [response]
(let [jsonobj (js->clj (js/JSON.parse response))]
(auth-notifications jsonobj)
(on-menu-clicked "/resume/contactinfo")))
-(defn render-contactinfo-modify-submit []
+(defn render-contactinfo-modify-submit [id]
(POST "/resume/contactinfo/modify/submit"
{:format :raw
- :params {:id (dommy/value (dommy/sel1 :#id))
+ :params {:id 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))
+ :url (dommy/value (dommy/sel1 :#url))
:visastatus_id (dommy/value (dommy/sel1 :#visastatus_id))}
:handler handler-contactinfo-modify-submit}))