3 (defaction edit-instance
((self mewa
))
4 (call-presentation (instance self
) :type
:editor
))
7 (defcomponent mewa-one-line-presentation
(mewa one-line-presentation
)
9 (:default-initargs
:attributes-getter
#'one-line-attributes-getter
))
11 (defmethod one-line-attributes-getter ((self mewa
))
12 (or (meta-model:list-keys
(instance self
))))
15 (defcomponent mewa-object-presentation
(mewa ucw
:object-presentation
) ())
17 (defcomponent two-column-presentation
(mewa-object-presentation) ())
19 (defmethod present ((pres two-column-presentation
))
21 (<:table
:class
(css-class pres
)
22 (loop for slot on
(slots pres
) by
#'cddr
24 (<:tr
:class
"presentation-slot-row"
25 (<:td
:class
"presentation-slot-label"
26 (<:as-html
(label (first slot
))))
27 (<:td
:class
"presentation-slot-value"
28 (present-slot (first slot
) (instance pres
)))
30 (<:td
:class
"presentation-slot-label"
31 (<:as-html
(label (second slot
))))
32 (<:td
:class
"presentation-slot-value"
33 (present-slot (second slot
) (instance pres
))))))
34 (render-options pres
(instance pres
))))
38 (defcomponent mewa-list-presentation
(mewa ucw
:list-presentation
)
39 ((ucw::instances
:accessor instances
:initarg
:instances
:initform nil
)
40 (instance :accessor instance
)
41 (select-label :accessor select-label
:initform
"select" :initarg
:select-label
)
42 (selectablep :accessor selectablep
:initform t
:initarg
:selectablep
)
43 (ucw::deleteablep
:accessor deletablep
:initarg
:deletablep
:initform nil
)
44 (viewablep :accessor viewablep
:initarg
:viewablep
:initform nil
)))
46 (defaction select-from-listing
((listing mewa-list-presentation
) object index
)
49 (defmethod render-list-row ((listing mewa-list-presentation
) object index
)
50 (<:tr
:class
"item-row"
51 (<:td
:align
"center" :valign
"top"
52 (when (ucw::editablep listing
)
53 (let ((object object
))
54 (<ucw
:input
:type
"submit"
55 :action
(edit-from-listing listing object index
)
56 :value
(ucw::edit-label listing
))))
58 (when (ucw::deleteablep listing
)
60 (<ucw
:input
:type
"submit"
61 :action
(delete-from-listing listing object index
)
62 :value
(ucw::delete-label listing
))))
63 (when (selectablep listing
)
65 (<ucw
:input
:type
"submit"
66 :action
(select-from-listing listing object index
)
67 :value
(select-label listing
))))
68 (when (viewablep listing
)
70 (<ucw
:input
:type
"submit"
71 :action
(call-component listing
(make-presentation object
))
73 (dolist (slot (slots listing
))
74 (<:td
:class
"data-cell" (present-slot slot object
)))
75 (<:td
:class
"index-number-cell")
78 (defmethod get-all-instances ((self mewa-list-presentation
))
83 (defgeneric search-expr
(criteria instance
)
84 (:documentation
"Return ready to apply criteria.
85 What to do with it is backend dependent."))
87 (defmacro def-search-expr
(((self criteria-type
)) (model-expr &body body
))
88 `(defmethod search-expr ((,self
,criteria-type
) instance
)
91 (ucw::slot-name
(ucw::presentation
,self
))
94 (defmethod search-expr ((self ucw
::negated-criteria
) instance
)
95 (when (ucw::criteria self
)
98 (search-expr (ucw::criteria self
) instance
))))
100 (def-search-expr ((self ucw
::string-starts-with
))
101 (meta-model:expr-starts-with
(ucw::search-text self
)))
103 (def-search-expr ((self ucw
::string-ends-with
))
104 (meta-model:expr-ends-with
(ucw::search-text self
)))
106 (def-search-expr ((self ucw
::string-contains
))
107 (meta-model:expr-contains
(ucw::search-text self
)))
109 (def-search-expr ((self ucw
::number-less-than
))
110 (meta-model:expr-
< (ucw::number-input self
)))
112 (def-search-expr ((self ucw
::number-greater-than
))
113 (meta-model:expr-
> (ucw::number-input self
)))
115 (def-search-expr ((self ucw
::number-equal-to
))
116 (meta-model:expr-
= (ucw::number-input self
)))
118 (defcomponent mewa-presentation-search
(ucw::presentation-search
)
119 ((display-results-p :accessor display-results-p
:initarg
:display-results-p
:initform nil
)))
121 (defmethod instance ((self mewa
:mewa-presentation-search
))
122 (instance (ucw::search-presentation self
)))
124 (defmethod search-expr ((self mewa
:mewa-presentation-search
) instance
)
125 (apply #'meta-model
:expr-and instance
126 (mapcan (lambda (c) (let ((e (search-expr c instance
)))
127 (if (listp e
) e
(list e
))))
128 (ucw::criteria self
))))
130 (defmethod search-query ((self mewa
:mewa-presentation-search
))
131 (search-expr self
(instance self
)))
133 (defmethod valid-instances ((self mewa
:mewa-presentation-search
))
134 (meta-model:select-instances
(instance self
) (search-query self
)))
136 (defmethod get-all-instances ((self mewa-presentation-search
))
137 (meta-model:select-instances
(instance self
)))
139 (defmethod ok ((self mewa-presentation-search
) &optional arg
)
140 (declare (ignore arg
))
141 (setf (ucw::instances
(ucw::list-presentation self
)) (valid-instances self
))
142 (setf (display-results-p self
) t
))
145 (defmethod render-on ((res response
) (self mewa-presentation-search
))
146 ;(<:as-html (search-query self))
147 (ucw::render-criteria res self
)
148 (<ucw
:input
:type
"submit" :value
"Search" :action
(ok self
))
149 (when (display-results-p self
)
150 (let ((listing (ucw::list-presentation self
)))
152 (slot-value listing
'ucw
::calling-component
) (slot-value self
'ucw
::calling-component
)
153 (slot-value listing
'ucw
::place
) (slot-value self
'ucw
::place
)
154 (slot-value listing
'ucw
::continuation
) (slot-value self
'ucw
::continuation
))
156 (render-on res listing
))))
159 (defcomponent dont-show-unset-slots
()())
161 (defmethod slots :around
((self dont-show-unset-slots
))
162 (remove-if-not #'(lambda (s) (let ((s (presentation-slot-value s
(instance self
))))
163 (and s
(not (equal "" s
)))))