XPressME Integration Kit

Trac

Version 1 から Version 2 における更新: TracTicketsCustomFields

差分発生行の前後
Ignore:
Timestamp:
Nov 29, 2010, 3:25:29 PM (13 years 前)
Author:
trac (IP: 127.0.0.1)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracTicketsCustomFields

    v1 v2  
    1 = カスタムチケット属性 = #CustomTicketFields 
    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 == 設定方法 == #Configuration 
    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 === 属性のタイプとオプション === #AvailableFieldTypesandOptions 
    16  * '''text''': シンプルな(1行の)テキスト。 
    17    * label: 説明となるラベル 
    18    * value: デフォルト値 
    19    * order: ソート時の並び順 (全てのカスタムフィールドで共通するソートの並び順) 
    20  * '''checkbox''': ブーリアン値をもつチェックボックス。 
    21    * label: 説明となるラベル。 
    22    * value: デフォルト値 (0 または 1). 
    23    * order: ソート時の並び順 
    24  * '''select''': ドロップダウンするリストボックス。 
    25    * label: 説明となるラベル。 
    26    * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述。 
    27    * value: デフォルト値 (options の値から一つを指定) 
    28    * order: ソート時の並び順 
    29  * '''radio''': ラジオボタン。 HTML の '''select''' 要素と同じ。 
    30    * label: 説明となるラベル。 
    31    * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述。 
    32    * value: デフォルト値 (options の値から一つを指定) 
    33    * order: ソート時の並び順 
    34  * '''textarea''': 複数行のテキストエリア。 
    35    * label: 説明となるラベル。 
    36    * value: デフォルトで設定されるテキスト。 
    37    * cols: 入力領域のカラム幅。 
    38    * rows: 入力領域の行数。 
    39    * 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'') 
    4042 
    41 === サンプル === #SampleConfig 
     43=== Sample Config === 
    4244{{{ 
    4345[ticket-custom] 
     
    4850test_two = text 
    4951test_two.label = Another text-box 
    50 test_two.value = Just a default value 
     52test_two.value = Default [mailto:joe@nospam.com owner] 
     53test_two.format = wiki 
    5154 
    5255test_three = checkbox 
     
    7174}}} 
    7275 
    73 ''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.'' 
    7477 
    75 === カスタム属性を含むレポート === #ReportsInvolvingCustomFields 
     78=== Reports Involving Custom Fields === 
    7679 
    77 カスタムチケット属性は `ticket` テーブルに保存されるのではなく、 `ticket_custom` テーブルに保存されます。したがって、レポートのカスタム属性を表示するためには `ticket` と `ticket_custom` の 2 テーブルを join する必要があります。 `progress` と設定されたカスタムチケット属性の使用例を示します。 
     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`. 
    7881 
    7982{{{ 
     
    8689  ORDER BY p.value 
    8790}}} 
    88 '''Note''' この例は progress が設定されたチケットだけを表示します。'''すべてのチケットを表示するのではありません。'''既にいくつかのチケットを作成した''後で''カスタムチケット属性を定義した場合、既に作成されたチケットにはカスタムチケット属性が定義されません。そのため上記のクエリではチケットが表示されないでしょう。既に作成されたチケットにカスタム属性を設定し直せば、カスタムチケット属性は定義されます。そして、上記のクエリによって表示されるでしょう。 
     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. 
    8992 
    90 しかし、すべてのチケットエントリを ( progress が定義されていないエントリーも一緒に ) 表示したいのであれば、クエリにおいてあらゆるカスタムフィールドに `JOIN` を使用する必要があります。 
     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. 
    9194{{{ 
    9295#!sql 
     
    105108}}} 
    106109 
    107 この `LEFT OUTER JOIN` ステートメントに特に注意してください。 
     110Note in particular the `LEFT OUTER JOIN` statement here. 
    108111 
    109 === データベースを更新する === #Updatingthedatabase 
     112=== Updating the database === 
    110113 
    111 上記に記述したとおり、カスタムフィールド設定以前に作成されたチケットには、該当するフィールドの値が定義されていない状態になります。以下のような SQL を Trac のデータベースで直接実行することで、カスタムフィールドの初期値を設定することができます (SQLite 向けの SQL ですので、 DBMS に応じて調整してください)。カスタムフィールド 'request_source' が存在しない、全てのチケットにデフォルト値 'None' が挿入されます: 
     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: 
    112115 
    113116{{{ 
     
    125128}}} 
    126129 
    127 複数のカスタムフィールドを追加している場合、 {{{ticket}}} 表への副問合わせで対象となるカスタムフィールドの名前を指定しなければなりません (訳注: 通常は上記の例ではなく、こちらを使うといいでしょう): 
     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: 
    128131 
    129132{{{