Changes between Version 1 and Version 2 of TracTicketsCustomFields


Ignore:
Timestamp:
09/26/06 13:01:24 (18 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v1 v2  
    11= Custom Ticket Fields = 
    2 Trac support adding custom, user-defined, fields to the ticket module. Using custom fields, you can add typed, site-specific, properties to tickets. 
     2Trac supports adding custom, user-defined fields to the ticket module. Using custom fields, you can add typed, site-specific properties to tickets. 
    33 
    4 '''Note: In Trac 0.8, this feature is still experimental.''' 
    5  
    6 == Configuriation == 
    7 Configuring custom ticket fields is done in the TracIni config file. 
    8  
    9 All field definitions should be under a section named [ticket-custom] in the ini-file. 
     4== Configuration == 
     5Configuring custom ticket fields is done in the [wiki:TracIni trac.ini] file. All field definitions should be under a section named `[ticket-custom]`. 
    106 
    117The syntax of each field definition is: 
     
    1511 ... 
    1612}}} 
    17 Looking at the example below should help explain the syntax. 
     13The example below should help to explain the syntax. 
    1814 
    1915=== Available Field Types and Options === 
     
    2723   * order: Sort order placement. 
    2824 * '''select''': Drop-down select box. Uses a list of values. 
     25   * label: Descriptive label. 
    2926   * options: List of values, separated by '''|''' (vertical pipe). 
    3027   * value: Default value (Item #, starting at 0). 
     
    3835   * label: Descriptive label. 
    3936   * value: Default text. 
    40    * width: Width in columns. 
    41    * height: Height in lines. 
     37   * cols: Width in columns. 
     38   * rows: Height in lines. 
    4239   * order: Sort order placement. 
    4340 
     
    4542{{{ 
    4643[ticket-custom] 
     44 
    4745test_one = text 
    4846test_one.label = Just a text box 
     
    6967test_six.label = This is a large textarea 
    7068test_six.value = Default text 
    71 test_six.width = 60 
    72 test_six.height = 30 
     69test_six.cols = 60 
     70test_six.rows = 30 
    7371}}} 
     72 
     73''Note: To make entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.'' 
     74 
     75=== Reports Involving Custom Fields === 
     76 
     77The SQL required for TracReports to include custom ticket fields is relatively hard to get right. You need a `JOIN` with the `ticket_custom` field for every custom field that should be involved. 
     78 
     79The following example includes a custom ticket field named `progress` in the report: 
     80{{{ 
     81#!sql 
     82SELECT p.value AS __color__, 
     83   id AS ticket, summary, component, version, milestone, severity, 
     84   (CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner, 
     85   time AS created, 
     86   changetime AS _changetime, description AS _description, 
     87   reporter AS _reporter, 
     88  (CASE WHEN c.value = '0' THEN 'None' ELSE c.value END) AS progress 
     89  FROM ticket t 
     90     LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name = 'progress') 
     91     JOIN enum p ON p.name = t.priority AND p.type='priority' 
     92  WHERE status IN ('new', 'assigned', 'reopened') 
     93  ORDER BY p.value, milestone, severity, time 
     94}}} 
     95 
     96Note in particular the `LEFT OUTER JOIN` statement here. 
    7497 
    7598----