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'm proposing to add something like this:
class ITicketFieldTypeProvider(Interface):
""" Provide custom ticket field types. """
def get_ticket_field_types():
""" Return list of (name, type) tuples, where type is a
subclass of trac.ticket.field.Field. """
Then the current field types would be implemented with this:
def get_ticket_field_types(self):
from trac.ticket.field import TextArea, Select, \
CheckBox, Radio, Text
yield ('textarea', TextArea)
yield ('select', Select)
yield ('checkbox', CheckBox)
yield ('radio', Radio)
yield ('text', Text)
The problematic part is how to render the custom fields. Ideally they
would be rendered through the templating system, but I can't really
figure out a clean way to inject other templates into ClearSilver.
The solution I've come up with is to create a temporary HDFWrapper
object, populate it with the ticket data, then pass that to the
render(hdf) and render_control(hdf) methods of ticket.field.Field. This
doesn't seem terribly efficient to me.
render() generates the HTML used when displaying the field itself, while
render_control() generates the HTML necessary to edit the field. The
results are stored in the main HDF tree under the current fields
html_value and html_control.
Here's what the ticket summary field might look like:
1 {
name = summary
title =
plaintext = 0
editable = 1
value = This is a really really long ticket summary to see how the new
patch handles long lines
label = Summary
hidden = 1
type = text
order = 0
fullrow = 1
html_value = This is a really really long ticket summary to see how the
new patch handles long lines
html_control = <input type="text" id="summary" name="summary" size="70"
value="This is a really really long ticket summary to see how the new patch
handles long lines" />
}
So, the question is, is there a cleaner way to do this?
Alec
--
Evolution: Taking care of those too stupid to take care of themselves.
_______________________________________________
Trac-dev mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-dev