DynamicFieldsPlugin: Bug or feature?

67 views
Skip to first unread message

Reinhard Wobst

unread,
May 9, 2012, 11:13:31 AM5/9/12
to Trac Users
Hi all,

I made some experiments with the DynamicFieldsPlugin
(http://trac-hacks.org/wiki/DynamicFieldsPlugin) and noticed that the
0.12 branch did not work with Trac 0.12. However, Google found some
Twitter message that this branch has some problems and we should use
the
0.11 plugin version. Really, it runs.

However, I observed a strange behaviour. I created some custom fields
X1, X2 etc. and configured like

X1.show_when_type = task

This worked as promised (i.e., the X* fields are shown only when the
ticket type is "task"), but when I changed the ticket type to e.g.
"enhanced", the change log claimed "X1 deleted, X2 deleted" etc.
Indeed,
when I changed the ticket type back to "task", the values were lost
though the field forms were displayed again, the fields were blank.

This happens with default values as well as with manual entries. The
values are lost even when I change the ticket type on the fly without
submitting or even previewing the ticket.

My question: Is that a bug or a feature? I must say that I am not firm
with Javascript, my world is Python (and others).

BTW, I have been developing a successor of the condfield plugin
(https://trac-hacks.org/ticket/2486) based on Genshi only, which
already
works fine (but still needs some tests) and should not show the
problems
like performance (http://trac-hacks.org/ticket/9606) and
incompatibility
with ticket sorting as the DynamicFieldsPlugin is reported. Maybe,
this
will be a solution for some requirements, but about this later.

Greetings

Reinhard

RjOllos

unread,
May 9, 2012, 5:50:10 PM5/9/12
to trac-...@googlegroups.com


On Wednesday, May 9, 2012 8:13:31 AM UTC-7, Reinhard Wobst wrote:
I made some experiments with the DynamicFieldsPlugin
(http://trac-hacks.org/wiki/DynamicFieldsPlugin) and noticed that the
0.12 branch did not work with Trac 0.12. However, Google found some
Twitter message that this branch has some problems and we should use
the
0.11 plugin version. Really, it runs.


You were looking too hard. The issue is stated at the top of the project page ;)
http://trac-hacks.org/wiki/DynamicFieldsPlugin#Dynamicallyhidedefaultcopyclearvalidatesetticketfields

However, I observed a strange behaviour. I created some custom fields
X1, X2 etc. and configured like

X1.show_when_type = task

This worked as promised (i.e., the X* fields are shown only when the
ticket type is "task"), but when I changed the ticket type to e.g.
"enhanced", the change log claimed "X1 deleted, X2 deleted" etc.
Indeed,
when I changed the ticket type back to "task", the values were lost
though the field forms were displayed again, the fields were blank.

Assuming I'm following you correctly, the behavior seems correct and desirable (at least in the most general sense). If you hide X1 for ticket type enhancement, then you want it's field to be empty and not based on whatever the user input before they changed the ticket type. It seems like it would be difficult and overly complicated to save and restore the value for X1 in case that the user changes the type from task -> enhancement -> task.

What may be desireable though, is behavior similar to the TracTicketTemplatePlugin. If you enter some text in the Description field and then change the ticket type, it will warn you that your edits will be lost.

http://trac-hacks.org/wiki/TracTicketTemplatePlugin

Reinhard Wobst

unread,
May 10, 2012, 11:52:12 AM5/10/12
to Trac Users
Thank you, this explains all - the plugin web page has changed on end
of April, and I obviously still had the old version in my browser tab.
What I was looking for was a tool like the condfield plugin that just
hides fields and does not influence the contents in any way - so I see
that my condfield2 makes some sense. I hope to post about this
soon ...

Best

Reinhard

Reinhard Wobst

unread,
May 10, 2012, 12:01:34 PM5/10/12
to Trac Users
... addenda: Suppose a ticket is created with a certain type,
uninteresting fields with default values are hidden to not irritate
the user.
Later the type is changed, and the default values have vanished. I
still will discuss this with my customer but I think this is not what
he wants.

Reinhard

robguttman

unread,
May 25, 2012, 2:17:41 PM5/25/12
to Trac Users
Hi, you can instruct DynamicFields to not clear a hidden field:

http://trac-hacks.org/wiki/DynamicFieldsPlugin#Hiderule

Set {field}.clear_on_hide to false (the default is true).

- Rob

Reinhard Wobst

unread,
May 31, 2012, 10:12:51 AM5/31/12
to Trac Users
Sorry that I answer only now (we had holidays :-) ... you are right,
but if I write e.g.

X1.show_when_type = task
X1.clear_on_hide = false

in trac.ini, the field X1 is shown even for other types than "task".
This is not my intention ...

Reinhard
Reply all
Reply to author
Forward
0 new messages