From 5f0b37e7a9a8e95dd5a846bfa7896af5875b91f7 Mon Sep 17 00:00:00 2001 From: Drew Crampsie Date: Mon, 1 Aug 2005 16:45:25 -0700 Subject: [PATCH] Did some work on searching, changed object presentation to specialise on each row, and added an inline-slot-presentation taht used this feature darcs-hash:20050801234525-5417e-1d7ffc7570525650141333ca2c7ffd3d7a373db7.gz --- src/mewa/presentations.lisp | 79 +++++++++++++++++++++++++++++--- src/mewa/slot-presentations.lisp | 18 +++++++- 2 files changed, 89 insertions(+), 8 deletions(-) diff --git a/src/mewa/presentations.lisp b/src/mewa/presentations.lisp index 62e93d1..15f0e16 100644 --- a/src/mewa/presentations.lisp +++ b/src/mewa/presentations.lisp @@ -15,6 +15,18 @@ (defcomponent mewa-object-presentation (mewa ucw:object-presentation) ((ucw::instance :accessor instance :initarg :instance :initform nil))) +(defmethod present ((pres mewa-object-presentation)) + (<:table :class (css-class pres) + (dolist (slot (slots pres)) + (<:tr :class "presentation-slot-row" + (present-slot-as-row pres slot)))) + (render-options pres (instance pres))) + +(defmethod present-slot-as-row ((pres mewa-object-presentation) (slot ucw::slot-presentation)) + (<:td :class "presentation-slot-label" (<:as-html (label slot))) + (<:td :class "presentation-slot-value" (present-slot slot (instance pres)))) + + (defcomponent two-column-presentation (mewa-object-presentation) ()) (defmethod present ((pres two-column-presentation)) @@ -80,7 +92,11 @@ (instances self)) -;;; searching +;;;; * Presentation Searches + + +;;;; ** "search all fields" criteria + (defgeneric search-expr (criteria instance) (:documentation "Return ready to apply criteria. What to do with it is backend dependent.")) @@ -116,15 +132,19 @@ (def-search-expr ((self ucw::number-equal-to)) (meta-model:expr-= (ucw::number-input self))) + + (defcomponent mewa-presentation-search (ucw::presentation-search) - ((display-results-p :accessor display-results-p :initarg :display-results-p :initform nil))) + ((display-results-p :accessor display-results-p :initarg :display-results-p :initform nil) + (criteria-input :accessor criteria-input :initform "") + (new-criteria :accessor new-criteria :initform nil))) (defmethod instance ((self mewa:mewa-presentation-search)) (instance (ucw::search-presentation self))) (defmethod search-expr ((self mewa:mewa-presentation-search) instance) (apply #'meta-model:expr-and instance - (mapcan (lambda (c) (let ((e (search-expr c instance))) + (mapcan (lambda (c) (let ((e (search-expr c instance))) (if (listp e) e (list e)))) (ucw::criteria self)))) @@ -143,10 +163,56 @@ (setf (display-results-p self) t)) +(defmethod set-search-input-for-criteria ((criteria ucw::criteria) (input t)) + (error "No search-input-for-criteria method for ~A : ~A" criteria input)) + +(defmethod set-search-input-for-criteria ((c ucw::string-criteria) input) + (setf (ucw::search-text c) input)) + +(defmethod set-search-input-for-criteria ((c ucw::negated-criteria) i) + nil) + + +(defmethod mewa-add-criteria ((self component) (criteria ucw::criteria)) + (set-search-input-for-criteria criteria (criteria-input self)) + (ucw::add-criteria self criteria)) + +(defmethod find-default-criteria (c ucw::mewa-string-slot-presentation) + 'ucw::string-contains) + + + +(defmethod render-criteria ((res response) (s mewa-presentation-search)) + (setf (criteria-input s) "") + (<:ul + (dolist (c (criteria s)) + (<:li (render-on res c) + (let ((c c)) + (