X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/0386c736fe19db9f72a9d12728f5707cf570778f..91b9f259d38073a9847ede172cdda1218f2c35fb:/src/slot-presentations/date.lisp diff --git a/src/slot-presentations/date.lisp b/src/slot-presentations/date.lisp deleted file mode 100644 index 973f8fe..0000000 --- a/src/slot-presentations/date.lisp +++ /dev/null @@ -1,246 +0,0 @@ -(in-package :lol) - -(defclass form-element (widget-component) - ((client-value :accessor client-value :initform "" - :initarg :client-value - :documentation "Whetever the client's browse sent for this form element." - :backtrack t) - (lisp-value :accessor lisp-value :initform +uninitialized+ - :initarg :lisp-value - :documentation "The current lisp object in this form element." - :backtrack t)) - (:metaclass standard-component-class) - (:documentation "A single value in a form. - -A form-element is, simply put, a wrapper for a value in an html -form.")) - -;;;; Expiry date picker - -(defslot-presentation date-slot-presentation (clsql-wall-time-slot-presentation) - ((date-field :component (my-date-field :year-min 2005 :year-max 2015) - :accessor date-field)) - (:type-name date)) - -(defmethod update-value ((slot date-slot-presentation)) - (multiple-value-bind (year month day) - (time-ymd (presentation-slot-value slot (instance (ucw::parent slot)))) - (multiple-value-bind (new-year new-month new-day) - (time-ymd) - (if (remove nil (map 'list #'(lambda (old new) - (unless (equal (car old) (car new)) - t)) - (list year month day) - (list new-year new-month new-day))) - (setf (presentation-slot-value slot (instance (ucw::parent slot))) - (make-time t)))))) - -(defmethod present-slot ((slot date-slot-presentation) instance) - (let ((date (slot-value instance (slot-name slot)))) - ;; Default values - (when (and (not date) (default-to-now-p slot)) - (setf date (clsql:get-time) - (presentation-slot-value slot instance) date)) - ;;simple viewer - (if (and date (not (editablep slot))) - (<:as-html date)) - ;; editor - (when (editablep slot) - (with-slots ((m month) (y year)) - (date-field slot) - - (multiple-value-bind (year month) (time-ymd date) - (setf (lisp-value m) month - (lisp-value y) year) - (