Edgewall Software

Ticket #926 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 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:

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

customalign.ini (2.0 KB) - added by pkou <pkou at ua.fm> 4 years ago.
Example [ticket-custom] setup for trac.ini
customalign.png (5.5 KB) - added by pkou <pkou at ua.fm> 4 years ago.
Result of using customalign.ini on the patch
patch-customalign-r1049.diff (4.1 KB) - added by pkou <pkou at ua.fm> 4 years ago.
Patch for the changes
custom-field-alignment.png (21.9 KB) - added by stp 4 years ago.
align-custom-fields-r1579.diff (3.3 KB) - added by stp 4 years ago.
align-custom-fields-r1634.diff (3.8 KB) - added by steffenp@… 4 years ago.
Fixed alignment of radio buttons
align-custom-fields-r1705.diff (3.8 KB) - added by steffenp@… 4 years ago.
updated patch to current svn

Change History

Changed 4 years ago by pkou <pkou at ua.fm>

Example [ticket-custom] setup for trac.ini

Changed 4 years ago by pkou <pkou at ua.fm>

Result of using customalign.ini on the patch

Changed 4 years ago by pkou <pkou at ua.fm>

Patch for the changes

Changed 4 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 4 years ago by stp

Changed 4 years ago by stp

Changed 4 years ago by mgood

  • owner changed from jonas to mgood
  • status changed from new to assigned
  • milestone set to 0.9

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 4 years ago by steffenp@…

Fixed alignment of radio buttons

Changed 4 years ago by steffenp@…

I have attached an improved patch that has been tested with konqueror, firefox and IE 6.0.

Changed 4 years ago by steffenp@…

updated patch to current svn

Changed 3 years ago by mgood

  • status changed from assigned to closed
  • resolution set to fixed

This has actually been fixed at some point, but I don't know which revision.

Changed 3 years ago by pkou at ua.fm

  • status changed from closed to reopened
  • resolution fixed deleted

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

Changed 3 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

     
    8585      /if ?></td><?cs 
    8686     if:idx % 2 ?></tr><tr><?cs 
    8787     elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 
    88      /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 
     88     /if ?><?cs set:idx = idx + 1 ?><?cs 
    8989    /if ?><?cs 
    9090   /each ?></tr> 
    9191  </table> 
  • templates/ticket.cs

     
    6767      var:name(field) ?>"><?cs var:ticket[name(field)] ?></td><?cs 
    6868    if:idx % 2 ?></tr><tr><?cs 
    6969    elif:idx == num_fields - 1 ?><th></th><td></td><?cs 
    70     /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 
     70    /if ?><?cs set:idx = idx + 1 ?><?cs 
    7171   /if ?><?cs 
    7272  /each ?></tr> 
    7373 </table> 
     
    207207      /if ?></td><?cs 
    208208     if:idx % 2 ?></tr><tr><?cs 
    209209     elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 
    210      /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 
     210     /if ?><?cs set:idx = idx + 1 ?><?cs 
    211211    /if ?><?cs 
    212212   /each ?></tr> 
    213213  </table> 

Changed 3 years ago by cboos

Another attempt:

  • templates/ticket.cs

     
    6565    <th id="h_<?cs var:name(field) ?>"><?cs var:field.label ?>:</th> 
    6666    <td<?cs if:fullrow ?> colspan="3"<?cs /if ?> headers="h_<?cs 
    6767      var:name(field) ?>"><?cs var:ticket[name(field)] ?></td><?cs 
    68     if:idx % 2 ?></tr><tr><?cs 
     68    if:idx % 2 || fullrow ?></tr><tr><?cs 
    6969    elif:idx == num_fields - 1 ?><th></th><td></td><?cs 
    7070    /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 
    7171   /if ?><?cs 
     
    173173  /each ?><?cs set:idx = 0 ?><?cs 
    174174   each:field = ticket.fields ?><?cs 
    175175    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 ?> 
    177177     <th class="col<?cs var:idx % 2 + 1 ?>"><?cs 
    178178       if:field.type != 'radio' ?><label for="<?cs var:name(field) ?>"><?cs 
    179179       /if ?><?cs alt:field.label ?><?cs var:field.name ?><?cs /alt ?>:<?cs 
     
    205205         var:option ?></label> <?cs set:optidx = optidx + 1 ?><?cs 
    206206        /each ?><?cs 
    207207      /if ?></td><?cs 
    208      if:idx % 2 ?></tr><tr><?cs 
     208     if:idx % 2 || fullrow ?></tr><tr><?cs 
    209209     elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 
    210210     /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 
    211211    /if ?><?cs 
  • templates/newticket.cs

     
    5252  /each ?><?cs set:idx = 0 ?><?cs 
    5353   each:field = newticket.fields ?><?cs 
    5454    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 ?> 
    5656     <th class="col<?cs var:idx % 2 + 1 ?>"><?cs 
    5757       if:field.type != 'radio' ?><label for="<?cs var:name(field) ?>"><?cs 
    5858       /if ?><?cs alt:field.label ?><?cs var:field.name ?><?cs /alt ?>:<?cs 
     
    8383         var:option ?></label> <?cs set:optidx = optidx + 1 ?><?cs 
    8484       /each ?><?cs 
    8585      /if ?></td><?cs 
    86      if:idx % 2 ?></tr><tr><?cs 
     86     if:idx % 2 || fullrow ?></tr><tr><?cs 
    8787     elif:idx == num_fields - 1 ?><th class="col2"></th><td></td><?cs 
    8888     /if ?><?cs set:idx = idx + #fullrow + 1 ?><?cs 
    8989    /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).

Changed 3 years ago by cboos

Applied previous patch in r2002

Changed 3 years ago by cboos

  • status changed from new to closed
  • resolution set to fixed

... 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.

Add/Change #926 ([PATCH] Allow aligning custom fields by specifying CSS style for them)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from cboos. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.