Edgewall Software
Modify

Opened 20 years ago

Closed 19 years ago

#926 closed enhancement (fixed)

[PATCH] Allow aligning custom fields by specifying CSS style for them

Reported by: pkou <pkou at ua.fm> Owned by: Christian Boos
Priority: normal Milestone: 0.9
Component: ticket system Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal 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 (7)

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

Download all attachments as: .zip

Change History (16)

by pkou <pkou at ua.fm>, 20 years ago

Attachment: customalign.ini added

Example [ticket-custom] setup for trac.ini

by pkou <pkou at ua.fm>, 20 years ago

Attachment: customalign.png added

Result of using customalign.ini on the patch

by pkou <pkou at ua.fm>, 20 years ago

Patch for the changes

comment:1 by steffenp@…, 20 years ago

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.

by stp, 20 years ago

Attachment: custom-field-alignment.png added

comment:2 by Matthew Good, 20 years ago

Milestone: 0.9
Owner: changed from Jonas Borgström to Matthew Good
Status: newassigned

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.

by steffenp@…, 20 years ago

Fixed alignment of radio buttons

comment:3 by steffenp@…, 20 years ago

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

by steffenp@…, 19 years ago

updated patch to current svn

comment:4 by Matthew Good, 19 years ago

Resolution: fixed
Status: assignedclosed

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

comment:5 by pkou at ua.fm, 19 years ago

Resolution: fixed
Status: closedreopened

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 by Christian Boos, 19 years ago

Owner: changed from Matthew Good to Christian Boos
Status: reopenednew

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>

comment:7 by Christian Boos, 19 years ago

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

comment:8 by Christian Boos, 19 years ago

Applied previous patch in r2002

comment:9 by Christian Boos, 19 years ago

Resolution: fixed
Status: newclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.