1 (in-package :lisp-on-lines
)
6 attribute
:in-layer dojo
()
7 ((dojo-type :accessor dojo-type
:initarg
:dojo-type
:initform nil
:special t
)))
10 (defgeneric display-as-dojo-type
(type attribute object component
))
13 :in-layer dojo
:after
((attribute standard-attribute
) object
)
14 (when (dojo-type attribute
)
15 (display-as-dojo-type (dojo-type attribute
) attribute object self
)))
17 (defcomponent dojo-test
(window-component)
19 (results :accessor results
:initarg
:results
)))
21 (defmethod render ((self dojo-test
))
22 (<:as-is
(js:js
* `(array
23 ,@(loop for r in
(results self
)
26 (with-output-to-string (s)
27 (yaclml:with-yaclml-stream s
28 (display self r
:type
'as-string
))) ,n
))))))
31 (defmethod display-as-dojo-type ((type (eql 'combo-box
)) attribute object component
)
33 (let* ((search-function (search-function attribute
))
34 (select-function (select-function attribute
))
35 (select-callback (ucw::make-new-callback
(lambda (x)
36 (warn "setting index to ~A" (parse-integer x
))
37 (funcall select-function
38 (parse-integer x
))))))
39 "The combo box widget"
41 `(dojo.require
"dojo.*")
42 `(dojo.require
"dojo.widget.*")
43 `(dojo.require
"dojo.widget.html.ComboBox")
44 (js:with-unique-js-names
(element combo-box
)
48 (setf ,element
(dojo.by-id
,(id attribute
)))
50 (dojo.widget.from-script
53 :data-url
(+ , (lol::make-action-url
56 (context.window-component
*context
*)
57 (make-instance 'dojo-test
59 (funcall search-function
60 (attribute-value object attribute
)))))
62 ,(escape-as-uri (callback attribute
))
66 ((slot-value ,combo-box
'set-value
) (slot-value ,element
'value
))
68 ,combo-box
"selectOption"
70 (setf (slot-value ,element
'value
)
71 (slot-value ,combo-box
'selected-result
))
74 :url
(+ ,(lol::make-action-url
78 ,(escape-as-uri (callback attribute
))
80 (slot-value ,combo-box
'selected-result
)
84 (slot-value ,combo-box
'combo-box-selection-value.value
))))))))))))