Changes between Version 1 and Version 2 of TracTicketsCustomFields


Ignore:
Timestamp:
12/14/10 02:51:48 (13 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v1 v2  
    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 == 設定方法 == 
    5 カスタムチケット属性を設定するためには、 [wiki:TracIni trac.ini] ファイルを変更します。カスタムフィールドは、 trac.ini ファイルの `[ticket-custom]` セクションに書く必要があります。 
     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]`. 
    66 
    7 各属性の定義は以下のように記述します: 
     7The syntax of each field definition is: 
    88{{{ 
    9  属性名 = タイプ 
    10  (属性名.オプション = 値) 
     9 FIELD_NAME = TYPE 
     10 (FIELD_NAME.OPTION = VALUE) 
    1111 ... 
    1212}}} 
    13 構文の詳細は以下の例を見てください。 
     13The example below should help to explain the syntax. 
    1414 
    15 === 属性のタイプとオプション === 
    16  * '''text''': シンプルな(1行の)テキスト。 
    17    * label: 説明となるラベル 
    18    * value: デフォルト値 
    19    * order: ソート時の並び順 (フォーム内での相対的位置を決定します。) 
    20  * '''checkbox''': ブーリアン値をもつチェックボックス。 
    21    * label: 説明となるラベル。 
    22    * value: デフォルト値 (0 または 1). 
    23    * order: ソート時の並び順 
    24  * '''select''': ドロップダウンするリストボックス。 
    25    * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述。 
    26    * value: デフォルト値 (0から始まるリスト内での番号) 。 
    27    * order: ソート時の並び順 
    28  * '''radio''': ラジオボタン。HTMLの '''select''' 要素と同じ。 
    29    * label: 説明となるラベル。 
    30    * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述。 
    31    * value: デフォルト値 (0から始まるリスト内での番号) 。 
    32    * order: ソート時の並び順 
    33  * '''textarea''': 複数行のテキストエリア。 
    34    * label: 説明となるラベル。 
    35    * value: デフォルトで設定されるテキスト。 
    36    * cols: 入力領域のカラム幅。 
    37    * rows: 入力領域の行数。 
    38    * 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 with respect to other custom fields.) 
     20   * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. (''since 0.11.3'') 
     21 * '''checkbox''': A boolean value check box. 
     22   * label: Descriptive label. 
     23   * value: Default value (0 or 1). 
     24   * order: Sort order placement. 
     25 * '''select''': Drop-down select box. Uses a list of values. 
     26   * label: Descriptive label. 
     27   * options: List of values, separated by '''|''' (vertical pipe). 
     28   * value: Default value (one of the values from options). 
     29   * order: Sort order placement. 
     30 * '''radio''': Radio buttons. Essentially the same as '''select'''. 
     31   * label: Descriptive label. 
     32   * options: List of values, separated by '''|''' (vertical pipe). 
     33   * value: Default value (one of the values from options). 
     34   * order: Sort order placement. 
     35 * '''textarea''': Multi-line text area. 
     36   * label: Descriptive label. 
     37   * value: Default text. 
     38   * cols: Width in columns. 
     39   * rows: Height in lines. 
     40   * order: Sort order placement. 
     41   * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. (''since 0.11.3'') 
    3942 
    40 === サンプル === 
     43=== Sample Config === 
    4144{{{ 
    4245[ticket-custom] 
     
    4750test_two = text 
    4851test_two.label = Another text-box 
    49 test_two.value = Just a default value 
     52test_two.value = Default [mailto:joe@nospam.com owner] 
     53test_two.format = wiki 
    5054 
    5155test_three = checkbox 
     
    5660test_four.label = My selectbox 
    5761test_four.options = one|two|third option|four 
    58 test_four.value = 2 
     62test_four.value = two 
    5963 
    6064test_five = radio 
    6165test_five.label = Radio buttons are fun 
    6266test_five.options = uno|dos|tres|cuatro|cinco 
    63 test_five.value = 1 
     67test_five.value = dos 
    6468 
    6569test_six = textarea 
     
    7074}}} 
    7175 
    72 ''Note: `select` タイプのフィールドを非必須(optional)にしたい場合、 `フィールド名.options` オプションの先頭に `バーティカルパイプ (|)` を設定してください。'' 
     76''Note: To make entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.'' 
    7377 
    74 === カスタム属性を含むレポート === 
     78=== Reports Involving Custom Fields === 
    7579 
    76 カスタム属性を含む TracReports では比較的 SQL を間違えやすいです。 `ticket_custom` 表の `JOIN` はカスタム属性ごとにそれぞれ必要です。 
     80Custom ticket fields are stored in the `ticket_custom` table, not in the `ticket` table. So to display the values from custom fields in a report, you will need a join on the 2 tables. Let's use an example with a custom ticket field called `progress`. 
    7781 
    78 以下の例は `progress` という名前のカスタム属性を含むレポートです: 
     82{{{ 
     83#!sql 
     84SELECT p.value AS __color__, 
     85   id AS ticket, summary, owner, c.value AS progress 
     86  FROM ticket t, enum p, ticket_custom c 
     87  WHERE status IN ('assigned') AND t.id = c.ticket AND c.name = 'progress' 
     88AND p.name = t.priority AND p.type = 'priority' 
     89  ORDER BY p.value 
     90}}} 
     91'''Note''' that this will only show tickets that have progress set in them, which is '''not the same as showing all tickets'''. If you created this custom ticket field ''after'' you have already created some tickets, they will not have that field defined, and thus they will never show up on this ticket query. If you go back and modify those tickets, the field will be defined, and they will appear in the query. If that's all you want, you're set. 
     92 
     93However, if you want to show all ticket entries (with progress defined and without), you need to use a `JOIN` for every custom field that is in the query. 
    7994{{{ 
    8095#!sql 
     
    93108}}} 
    94109 
    95 この `LEFT OUTER JOIN` ステートメントに特に注意してください。 
     110Note in particular the `LEFT OUTER JOIN` statement here. 
     111 
     112=== Updating the database === 
     113 
     114As noted above, any tickets created before a custom field has been defined will not have a value for that field. Here's a bit of SQL (tested with SQLite) that you can run directly on the Trac database to set an initial value for custom ticket fields. Inserts the default value of 'None' into a custom field called 'request_source' for all tickets that have no existing value: 
     115 
     116{{{ 
     117#!sql 
     118INSERT INTO ticket_custom 
     119   (ticket, name, value) 
     120   SELECT  
     121      id AS ticket, 
     122      'request_source' AS name, 
     123      'None' AS value 
     124   FROM ticket  
     125   WHERE id NOT IN ( 
     126      SELECT ticket FROM ticket_custom 
     127   ); 
     128}}} 
     129 
     130If you added multiple custom fields at different points in time, you should be more specific in the subquery on table {{{ticket}}} by adding the exact custom field name to the query: 
     131 
     132{{{ 
     133#!sql 
     134INSERT INTO ticket_custom 
     135   (ticket, name, value) 
     136   SELECT  
     137      id AS ticket, 
     138      'request_source' AS name, 
     139      'None' AS value 
     140   FROM ticket  
     141   WHERE id NOT IN ( 
     142      SELECT ticket FROM ticket_custom WHERE name = 'request_source' 
     143   ); 
     144}}} 
    96145 
    97146----