X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/e5b53af49b8be7c10931bd37eaaec91fab34ea1c..63c06c541289a6669a5d03c6076b71ff37e4b49d:/src/slot-presentations.lisp?ds=sidebyside diff --git a/src/slot-presentations.lisp b/src/slot-presentations.lisp index 6acc8a9..95e8c8e 100644 --- a/src/slot-presentations.lisp +++ b/src/slot-presentations.lisp @@ -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) - (