Am 10.03.2006 um 10:05 schrieb Christian Boos:
Alec Thomas wrote:
Hi,
I think it would be advantageous to let plugins implement their own
ticket field types. Progress-bars, integer-only fields, etc. have all
been requested numerous times.
I'd like to have at least the progress bar in the core Trac (see
ticket #1084),
in order to match FlySpray's percent complete functionality. See:
http://flyspray.rocks.cc/bts/ for how it looks in the overview, and
e.g.
http://flyspray.rocks.cc/bts/task/612 for how it looks in the
ticket view.
Doesn't make sense to me to include a widget if we don't actually
support any kind of "percent complete" for tickets.
...
So, the question is, is there a cleaner way to do this?
Can't field.render_view(req, hdf) and field.render_control(req,hdf) be
"agnostic" w.r.t. the way they generate the HTML, i.e. simply be
field.render_view(req) and field.render_control(req).
If a field implementation wants to use ClearSilver, it's "its"
problem...
I agree that fields should simply return HTML as text. Classic
templates are particularly clumsy for forms. The only thing about
form fields/widgets that should be customizable via templates is
where it gets placed, and where the corresponding label should get
placed (i.e. don't include both in the string).
I've been hacking away yesterday at "yet another HTML builder" lib
which would probably be useful here:
http://projects.edgewall.com/trac/attachment/wiki/ChristopherLenz/
html.py
Example usage:
>>> from trac.util import html
>>> values = ['one', 'two', 'three']
>>> curval = 'two'
>>> select = html.SELECT(name='something')[
... [html.OPTION(selected=(val == curval))[val] for val in
values]
... ]
>>> print select
<select name="something">
<option>one</option>
<option selected="selected">two</option>
<option>three</option>
</select>
(indentation and line-breaks in output added here for readability)
This is intended to be used in the various places in Trac where we
generate little HTML snippets.
Cheers,
Chris
--
Christopher Lenz
cmlenz at gmx.de
http://www.cmlenz.net/
_______________________________________________
Trac-dev mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-dev