fixes for ucw+interpreter
[clinton/lisp-on-lines.git] / src / mewa / slot-presentations.lisp
index 4a746d3..4254227 100644 (file)
                     (multiple-value-funcall->list #',(car form) ,@(cdr form))
                     ,@body))
 
+
+;;;; ** Textarea Slot Presentation
+;;;;  This should really be in UCW.
+
+(defslot-presentation text-slot-presentation ()
+  ((rows :initarg :rows :accessor rows :initform nil)
+   (columns :initarg :columns :accessor columns :initform nil)
+   (html-contentp :initarg :escape-html-p :accessor escape-html-p :initform nil))
+  (:type-name text))
+
+(defmethod present-slot ((slot text-slot-presentation) instance)
+  (if (editablep slot)
+      (<ucw:textarea :accessor (presentation-slot-value slot instance)
+                    :rows (rows slot)
+                    :cols (columns slot))
+      (if (escape-html-p slot)
+         (<:as-is (presentation-slot-value slot instance))
+         (<:as-html (presentation-slot-value slot instance)))))
+
+
 (defcomponent mewa-slot-presentation ()
   ((slot-name :accessor slot-name 
              :initarg :slot-name 
@@ -20,7 +40,8 @@
                     :initform nil
                     :documentation 
                     "When nil, the instance is syncronised with the database. 
-When T, only the default value for primary keys and the joins are updated."))
+When T, only the default value for primary keys and the joins are updated.")
+   (show-label-p :accessor show-label-p :initarg :show-label-p :initform t))
   (:documentation "The superclass of all Mewa slot presentations"))
 
 ;;;; this has to be in the eval when i would think
@@ -46,7 +67,6 @@ When T, only the default value for primary keys and the joins are updated."))
   integer
   currency)
 
-
 (defslot-presentation clsql-wall-time-slot-presentation (mewa-relation-slot-presentation)
        ()
        (:type-name clsql-sys:wall-time))
@@ -93,7 +113,7 @@ When T, only the default value for primary keys and the joins are updated."))
       (meta-model:explode-foreign-key instance (slot-name slot))
     (let ((new-instance
             (call-component 
-             (parent slot) 
+             (parent slot)
              (make-instance (or (cadr (mewa:find-attribute finstance :presentation-search))
                                 'mewa::mewa-presentation-search)
                             :search-presentation
@@ -186,7 +206,6 @@ When T, only the default value for primary keys and the joins are updated."))
   ((add-new-label :accessor add-new-label :initarg :add-new-label :initform "Add New"))
   (:type-name has-many))
 
-
 (defaction add-to-has-many ((slot has-many-slot-presentation) instance)
   ;; if the instance is not stored we must make sure to mark it stored now!
   (unless (mewa::instance-is-stored-p instance)
@@ -285,3 +304,10 @@ When T, only the default value for primary keys and the joins are updated."))
            (setf (instance (presentation slot)) (presentation-slot-value slot instance))
            (present (presentation slot)))
          (<:as-html "--"))))
+
+
+
+
+
+
+