X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/9f2bdea87849c3feab566d6cd49c67bb31cc1f36..c1869452e310290dd53fe066cf329b37e5a89217:/src/slot-presentations.lisp diff --git a/src/slot-presentations.lisp b/src/slot-presentations.lisp index 19927f9..b90128e 100644 --- a/src/slot-presentations.lisp +++ b/src/slot-presentations.lisp @@ -29,7 +29,7 @@ :cols (columns slot)) (if (escape-html-p slot) (<:as-html (presentation-slot-value slot instance)) - (<:as-is (presentation-slot-value slot instance)))))) + (<:as-is (presentation-slot-value slot instance))))) (defcomponent mewa-slot-presentation () @@ -212,12 +212,7 @@ Calendar.setup({ (defmethod find-foreign-instances ((slot foreign-key-slot-presentation)) (clsql:select (class-name (class-of (meta-model:explode-foreign-key (instance slot) (slot-name slot)))))) -(defslot-presentation has-a-slot-presentation (foreign-key-slot-presentation) - () - (:type-name has-a)) -(defmethod present-slot ((slot has-a-slot-presentation) instance) - t) ;;;; HAS MANY (defslot-presentation has-many-slot-presentation (mewa-relation-slot-presentation) @@ -321,26 +316,46 @@ Calendar.setup({ for i from 0 upto (number-to-display slot) collect (car cons)))) -(defslot-presentation has-a-slot-presentation (one-of-presentation) - ((key :initarg :key :accessor key)) + +;;;; * Has-a +(defslot-presentation has-a-slot-presentation (mewa-relation-slot-presentation) + ((allow-nil-p :accessor allow-nil-p :initarg :allow-nil-p :initform t) + (attributes :accessor attributes :initarg :attributes :initform nil)) (:type-name has-a)) -(defmethod get-foreign-slot-value ((slot has-a-slot-presentation) (object t) (slot-name t)) - (slot-value object slot-name)) +(defmethod find-foreign-slot-value ((slot has-a-slot-presentation) (object t)) + (multiple-value-bind (c s) + (meta-model:explode-foreign-key (instance (ucw::parent slot)) (slot-name slot)) + (slot-value object s))) + +(defmethod get-foreign-instances ((slot mewa-relation-slot-presentation) instance) + (clsql:select (class-name (class-of + (meta-model:explode-foreign-key instance (slot-name slot)))) + :flatp t)) (defmethod present-slot ((slot has-a-slot-presentation) instance) - (<:as-html (presentation-slot-value slot instance)) +; (<:as-html (presentation-slot-value slot instance)) (if (editablep slot) - (