From: Drew Crampsie Date: Tue, 8 Nov 2005 07:34:56 +0000 (-0800) Subject: added a default option to wall-time presentation. X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/commitdiff_plain/db4fe3430ee9cc4190222e915e32d809928f64cb?hp=adfb39839d6b54a4182de18e658061060ce91ba1 added a default option to wall-time presentation. darcs-hash:20051108073456-5417e-47d05a873ae4c6a37f14167ab76697dbc08da945.gz --- diff --git a/src/slot-presentations.lisp b/src/slot-presentations.lisp index ceb27ab..d7e874d 100644 --- a/src/slot-presentations.lisp +++ b/src/slot-presentations.lisp @@ -84,7 +84,8 @@ When T, only the default value for primary keys and the joins are updated.") (defslot-presentation clsql-wall-time-slot-presentation (mewa-relation-slot-presentation) ((input-id :accessor input-id :initform (arnesi:random-string 10 arnesi:+ascii-alphabet+)) - (trigger-id :accessor trigger-id :initform (arnesi:random-string 10 arnesi:+ascii-alphabet+))) + (trigger-id :accessor trigger-id :initform (arnesi:random-string 10 arnesi:+ascii-alphabet+)) + (default-to-now-p :accessor default-to-now-p :initarg :default-to-now-p :initform nil)) (:type-name clsql-sys:wall-time)) (defmethod presentation-slot-value ((slot clsql-wall-time-slot-presentation) instance) @@ -99,15 +100,20 @@ When T, only the default value for primary keys and the joins are updated.") (unless (or (eql old-time new-time) (when (and new-time old-time) (equal :equal (clsql:time-compare new-time old-time)))) - (setf (presentation-slot-value slot instance) new-time )))) + (setf (presentation-slot-value slot instance) new-time)))) (defmethod label :around ((slot clsql-wall-time-slot-presentation)) (concatenate 'string (call-next-method) " (m/d/y)")) (defmethod present-slot ((slot clsql-wall-time-slot-presentation) instance) (let ((date (presentation-slot-value slot instance))) + ;; Default values + (when (and (not date) (default-to-now-p slot)) + (setf (presentation-slot-value slot instance) (clsql:get-time))) + ;;simple viewer (if (and date (not (editablep slot))) (<:as-html date)) + ;; editor (when (editablep slot) (