Changes between Version 2 and Version 3 of TracTicketsCustomFields


Ignore:
Timestamp:
Dec 31, 2005, 4:43:10 PM (18 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v2 v3  
    1 = カスタムチケット属性 =
    2 Trac ではチケットにユーザ定義の属性を追加できます。カスタムチケット属性を使用すると、定型で、プロジェクト特有のプロパティをチケットに持たせることができます。
     1= Custom Ticket Fields =
     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: Trac 0.8 では、この機能は、まだ実験段階です。'''
     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]`.
    56
    6 == 設定方法 ==
    7 カスタムチケット属性を設定するためには、 TracIni 設定ファイルを変更します。
    8 
    9 カスタムフィールドは、 trac.ini ファイルの [ticket-custom] セクションに書く必要があります。
    10 
    11 各属性の定義は以下のように記述します:
     7The syntax of each field definition is:
    128{{{
    13  属性名 = タイプ
    14  (属性名.オプション = 値)
     9 FIELD_NAME = TYPE
     10 (FIELD_NAME.OPTION = VALUE)
    1511 ...
    1612}}}
    17 構文の詳細は以下の例を見てください。
     13The example below should help to explain the syntax.
    1814
    19 === 属性のタイプとオプション ===
    20  * '''text''': シンプルな(1行の)テキスト。
    21    * label: 説明となるラベル
    22    * value: デフォルト値
    23    * order: ソート時の並び順 (フォーム内での相対的位置を決定します。)
    24  * '''checkbox''': ブーリアン値をもつチェックボックス。
    25    * label: 説明となるラベル。
    26    * value: デフォルト値 (0 または 1).
    27    * order: ソート時の並び順
    28  * '''select''': ドロップダウンするリストボックス。
    29    * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述。
    30    * value: デフォルト値 (0から始まるリスト内での番号) 。
    31    * order: ソート時の並び順
    32  * '''radio''': ラジオボタン。HTMLの '''select''' 要素と同じ。
    33    * label: 説明となるラベル。
    34    * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述。
    35    * value: デフォルト値 (0から始まるリスト内での番号) 。
    36    * order: ソート時の並び順
    37  * '''textarea''': 複数行のテキストエリア。
    38    * label: 説明となるラベル。
    39    * value: デフォルトで設定されるテキスト。
    40    * width: 入力領域のカラム幅。
    41    * height: 入力領域の行数。
    42    * order: ソート時の並び順
     15=== Available Field Types and Options ===
     16 * '''text''': A simple (one line) text field.
     17   * label: Descriptive label.
     18   * value: Default value.
     19   * order: Sort order placement. (Determines relative placement in forms.)
     20 * '''checkbox''': A boolean value check box.
     21   * label: Descriptive label.
     22   * value: Default value (0 or 1).
     23   * order: Sort order placement.
     24 * '''select''': Drop-down select box. Uses a list of values.
     25   * options: List of values, separated by '''|''' (vertical pipe).
     26   * value: Default value (Item #, starting at 0).
     27   * order: Sort order placement.
     28 * '''radio''': Radio buttons. Essentially the same as '''select'''.
     29   * label: Descriptive label.
     30   * options: List of values, separated by '''|''' (vertical pipe).
     31   * value: Default value (Item #, starting at 0).
     32   * order: Sort order placement.
     33 * '''textarea''': Multi-line text area.
     34   * label: Descriptive label.
     35   * value: Default text.
     36   * cols: Width in columns.
     37   * rows: Height in lines.
     38   * order: Sort order placement.
    4339
    44 === サンプル ===
     40=== Sample Config ===
    4541{{{
    4642[ticket-custom]
     43
    4744test_one = text
    4845test_one.label = Just a text box
     
    6966test_six.label = This is a large textarea
    7067test_six.value = Default text
    71 test_six.width = 60
    72 test_six.height = 30
     68test_six.cols = 60
     69test_six.rows = 30
    7370}}}
    7471
     72''Note: To make an entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.''
     73
     74=== Reports Involving Custom Fields ===
     75
     76The 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.
     77
     78The following example includes a custom ticket field named `progress` in the report:
     79{{{
     80#!sql
     81SELECT p.value AS __color__,
     82   id AS ticket, summary, component, version, milestone, severity,
     83   (CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner,
     84   time AS created,
     85   changetime AS _changetime, description AS _description,
     86   reporter AS _reporter,
     87  (CASE WHEN c.value = '0' THEN 'None' ELSE c.value END) AS progress
     88  FROM ticket t
     89     LEFT OUTER JOIN ticket_custom c ON (t.id = c.ticket AND c.name = 'progress')
     90     JOIN enum p ON p.name = t.priority AND p.type='priority'
     91  WHERE status IN ('new', 'assigned', 'reopened')
     92  ORDER BY p.value, milestone, severity, time
     93}}}
     94
     95Note in particular the `LEFT OUTER JOIN` statement here.
     96
    7597----
    76 参考: TracTickets, TracIni
     98See also: TracTickets, TracIni