From c2f77f4296c6b13eeb86067a772192b70577bca6 Mon Sep 17 00:00:00 2001 From: ckonstanski Date: Sat, 20 Jan 2018 22:07:54 -0700 Subject: initial commit --- service/generic-form.lisp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 service/generic-form.lisp (limited to 'service/generic-form.lisp') diff --git a/service/generic-form.lisp b/service/generic-form.lisp new file mode 100644 index 0000000..1fb9867 --- /dev/null +++ b/service/generic-form.lisp @@ -0,0 +1,45 @@ +;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +(declaim (optimize (speed 0) (safety 3) (debug 3))) + +(in-package #:ldapadmin) + +;; ========================================================================== ;; + +(defclass generic-form (rest-service) + ((name :initarg :name + :initform nil + :accessor name) + (http-method :initarg :http-method + :initform "POST" + :accessor http-method) + (action :initarg :action + :initform nil + :accessor action) + (form-fields :initarg :form-fields + :initform nil + :accessor form-fields)) + (:documentation "")) + +(defclass form-field (base-service) + ((name :initarg :name + :initform nil + :accessor name) + (label :initarg :label + :initform nil + :accessor label) + (field-type :initarg :field-type + :initform nil + :accessor field-type)) + (: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)))) -- cgit v1.3