687d5f1c |
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 | |
6460c439 |
14 | (defcomponent two-column-presentation (mewa-object-presentation) ()) |
15 | |
16 | (defmethod present ((pres two-column-presentation)) |
17 | |
18 | (<:table :class (css-class pres) |
19 | (loop for slot on (slots pres) by #'cddr |
20 | do |
21 | (<:tr :class "presentation-slot-row" |
22 | (<:td :class "presentation-slot-label" |
23 | (<:as-html (label (first slot)))) |
24 | (<:td :class "presentation-slot-value" |
25 | (present-slot (first slot) (instance pres))) |
26 | (when (second slot) |
27 | (<:td :class "presentation-slot-label" |
28 | (<:as-html (label (second slot)))) |
29 | (<:td :class "presentation-slot-value" |
30 | (present-slot (second slot) (instance pres)))))) |
31 | (render-options pres (instance pres)))) |
32 | |
33 | |
687d5f1c |
34 | ;;;lists |
35 | (defcomponent mewa-list-presentation (mewa ucw:list-presentation) |
31597d71 |
36 | ((ucw::instances :accessor instances :initarg :instances :initform nil) |
687d5f1c |
37 | (instance :accessor instance) |
38 | (select-label :accessor select-label :initform "select" :initarg :select-label) |
39 | (selectablep :accessor selectablep :initform t :initarg :selectablep))) |
40 | |
41 | (defaction select-from-listing ((listing mewa-list-presentation) object index) |
42 | (answer object)) |
43 | |
44 | (defmethod render-list-row ((listing mewa-list-presentation) object index) |
45 | (<:tr :class "item-row" |
46 | (<:td :align "center" :valign "top" |
47 | (when (ucw::editablep listing) |
48 | (let ((object object)) |
49 | (<ucw:input :type "submit" |
50 | :action (edit-from-listing listing object index) |
51 | :value (ucw::edit-label listing)))) |
52 | (<:as-is " ") |
53 | (when (ucw::deleteablep listing) |
54 | (let ((index index)) |
55 | (<ucw:input :type "submit" |
56 | :action (delete-from-listing listing object index) |
57 | :value (ucw::delete-label listing)))) |
58 | (when (selectablep listing) |
59 | (let ((index index)) |
60 | (<ucw:input :type "submit" |
61 | :action (select-from-listing listing object index) |
62 | :value (select-label listing))))) |
63 | (dolist (slot (slots listing)) |
64 | (<:td :class "data-cell" (present-slot slot object))) |
6fc8733b |
65 | (<:td :class "index-number-cell") |
687d5f1c |
66 | )) |
67 | |
68 | (defmethod get-all-instances ((self mewa-list-presentation)) |
69 | (instances self)) |