1 (in-package :lisp-on-lines
)
4 ;TODO: get rid of this.
5 (defun attribute.name
(attribute)
6 (attribute-name attribute
))
9 ;;;; A few layers related to attributes
10 (deflayer omit-nil-attributes
)
12 (defdisplay :in-layer omit-nil-attributes
13 :around
((attribute standard-attribute
) object
)
14 (when (attribute-value object attribute
)
18 (deflayer show-attribute-labels
)
20 (defattribute attribute-label
(attribute)
26 ((label attribute-label
) object
)
29 (<:as-html
(or (label (attribute label
))
30 (attribute-name (attribute label
)) " ")
33 (defvar *attribute-label-attribute
*
34 (make-instance 'attribute-label
))
37 :in-layer show-attribute-labels
38 :around
((attribute standard-attribute
) object
)
39 (display-attribute *attribute-label-attribute
* object
:attribute attribute
)
42 (deflayer use-pretty-labels
)
44 (define-layered-method label
45 :in-layer use-pretty-labels
46 :around
(standard-attribute)
47 (let ((label (call-next-method)))
50 (substitute #\Space
#\- label
)))))
52 (deflayer inspect-attributes
)
54 (defdisplay :in-layer inspect-attributes
55 :around
((attribute standard-attribute
) object
)
57 (<ucw
:a
:action-body
(ucw::call-inspector self attribute
)
60 (attribute-name attribute
) ":"
61 (description-type attribute
) ":"
65 ;;;; Functional attributes
66 (defattribute display-attribute
()
68 :accessor display-arguments
73 (:documentation
"Apply the display function to this object"))
75 (defdisplay ((attribute display-attribute
) object
)
76 (apply #'display self
(attribute-value object attribute
)
77 (display-arguments attribute
)))
79 (defattribute function-attribute
()
80 ((function :accessor function-of
87 (defdisplay ((function function-attribute
) object
)
88 (funcall (function-of function
)
89 (attribute-value object function
)))
92 ;;;; Attribute Grouping
93 (defattribute attribute-group
()
99 (defdisplay ((group attribute-group
) object
)
100 (apply #'display self object
101 :attributes
(attributes group
)
105 (defattribute select-attribute
(display-attribute)
108 :test
'meta-model
::generic-equal
109 :options-getter
(constantly nil
))
112 (defdisplay ((attribute select-attribute
) object
)
114 :accessor
(attribute-value object attribute
)
116 :test
(test attribute
)
117 (dolist* (obj (funcall (options-getter attribute
) object
))
120 (apply #'display
* obj
(display-arguments attribute
))))))
124 (defattribute base-attribute
()
129 (defdisplay ((base base-attribute
) object
)
130 (<:as-html
(attribute-value object base
)))
132 (defattribute base-attribute
()
138 :default-value-predicate
#'null
139 :dom-id
(js:gen-js-name-string
:prefix
"_ucw_")
142 (define-layered-function display-value
(attribute value
)
143 (:method
(attribute value
)
144 (if (funcall (default-value-predicate attribute
) value
)
145 (default-value attribute
)
149 :in-layer editor
((field base-attribute
) object
)
150 (LET ((value (attribute-value (object field
) field
)))
154 :VALUE
(escape-as-html (strcat (display-value field value
)))
160 (INPUT-SIZE FIELD
))))
163 :in-layer editor
:around
((string base-attribute
) object
)
164 (dletf (((callback string
)
165 (or (callback string
)
166 (ucw::register-callback
168 (setf (attribute-value object string
) val
)))))
169 ((object string
) object
))
174 (defattribute string-attribute
(base-attribute)
186 (defdisplay :in-layer omit-nil-attributes
187 :around
((attribute string-attribute
) object
)
188 (when (< 0 (length (attribute-value object attribute
)))
192 (defdisplay :in-layer viewer
193 ((string string-attribute
) object
)
194 (if (escape-html-p string
)
195 (<:as-html
(attribute-value object string
))
196 (<:as-is
(attribute-value object string
))))
200 #+nil
(defattribute string-attribute
(base-attribute)
207 (defattribute string-search-attribute
(string-attribute)
210 ;; the func that find search results
212 :search-action
#'(lambda ()
215 ;; when chosing from a list of results, this function selects one.
216 :select-function
(constantly t
))
217 (:type-name string-search
))
220 :in-layer editor
:after
((search string-search-attribute
) object
)
227 (IT.BESE.UCW
::SET-ACTION-PARAMETER
228 ,(IT.BESE.UCW
::MAKE-NEW-ACTION
229 (IT.BESE.UCW
::CONTEXT.CURRENT-FRAME
*CONTEXT
*)
230 (search-action search
)))
235 (defattribute text-attribute
(string-attribute)
239 (defdisplay :in-layer editor
((string text-attribute
) object
)
242 :name
(callback string
)
243 (or (attribute-value object string
) "")))
249 (defattribute wall-time-attribute
(string-attribute)
251 (:type-name clsql-sys
:wall-time
))
253 (define-layered-method attribute-value
(object (attribute wall-time-attribute
))
254 (let ((date (call-next-method)))
255 (when date
(multiple-value-bind (y m d
) (clsql:time-ymd date
)
256 (format nil
"~a/~a/~a" m d y
)))))
259 ((time wall-time-attribute
) object
)
260 (<:as-html
(attribute-value object time
)))
264 (defattribute image
()
267 :css-class
"lol-image"
270 (defdisplay ((buttons (eql 'image-editor-buttons
)) object
)
271 (<ucw
:a
:action
(ok component object
)
272 (<:as-html
"select this image")))
274 (defdisplay ((image image
) object
)
276 :class
(or (css-class image
) "lol-image")
278 (or (prefix image
) "images/")
280 (attribute-value object image
)))))
283 :in-layer editor
((image image
) object
)
286 :class
"lol-image-thumbnails"
287 (<:as-html
"imagie"))) |
#