From fb04c0a8c71cd64e3a36cfed59a0224d44de2474 Mon Sep 17 00:00:00 2001 From: drewc Date: Thu, 3 Aug 2006 10:29:28 -0700 Subject: [PATCH] reorganized some source files darcs-hash:20060803172928-39164-f221a842ae3c21e40146032d680db4ea47b19506.gz --- reddit-example.lisp | 2 +- src/attributes/numbers.lisp | 21 +++++--- src/attributes/relational-attributes.lisp | 30 +++++++---- src/attributes/standard-attributes.lisp | 28 ++++++++-- src/defdisplay.lisp | 32 +++++++++-- src/mewa.lisp | 65 +++++++++++------------ src/standard-display.lisp | 26 ++++++++- src/standard-occurence.lisp | 1 - src/standard-wrappers.lisp | 12 +++-- 9 files changed, 149 insertions(+), 68 deletions(-) diff --git a/reddit-example.lisp b/reddit-example.lisp index 47ce250..1efa49d 100644 --- a/reddit-example.lisp +++ b/reddit-example.lisp @@ -2,7 +2,7 @@ (defvar *lol-example-application* (make-instance 'cookie-session-application - :url-prefix "/" + :url-prefix "/lisp-on-lines/" :tal-generator (make-instance 'yaclml:file-system-generator :cachep t :root-directories (list *ucw-tal-root*)) diff --git a/src/attributes/numbers.lisp b/src/attributes/numbers.lisp index 520e621..45d8aaa 100644 --- a/src/attributes/numbers.lisp +++ b/src/attributes/numbers.lisp @@ -45,11 +45,20 @@ (:type-name currency)) -(defdisplay :in-layer editor +(defdisplay + :in-layer t ((currency currency-attribute) object) - (<:as-html "$") + + (<:as-html (format nil "$~$" (or (attribute-value object currency) "")))) + +(defdisplay + :in-layer editor + ((currency currency-attribute) object) + (LET ((value (attribute-value (object currency) currency))) (<:input - :type "text" - :id (id currency) - :name (callback currency) - :value (format nil "~$" (or (attribute-value object currency) "")))) + :NAME + (callback currency) + :VALUE (escape-as-html (strcat (display-value currency value))) + :TYPE + "text")) + ) diff --git a/src/attributes/relational-attributes.lisp b/src/attributes/relational-attributes.lisp index 2b7cdbf..de3fcc2 100644 --- a/src/attributes/relational-attributes.lisp +++ b/src/attributes/relational-attributes.lisp @@ -3,10 +3,21 @@ ;;;; * Relational Attributes +(defvar *parent-relations* nil) + ;;;; ** has-a ;;;; Used for foreign keys, currently only works with clsql. -(defattribute has-a () +(defattribute relational-attribute () + ()) + +(defdisplay :wrap-around ((attribute relational-attribute) object) + (print (cons "parent-r" *parent-relations*)) + (dletf (((value attribute) (attribute-value object attribute))) + (unless (find (value attribute) *parent-relations* :test #'meta-model::generic-equal) + (call-next-method)))) + +(defattribute has-a (relational-attribute) () (:default-properties :has-a nil @@ -27,8 +38,6 @@ (let ((val (slot-value value (find-if (curry #'primary-key-p value) (list-keys value))))) (setf (attribute-value object attribute) val))) - - (define-layered-function find-all-foreign-objects (o a)) (define-layered-method find-all-foreign-objects (object (attribute has-a)) @@ -39,7 +48,7 @@ (val (attribute-value object attribute))) (when val (setf (getf args :type) - 'lol::one-line)) + 'lol::one-line)) (apply #'display* val args))) @@ -55,13 +64,13 @@ :value obj (display* obj :layers '(+ as-string)))))) - ;;;; ** Has-Many attribute (defattribute has-many () () (:default-properties :add-new-label "Add New" + :has-many nil :sort-arguments (list #'< :key #'(lambda (x) (funcall (car (list-keys x)) x)))) (:default-initargs :type 'lol::one-line)) @@ -70,18 +79,17 @@ attribute-value (object (has-many has-many)) (slot-value object (slot-name has-many))) + (defdisplay ((attribute has-many) object) ; ;(