X-Git-Url: https://git.hcoop.net/clinton/lisp-on-lines.git/blobdiff_plain/e5b53af49b8be7c10931bd37eaaec91fab34ea1c..1e936a4d6201432cbb347ee621377523749c6b65:/src/slot-presentations.lisp diff --git a/src/slot-presentations.lisp b/src/slot-presentations.lisp index 6acc8a9..4dcbecc 100644 --- a/src/slot-presentations.lisp +++ b/src/slot-presentations.lisp @@ -43,7 +43,8 @@ :documentation "When nil, the instance is syncronised with the database. 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)) + (show-label-p :accessor show-label-p :initarg :show-label-p :initform t) + (creatablep :accessor creatablep :initarg :creatablep :initform t)) (:documentation "The superclass of all Mewa slot presentations")) ;;;; this has to be in the eval when i would think @@ -212,12 +213,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) @@ -255,7 +251,7 @@ Calendar.setup({ :linkedp t :editablep nil))) (<:as-html string)))) - (<:table + (<:table :cellpadding 10 (<:tr (<:th) ;empty col for (view) link (dolist (s (slots presentation)) @@ -321,26 +317,47 @@ 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) - (