X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/5f0b37e7a9a8e95dd5a846bfa7896af5875b91f7..d25124264c5fc11612eee640a7ef568ed08d7db6:/src/mewa/slot-presentations.lisp diff --git a/src/mewa/slot-presentations.lisp b/src/mewa/slot-presentations.lisp index cbd2525..1454c53 100644 --- a/src/mewa/slot-presentations.lisp +++ b/src/mewa/slot-presentations.lisp @@ -10,6 +10,26 @@ (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) + ( (length (last-name x)) 0) + (strcat (last-name x) ", ") + " ") + (first-name x)" " (company-name x))) + :as-value (lambda (x) x) + :submit-on-click-p nil))) + (:type-name ajax-foreign-key)) + + +(defmethod shared-initialize :after ((slot ajax-foreign-key-slot-presentation) slots &rest args) + ;; If no search-slots than use the any slots of type string + (unless (search-slots slot) + (setf (search-slots slot) t) + (let ((l (live-search slot))) + (setf (lisp-on-lines::values-generator l) t)))) + + +(defmethod present-slot :around ((slot ajax-foreign-key-slot-presentation) instance) + (setf (foreign-instance slot) + (when (presentation-slot-value slot instance) + (meta-model:explode-foreign-key instance (slot-name slot)))) + (flet ((render () (when (foreign-instance slot)(call-next-method)))) + (if (slot-boundp slot 'place) + (cond + ((editablep slot) + + (