Opened 9 years ago

Last modified 20 months ago

#2486 new enhancement

Dynamic fields by ticket type

Reported by: steve@… Owned by: obs
Priority: normal Component: BlackMagicTicketTweaksPlugin
Severity: normal Keywords: CondFieldsPlugin
Cc: Trac Release: 0.11


This would seem the logical place to implement the old 0.10 functionality of CondFieldsPlugin into 0.11 - i.e. dynamically showing and hiding fields based on the ticket type.

I realise that this functionality would be (partially) client-side, but it meshes well with the rest of the ideas here and would be a good next step.

The combination of restricting ticket-type changes by permissions and this would mean so much flexibility in implementations.

Attachments (1)

blackmagic-conditionalfields.patch (3.3 KB) - added by Joachim Hoessler 9 years ago.
Patch that adds conditional fields to the black magic plugin

Download all attachments as: .zip

Change History (10)

comment:1 Changed 9 years ago by Stephen Hansen

Status: newassigned

I've been thinking about that; its something I need for work too.

However, I really don't want to do a lot of client-side javascript for essential functionality like that. The tooltips are one thing-- they're just informational.

I've been thinking of removing the 'Type' field from the form, and instead looking into the workflow internals to add a 'set_type' workflow action.

Basically, instead of changing the type and then having the rest of the fields be adjusted inline via javascript, you'd have to click on the bottom where it'd say "Set type to: <dropdown>" and submit. Then when it reloads it'd have the ticket changes in place.

comment:2 Changed 9 years ago by steve@…

Keywords: CondFieldsPlugin added; ConfFieldsPlugin removed

I'm not sure my process gods would be happy with the extra step needed with your suggestion of workflow actions.

For my particular need it would be enough to allow the user to select a ticket type only on the new ticket page and then do as you suggest, but I was trying to keep the solution generic.

Would it be possible to allow fields to be shown only on ticket creation and hidden at all other times? Then just allow fields to be hidden conditional on ticket type and I'm sorted - no need for client-side JS. Even more evil for people not hiding ticket-type though.

Thanks for this plugin. I'm spending so much time generating our own dodgy workflow and plugins I'm not sure if I'll be able to contribute to this one...

Changed 9 years ago by Joachim Hoessler

Patch that adds conditional fields to the black magic plugin

comment:3 Changed 9 years ago by Joachim Hoessler

This patch implements a basic solution to the above problem. It allows to hide fields depending on the ticket type. For example with this configuration

tweaks = cc
cc.type_cond = defect,task

the cc field will only show up if the type of the ticket is set to "defect" or "task". For existing tickets, the current ticket type is taken. For new tickets, the type that is given as parameter to the page (e.g. via a /newticket?type=defect link) or, if none is given, the default type is used. If a user changes the type, he needs to submit this change before the corresponding conditional fields show up.

I've also moved the code some lines up that checks if fields need to be hidden so that "notice" or "tip" tweaks won't show up if fields are hidden.

Although this approach works for me, having an extra 'set_type' workflow action would probably be a nice thing.

comment:4 Changed 9 years ago by Tobias

hoesslers patch works great with trac 0.11. @ixokai: Why not integrate it into svn?

comment:5 Changed 8 years ago by Ross Blauwkamp

I found that the patch did not correctly pick up the ticket type in the request (Trac 0.11/Python 2.6 on Apache 2.2.1 /Ubuntu 9.0.4). Instead I always got the default ticket type for a new ticket request despite having, e.g. "/newticket?type=story".

I found that changing line 45 of (post_patch) to read:

ticket_type = req.args.get('type')

resolved the problem.

Great new functionality with this patch!

comment:6 Changed 8 years ago by Ross Blauwkamp

As I've used this more, I've found that even when using links like "/newticket?type=defect", one still should not hide or disable the "type" selector. If you do, somehow the type will be used to render the form for creating the ticket, but won't propagate to the preview or submit (get the default ticket type). Still useful functionality; I just use a notice to warn users not to change the type.

comment:7 Changed 7 years ago by obs

Owner: changed from Stephen Hansen to obs
Status: assignednew

comment:8 Changed 6 years ago by Rob Guttman

I just happened upon this old ticket but you all may be interested in the Dynamic Fields plugin which currently provides this (and other dynamic) functionality.

comment:9 Changed 20 months ago by Ryan J Ollos

#11683 closed as a duplicate.

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain obs.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.