Ticket #926 (closed enhancement: fixed)
Opened 7 years ago
Last modified 7 years ago
[PATCH] Allow aligning custom fields by specifying CSS style for them
| Reported by: | pkou <pkou at ua.fm> | Owned by: | cboos |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.9 |
| Component: | ticket system | Version: | devel |
| Severity: | normal | Keywords: | |
| Cc: | |||
| Release Notes: | |||
| API Changes: | |||
Description
Currently, there is no way to display custom fields in two columns, e.g. as main ticket fields are displayed.
The proposal is to implement this feature by adding customfield.class parameter for custom fields in trac.ini:
- When this parameter is not specified, Trac uses current approach:
- Every custom field is added into <div class="field custom_name"> section;
- Dashed line is added between main fields and custom fields.
- When .class is specified, Trac uses new approach:
- Every custom field with .class parameter starts new <div class="class"> section;
- Custom fields without .class paramter that follow a field with this paramter belong to the same class. The fields are separated using <br /> tag;
- No special separator is added between main and custom fields.
- It is possible to mix old and new approach:
- All custom fields before first field with .class paramter are processed in old way;
- For other fields, it is necessary to specify their class in trac.ini explicitly.
Also, three special classes are predefined:
- custom: Starting a new section and draw a dashed line above it;
- col1custom: Starting first column with dashed line above it;
- col2custom: Starting second column with dashed line above it.
Example setup for custom ticket fields is in attached file customalign.ini. Also, attached picture customalign.png shows the result for this setup.
Patch attached also.
Attachments
Change History
Changed 7 years ago by pkou <pkou at ua.fm>
- Attachment customalign.ini added
Changed 7 years ago by pkou <pkou at ua.fm>
- Attachment customalign.png added
Result of using customalign.ini on the patch
Changed 7 years ago by pkou <pkou at ua.fm>
- Attachment patch-customalign-r1049.diff added
Patch for the changes
comment:1 Changed 7 years ago by steffenp@…
I have modified the style sheet and the output generated by macros.py to use the <label for="..."> to align the custom fields like the other fields in the "Change Properties" box (see screenshot). I have also attached a patch.
Changed 7 years ago by stp
- Attachment custom-field-alignment.png added
Changed 7 years ago by stp
- Attachment align-custom-fields-r1579.diff added
comment:2 Changed 7 years ago by mgood
- Milestone set to 0.9
- Owner changed from jonas to mgood
- Status changed from new to assigned
I'll do some browser testing on this since this type of thing tends to be frustrating to get working in IE. If everthing seems kosher I'll try to get this in soon.
Changed 7 years ago by steffenp@…
- Attachment align-custom-fields-r1634.diff added
Fixed alignment of radio buttons
comment:3 Changed 7 years ago by steffenp@…
I have attached an improved patch that has been tested with konqueror, firefox and IE 6.0.
Changed 7 years ago by steffenp@…
- Attachment align-custom-fields-r1705.diff added
updated patch to current svn
comment:4 Changed 7 years ago by mgood
- Resolution set to fixed
- Status changed from assigned to closed
This has actually been fixed at some point, but I don't know which revision.
comment:5 Changed 7 years ago by pkou at ua.fm
- Resolution fixed deleted
- Status changed from closed to reopened
Custom fields added after a custom field with type textarea cannot be adjusted automatically and look ugly.
Tested on trunk [1850]
Example custom fields:
[ticket-custom] test_cases = textarea test_cases.order = 1 test_cases.label = Test cases test_cases.cols = 10 test_cases.rows = 2 info = text info.order = 2 info.label = Info keywords2 = textarea keywords2.order = 3 keywords2.label = Other keywords keywords2.cols = 70 keywords2.rows = 3 info2 = text info.order = 4 info.label = Info 2
comment:6 Changed 7 years ago by cboos
- Owner changed from mgood to cboos
- Status changed from reopened to new
I think that should fix it:
-
templates/newticket.cs
85 85 /if ?></td><?cs 86 86 if:idx % 2 ?></tr><tr><?cs 87 87 elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 88 /if ?><?cs set:idx = idx + #fullrow +1 ?><?cs88 /if ?><?cs set:idx = idx + 1 ?><?cs 89 89 /if ?><?cs 90 90 /each ?></tr> 91 91 </table> -
templates/ticket.cs
67 67 var:name(field) ?>"><?cs var:ticket[name(field)] ?></td><?cs 68 68 if:idx % 2 ?></tr><tr><?cs 69 69 elif:idx == num_fields - 1 ?><th></th><td></td><?cs 70 /if ?><?cs set:idx = idx + #fullrow +1 ?><?cs70 /if ?><?cs set:idx = idx + 1 ?><?cs 71 71 /if ?><?cs 72 72 /each ?></tr> 73 73 </table> … … 207 207 /if ?></td><?cs 208 208 if:idx % 2 ?></tr><tr><?cs 209 209 elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 210 /if ?><?cs set:idx = idx + #fullrow +1 ?><?cs210 /if ?><?cs set:idx = idx + 1 ?><?cs 211 211 /if ?><?cs 212 212 /each ?></tr> 213 213 </table>
comment:7 Changed 7 years ago by cboos
Another attempt:
-
templates/ticket.cs
65 65 <th id="h_<?cs var:name(field) ?>"><?cs var:field.label ?>:</th> 66 66 <td<?cs if:fullrow ?> colspan="3"<?cs /if ?> headers="h_<?cs 67 67 var:name(field) ?>"><?cs var:ticket[name(field)] ?></td><?cs 68 if:idx % 2 ?></tr><tr><?cs68 if:idx % 2 || fullrow ?></tr><tr><?cs 69 69 elif:idx == num_fields - 1 ?><th></th><td></td><?cs 70 70 /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 71 71 /if ?><?cs … … 173 173 /each ?><?cs set:idx = 0 ?><?cs 174 174 each:field = ticket.fields ?><?cs 175 175 if:!field.skip ?><?cs set:fullrow = field.type == 'textarea' ?><?cs 176 if:fullrow && idx % 2 ?>< th class="col2"></th><td></td></tr><tr><?cs /if ?>176 if:fullrow && idx % 2 ?><?cs set:idx = idx + 1 ?><th class="col2"></th><td></td></tr><tr><?cs /if ?> 177 177 <th class="col<?cs var:idx % 2 + 1 ?>"><?cs 178 178 if:field.type != 'radio' ?><label for="<?cs var:name(field) ?>"><?cs 179 179 /if ?><?cs alt:field.label ?><?cs var:field.name ?><?cs /alt ?>:<?cs … … 205 205 var:option ?></label> <?cs set:optidx = optidx + 1 ?><?cs 206 206 /each ?><?cs 207 207 /if ?></td><?cs 208 if:idx % 2 ?></tr><tr><?cs208 if:idx % 2 || fullrow ?></tr><tr><?cs 209 209 elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 210 210 /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 211 211 /if ?><?cs -
templates/newticket.cs
52 52 /each ?><?cs set:idx = 0 ?><?cs 53 53 each:field = newticket.fields ?><?cs 54 54 if:!field.skip ?><?cs set:fullrow = field.type == 'textarea' ?><?cs 55 if:fullrow && idx % 2 ?>< th class="col2"></th><td></td></tr><tr><?cs /if ?>55 if:fullrow && idx % 2 ?><?cs set:idx = idx + 1 ?><th class="col2"></th><td></td></tr><tr><?cs /if ?> 56 56 <th class="col<?cs var:idx % 2 + 1 ?>"><?cs 57 57 if:field.type != 'radio' ?><label for="<?cs var:name(field) ?>"><?cs 58 58 /if ?><?cs alt:field.label ?><?cs var:field.name ?><?cs /alt ?>:<?cs … … 83 83 var:option ?></label> <?cs set:optidx = optidx + 1 ?><?cs 84 84 /each ?><?cs 85 85 /if ?></td><?cs 86 if:idx % 2 ?></tr><tr><?cs86 if:idx % 2 || fullrow ?></tr><tr><?cs 87 87 elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 88 88 /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 89 89 /if ?><?cs
The rational is that when idx is even, the field is put in col1.
When there's a fullrow field (only textarea for now):
- the previous row is closed if it was only half filled (i.e. idx was odd). idx is then incremented, so that this fullrow field can start in col1 (that's the <?cs set:idx = idx + 1 ?> addition)
- the row is closed after the fullrow (that's the || fullrow change), notwithstanding the fact that the idx is even. The idx will be correctly incremented afterwards (because of the + #fullrow).
comment:8 Changed 7 years ago by cboos
Applied previous patch in r2002
comment:9 Changed 7 years ago by cboos
- Resolution set to fixed
- Status changed from new to closed
... which should close this ticket.
Note that the patches provided by the ticket author
apply to an old way of doing the layout of ticket fields:
they are not relevant anymore.



Example [ticket-custom] setup for trac.ini