diff options
| author | ckonstanski <kostcarl@isu.edu> | 2026-07-27 22:09:55 -0600 |
|---|---|---|
| committer | ckonstanski <kostcarl@isu.edu> | 2026-07-27 22:09:55 -0600 |
| commit | daa7e0343da2d1fd78faefdde2ac8c1796b52c30 (patch) | |
| tree | c48c14645ac448ad7e622968a0b4f5a87be56217 /lisp/service/resume-service.lisp | |
| parent | 85fdf5db522a3e3e841fef4c3dd5ff3a570739ca (diff) | |
stuff
Diffstat (limited to 'lisp/service/resume-service.lisp')
| -rw-r--r-- | lisp/service/resume-service.lisp | 71 |
1 files changed, 51 insertions, 20 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))))) |
