TracTicketsCustomFields のバージョン 1 とバージョン 2 との変更
- 日時:
- 2015/05/27 0:24:03 (11年前)
凡例:
- 変更なし
- 追加
- 削除
- 更新
-
TracTicketsCustomFields
v1 v2 1 = Custom Ticket Fields =2 Trac supports adding custom, user-defined fields to the ticket module. Using custom fields, you can add typed, site-specific properties to tickets.1 = カスタムチケット属性 = #CustomTicketFields 2 Trac ではチケットにユーザ定義の属性を追加できます。カスタムチケット属性を使用すると、型付けされた、プロジェクト特有のプロパティをチケットに持たせることができます。 3 3 4 == Configuration ==5 Configuring custom ticket fields is done in the [wiki:TracIni trac.ini] file. All field definitions should be under a section named `[ticket-custom]`. 4 == 設定方法 == #Configuration 5 カスタムチケット属性を設定するためには、 [wiki:TracIni trac.ini] ファイルを変更します。カスタムフィールドは、 trac.ini ファイルの `[ticket-custom]` セクションに書く必要があります。 6 6 7 The syntax of each field definition is:7 各属性の定義は以下のように記述します: 8 8 {{{ 9 FIELD_NAME = TYPE10 ( FIELD_NAME.OPTION = VALUE)9 属性名 = タイプ 10 (属性名.オプション = 値) 11 11 ... 12 12 }}} 13 The example below should help to explain the syntax. 13 構文の詳細は以下の例を見てください。 14 14 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'') 15 === 属性のタイプとオプション === #AvailableFieldTypesandOptions 16 * '''text''': シンプルな(1行の)テキスト 17 * label: 説明となるラベル 18 * value: デフォルト値 19 * order: ソート時の並び順 (全てのカスタムフィールドで共通するソートの並び順) 20 * format: 21 * 通常のテキストを指す `plain` 22 * WikiFormatting として整形を行う `wiki` (''0.11.3 以降'') 23 * 参照可能な値として整形を行う `reference` (''1.0 以降'') 24 * スペースで区切られた参照可能なリストとして整形を行う `list` のいずれかを指定する(''1.0 以降'') 25 * '''checkbox''': ブーリアン値をもつチェックボックス 26 * label: 説明となるラベル 27 * value: デフォルト値 (0 または 1) 28 * order: ソート時の並び順 29 * '''select''': ドロップダウンするリストボックス 30 * label: 説明となるラベル 31 * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述 32 * value: デフォルト値 (options の値から一つを指定) 33 * order: ソート時の並び順 34 * '''radio''': ラジオボタン。 HTML の '''select''' 要素と同じ 35 * label: 説明となるラベル 36 * options: リストに表示する値を '''|''' (vertical pipe) 区切りで記述 37 * value: デフォルト値 (options の値から一つを指定) 38 * order: ソート時の並び順 39 * '''textarea''': 複数行のテキストエリア 40 * label: 説明となるラベル 41 * value: デフォルトで設定されるテキスト 42 * cols: 入力領域のカラム幅 43 * rows: 入力領域の行数 44 * order: ソート時の並び順 45 * format: 通常のテキストを指す `plain` もしくは WikiFormatting として整形を行う `wiki` のいずれかを指定する (''0.11.3 以降'') 42 46 43 === Sample Config ===47 === サンプル === #SampleConfig 44 48 {{{ 45 49 [ticket-custom] … … 74 78 }}} 75 79 76 ''Note: To make entering an option for a `select` type field optional, specify a leading `|` in the `fieldname.options` option.''80 ''Note: `select` タイプのフィールドを非必須 (optional) にしたい場合、 `フィールド名.options` オプションの先頭に `バーティカルパイプ (|)` を設定してください。'' 77 81 78 === Reports Involving Custom Fields ===82 === カスタム属性を含むレポート === #ReportsInvolvingCustomFields 79 83 80 Custom 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`. 84 カスタムチケット属性は `ticket` テーブルに保存されるのではなく、 `ticket_custom` テーブルに保存されます。したがって、レポートのカスタム属性を表示するためには `ticket` と `ticket_custom` の 2 テーブルを join する必要があります。 `progress` と設定されたカスタムチケット属性の使用例を示します。 81 85 82 86 {{{ … … 89 93 ORDER BY p.value 90 94 }}} 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.95 '''Note''' この例は progress が設定されたチケットだけを表示します。'''すべてのチケットを表示するのではありません。'''既にいくつかのチケットを作成した''後で''カスタムチケット属性を定義した場合、既に作成されたチケットにはカスタムチケット属性が定義されません。そのため上記のクエリではチケットが表示されないでしょう。既に作成されたチケットにカスタム属性を設定し直せば、カスタムチケット属性は定義されます。そして、上記のクエリによって表示されるでしょう。 92 96 93 However, 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. 97 しかし、すべてのチケットエントリを ( progress が定義されていないエントリーも一緒に ) 表示したいのであれば、クエリにおいてあらゆるカスタムフィールドに `JOIN` を使用する必要があります。 94 98 {{{ 95 99 #!sql … … 108 112 }}} 109 113 110 Note in particular the `LEFT OUTER JOIN` statement here. 114 この `LEFT OUTER JOIN` ステートメントに特に注意してください。 111 115 112 === Updating the database ===116 === データベースを更新する === #Updatingthedatabase 113 117 114 As 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:118 上記に記述したとおり、カスタムフィールド設定以前に作成されたチケットには、該当するフィールドの値が定義されていない状態になります。以下のような SQL を Trac のデータベースで直接実行することで、カスタムフィールドの初期値を設定することができます (SQLite 向けの SQL ですので、 DBMS に応じて調整してください)。カスタムフィールド 'request_source' が存在しない、全てのチケットにデフォルト値 'None' が挿入されます: 115 119 116 120 {{{ … … 118 122 INSERT INTO ticket_custom 119 123 (ticket, name, value) 120 SELECT 124 SELECT 121 125 id AS ticket, 122 126 'request_source' AS name, 123 127 'None' AS value 124 FROM ticket 128 FROM ticket 125 129 WHERE id NOT IN ( 126 130 SELECT ticket FROM ticket_custom … … 128 132 }}} 129 133 130 If 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:134 複数のカスタムフィールドを追加している場合、 {{{ticket}}} 表への副問合わせで対象となるカスタムフィールドの名前を指定しなければなりません (訳注: 通常は上記の例ではなく、こちらを使うといいでしょう): 131 135 132 136 {{{ … … 134 138 INSERT INTO ticket_custom 135 139 (ticket, name, value) 136 SELECT 140 SELECT 137 141 id AS ticket, 138 142 'request_source' AS name, 139 143 'None' AS value 140 FROM ticket 144 FROM ticket 141 145 WHERE id NOT IN ( 142 146 SELECT ticket FROM ticket_custom WHERE name = 'request_source'
![(please configure the [header_logo] section in trac.ini)](/python/trac/mypz/chrome/common/trac_logo_mini.png)