| 1 | [[PageOutline(2-5,Contents,pullout)]] |
| 2 | |
| 3 | = Conditionally display fields based on ticket type = |
| 4 | |
| 5 | == Description == |
| 6 | |
| 7 | With the help of this Trac plugin you can hide or show fields when |
| 8 | creating or viewing a ticket, depending on the ticket type. Only the |
| 9 | presentation changes, not the contents of the ticket. |
| 10 | |
| 11 | CondField2 is derived from the CondFieldsPlugin ("Dynamic fields by ticket type"), but it is completely based on Genshi now instead of using |
| 12 | Javascript. Moreover, you can select whether selected fields are hidden |
| 13 | or shown by default. |
| 14 | |
| 15 | This plugin is "standalone"; the patch |
| 16 | "blackmagic-conditionalfields.patch" in [1] did not match with newer |
| 17 | releases of Trac 0.11. |
| 18 | |
| 19 | Some problems reported about the more powerful DynamicFieldsPlugin (bad scaling |
| 20 | for many fields, malfunction if fields are internally sorted, clearing |
| 21 | value of hidden fields) should not occur here. |
| 22 | |
| 23 | It should be easy to extend this plugin, e.g. for dependence on other parameters |
| 24 | than ticket type. |
| 25 | |
| 26 | The plugin was tested under Trac 0.12 but should work under Trac 0.11, too. |
| 27 | |
| 28 | == Bugs/Feature Requests == |
| 29 | |
| 30 | Existing bugs and feature requests for CondFieldsGenshiPlugin are |
| 31 | [report:9?COMPONENT=CondFieldsGenshiPlugin here]. |
| 32 | |
| 33 | If you have any issues, create a |
| 34 | [http://trac-hacks.org/newticket?component=CondFieldsGenshiPlugin&owner=Reinhard new ticket]. |
| 35 | |
| 36 | == Download == |
| 37 | |
| 38 | Download the zipped source from [download:condfieldsgenshiplugin here]. |
| 39 | |
| 40 | == Source == |
| 41 | |
| 42 | You can check out CondFieldsGenshiPlugin from [http://trac-hacks.org/svn/condfieldsgenshiplugin here] using Subversion, or [source:condfieldsgenshiplugin browse the source] with Trac. |
| 43 | |
| 44 | == Example == |
| 45 | |
| 46 | First, configure trac.ini as in this example: |
| 47 | |
| 48 | [components] |
| 49 | condfield2.* = enabled |
| 50 | |
| 51 | ... |
| 52 | |
| 53 | [condfield2] |
| 54 | tweaks = field1, field2 |
| 55 | default = disable |
| 56 | field1.type_cond = defect |
| 57 | field2.type_cond = task |
| 58 | |
| 59 | |
| 60 | Effect: |
| 61 | |
| 62 | Now field1 will be shown only if the ticket type is "defect", field2 |
| 63 | only if the ticket type is "task". |
| 64 | |
| 65 | The entry "default = disable" means that the field listed under "tweaks" |
| 66 | are NOT shown by default. |
| 67 | The default value is "default = enable". |
| 68 | |
| 69 | To disable/enable a field independent of the ticket type, simply write a line |
| 70 | like |
| 71 | |
| 72 | field1.type_cond = None |
| 73 | |
| 74 | (supposed there is no "None" type :-). |
| 75 | |
| 76 | When you change the ticket type, you must type "preview" resp. "submit" |
| 77 | before you can see the effect of of condfield2. |
| 78 | |
| 79 | |
| 80 | Bug fix done for "type" field |
| 81 | ----------------------------- |
| 82 | |
| 83 | When the ticket type is given as an URL parameter only: |
| 84 | |
| 85 | .../newticket?type=task |
| 86 | |
| 87 | and the ticket type field is disabled, this plugin works nevertheless |
| 88 | (in contrast to the Dynamic fields by ticket type plugin, cf. [1]). |
| 89 | |
| 90 | The type field label is extended by "(Fixed)" in this case now. |
| 91 | |
| 92 | == Recent Changes == |
| 93 | |
| 94 | [[ChangeLog(condfieldsgenshiplugin, 3)]] |
| 95 | |
| 96 | == Author/Contributors == |
| 97 | |
| 98 | '''Author:''' [wiki:Reinhard] [[BR]] |
| 99 | '''Maintainer:''' [wiki:Reinhard] [[BR]] |
| 100 | '''Contributors:''' |