diff options
| author | ckonstanski <ckonstanski@pippiandcarlos.com> | 2020-12-21 08:59:56 -0700 |
|---|---|---|
| committer | ckonstanski <ckonstanski@pippiandcarlos.com> | 2020-12-21 08:59:56 -0700 |
| commit | 0ed1cba1b39daaf8eef693233f081b455c88dece (patch) | |
| tree | 0322ba1444ef724d4613e3c26ed2679e71bf1882 /service/generic-form.lisp | |
| parent | bac1df6134eee78b79810d13c71a2b22b4739a12 (diff) | |
stuff
Diffstat (limited to 'service/generic-form.lisp')
| -rw-r--r-- | service/generic-form.lisp | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/service/generic-form.lisp b/service/generic-form.lisp index 1fb9867..e48d653 100644 --- a/service/generic-form.lisp +++ b/service/generic-form.lisp @@ -3,9 +3,7 @@ (in-package #:ldapadmin) -;; ========================================================================== ;; - -(defclass generic-form (rest-service) +(defclass generic-form (base-service) ((name :initarg :name :initform nil :accessor name) @@ -15,6 +13,9 @@ (action :initarg :action :initform nil :accessor action) + (required-p :initarg :required-p + :initform nil + :accessor required-p) (form-fields :initarg :form-fields :initform nil :accessor form-fields)) @@ -27,19 +28,60 @@ (label :initarg :label :initform nil :accessor label) + (value :initarg :value + :initform nil + :accessor value) + (checked :initarg :checked + :initform nil + :accessor checked) (field-type :initarg :field-type :initform nil - :accessor field-type)) + :accessor field-type) + (required :initarg :required + :initform nil + :accessor required) + (dismiss :initarg :dismiss + :initform nil + :accessor dismiss) + (options :initarg :options + :initform nil + :accessor options) + (onclick :initarg :onclick + :initform nil + :accessor onclick) + (onchange :initarg :onchange + :initform nil + :accessor onchange)) + (:documentation "")) + +(defclass option (base-service) + ((label :initarg :label + :initform nil + :accessor label) + (value :initarg :value + :initform nil + :accessor value)) (:documentation "")) -(defmacro define-generic-form-constructor ((form-class name action) fields) - `(defmethod initialize-instance :after ((,form-class ,form-class) &key) - (setf (name ,form-class) ,name) - (setf (action ,form-class) ,action) - (setf (form-fields ,form-class) - (mapcar (lambda (form) - (make-instance 'form-field - :name (getf form :name) - :label (getf form :label) - :field-type (getf form :field-type))) - ,fields)))) +(defun make-form (name action required-p fields) + (make-instance 'generic-form + :name name + :action action + :required-p required-p + :form-fields (mapcar (lambda (field) + (make-instance 'form-field + :name (getf field :name) + :label (getf field :label) + :value (getf field :value) + :checked (getf field :checked) + :field-type (getf field :field-type) + :required (getf field :required) + :dismiss (getf field :dismiss) + :options (mapcar (lambda (option) + (make-instance 'option + :label (getf option :label) + :value (getf option :value))) + (getf field :options)) + :onclick (getf field :onclick) + :onchange (getf field :onchange))) + fields))) |
