Opened 17 years ago
Last modified 9 years ago
#5641 new enhancement
Allow enums to be used in ticket custom value sets
Reported by: | Colin Guthrie | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | next-major-releases |
Component: | general | Version: | 0.10.4 |
Severity: | normal | Keywords: | field |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I am writing a plugin that just adds a custom ticket field. It is to hold a list of clients to which a ticket "belongs" but that is not really important.
The possible values for this could be quite long and using the .options
value of the .ini file doesn't seem appropriate.
So I thought a sensible route would be to use the enum table to hold the values and write a simple extension to TracWebAdmin to add another editing page page based on AbstractEnumAdminPage type (I'm not sure if this is still part of Trac 0.11 with merged TracWebAdmin tho' :))
Anyway, this patch allows easy use of the enum table and easy ways to hook up custom fields to use that list. This would not really be of use to people unless they create a plugin to admin the actual list too but it's still a useful feature IMO and the patch itself is fairly unobtrusive, so hopefully you can accept it.
The changes just allow a .options
value of "enum:name" where name is the name you give to your enum and this will load the values from the database rather than parsing a pipe-separated list.
The other change was for when an enum name is updated (name changed) and which then updates the ticket table to reflect said changes. I just added a check so that it can update the ticket_custom table instead.
Hope this is acceptable. Not adding my mail here as I don't want it spammed but I will check back for updates. Patches are against 0.10.4
Attachments (2)
Change History (10)
by , 17 years ago
Attachment: | custom_enum.diff added |
---|
follow-up: 3 comment:1 by , 17 years ago
comment:2 by , 17 years ago
For reference I've uploaded a plugin that makes use of this new feature:
The exceptionally complex code for the plugin is here: http://www.trac-hacks.org/browser/clientsplugin/0.10/clients/client.py
The plugin itself can be found here: http://www.trac-hacks.org/wiki/ClientsPlugin
Obviously this is just an example (and a simple one at that) but it illustrates the point :D
comment:3 by , 17 years ago
Replying to Colin Guthrie:
Hmmm, don't know why but the built in Trac viewer for diff file format doesn't like my patch and it's only showing the first file - seems like I've just found another bug :)
This has been fixed on trunk, though I'm not sure in which changeset exactly (probably r4067).
comment:4 by , 17 years ago
Keywords: | field added |
---|---|
Milestone: | → 0.12 |
Interesting idea, I'll keep note of the proposal and see how it can be handled in the new flexible property scheme (FieldRefactoring / GenericTrac).
But at this stage I'm not sure it will be implemented in the current form (enum:name
value for the options), so it doesn't make sense to integrate in 0.10 (which is mostly "closed" for new features anyway).
by , 17 years ago
Attachment: | ITicketCustomFieldValues.patch added |
---|
OK, here is an updated patch that adds a new Interface/ExtensionPoint that means that plugins can provide a list of custom field values to custom fields. The change is quite simple and I think useful. It means plugins can do a lot more with field values. If possible I'd love to see this in 0.11… I'd say this can replace the previous patch as although it's not exactly the same, it's much more flexible.
comment:7 by , 17 years ago
Yeah, I spoke to coderanger on irc and he explained how this could be done. I'll work on a plugin to do this instead. The general enum: concept is still quite a good one I reckon, to allow people to create custom fields and possible values easily but as cboos said that is one for GenericTrac
comment:8 by , 9 years ago
Owner: | removed |
---|
Hmmm, don't know why but the built in Trac viewer for diff file format doesn't like my patch and it's only showing the first file - seems like I've just found another bug :)
The raw format show it correctly: http://trac.edgewall.org/attachment/ticket/5641/custom_enum.diff?format=raw