3763c2783218ad0d1569725c0e6e17abd61f813c
[clinton/lisp-on-lines.git] / src / mewa / presentations.lisp
1 (in-package :mewa)
2
3 ;;;one-line objects
4 (defcomponent mewa-one-line-presentation (mewa one-line-presentation)
5 ()
6 (:default-initargs :attributes-getter #'one-line-attributes-getter))
7
8 (defmethod one-line-attributes-getter ((self mewa))
9 (or (meta-model:list-keys (instance self))))
10
11 ;;;objects
12 (defcomponent mewa-object-presentation (mewa ucw:object-presentation) ())
13
14 ;;;lists
15 (defcomponent mewa-list-presentation (mewa ucw:list-presentation)
16 ((instances :accessor instances :initarg :instances :initform nil)
17 (instance :accessor instance)
18 (select-label :accessor select-label :initform "select" :initarg :select-label)
19 (selectablep :accessor selectablep :initform t :initarg :selectablep)))
20
21 (defaction select-from-listing ((listing mewa-list-presentation) object index)
22 (answer object))
23
24 (defmethod render-list-row ((listing mewa-list-presentation) object index)
25 (<:tr :class "item-row"
26 (<:td :align "center" :valign "top"
27 (when (ucw::editablep listing)
28 (let ((object object))
29 (<ucw:input :type "submit"
30 :action (edit-from-listing listing object index)
31 :value (ucw::edit-label listing))))
32 (<:as-is " ")
33 (when (ucw::deleteablep listing)
34 (let ((index index))
35 (<ucw:input :type "submit"
36 :action (delete-from-listing listing object index)
37 :value (ucw::delete-label listing))))
38 (when (selectablep listing)
39 (let ((index index))
40 (<ucw:input :type "submit"
41 :action (select-from-listing listing object index)
42 :value (select-label listing)))))
43 (dolist (slot (slots listing))
44 (<:td :class "data-cell" (present-slot slot object)))
45 (<:td :class "index-number-cell"
46 (<:i (<:as-html index)))
47 ))
48
49 (defmethod get-all-instances ((self mewa-list-presentation))
50 (instances self))