| 13 | | 構文の詳細は以下の例を見てください。 |
| 14 | | |
| 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 以降'') |
| 46 | | |
| 47 | | === サンプル === #SampleConfig |
| 48 | | {{{ |
| | 14 | |
| | 15 | The example below should help to explain the syntax. |
| | 16 | |
| | 17 | === Field Names |
| | 18 | A field name can only contain lowercase letters a-z, uppercase letters A-Z or digits 0-9, and must not start with a leading digit. |
| | 19 | |
| | 20 | The following field names are reserved and can not be used for custom fields: |
| | 21 | * cc |
| | 22 | * changetime |
| | 23 | * col |
| | 24 | * comment |
| | 25 | * component |
| | 26 | * desc |
| | 27 | * description |
| | 28 | * format |
| | 29 | * group |
| | 30 | * groupdesc |
| | 31 | * id |
| | 32 | * keywords |
| | 33 | * max |
| | 34 | * milestone |
| | 35 | * or |
| | 36 | * order |
| | 37 | * owner |
| | 38 | * page |
| | 39 | * priority |
| | 40 | * report |
| | 41 | * reporter |
| | 42 | * resolution |
| | 43 | * row |
| | 44 | * severity |
| | 45 | * status |
| | 46 | * summary |
| | 47 | * time |
| | 48 | * type |
| | 49 | * verbose |
| | 50 | * version |
| | 51 | |
| | 52 | === Available Field Types and Options |
| | 53 | |
| | 54 | * '''text''': A simple (one line) text field. |
| | 55 | * label: Descriptive label. |
| | 56 | * value: Default value. |
| | 57 | * order: Sort order placement relative to other custom fields. |
| | 58 | * max_size: Maximum allowed size in characters (//Since 1.3.2//). |
| | 59 | * format: One of: |
| | 60 | * `plain` for plain text |
| | 61 | * `wiki` for [WikiFormatting wiki formatted] content |
| | 62 | * `reference` to treat the content as a queryable value |
| | 63 | * `list` to interpret the content as a list of queryable values, separated by whitespace |
| | 64 | * ticketlink_query: Query for linkifying ticket values. |
| | 65 | Not applicable for format `plain` and `wiki`. |
| | 66 | * '''checkbox''': A boolean value check box. |
| | 67 | * label: Descriptive label. |
| | 68 | * value: Default value, 0 or 1. |
| | 69 | * order: Sort order placement. |
| | 70 | * ticketlink_query: Query for linkifying ticket values. |
| | 71 | * '''select''': Drop-down select box. Uses a list of values. |
| | 72 | * label: Descriptive label. |
| | 73 | * options: List of values, separated by '''|''' (vertical pipe). |
| | 74 | * value: Default value (one of the values from options). |
| | 75 | * order: Sort order placement. |
| | 76 | * ticketlink_query: Query for linkifying ticket values. |
| | 77 | * '''radio''': Radio buttons. Essentially the same as '''select'''. |
| | 78 | * label: Descriptive label. |
| | 79 | * options: List of values, separated by '''|''' (vertical pipe). |
| | 80 | * value: Default value, one of the values from options. |
| | 81 | * order: Sort order placement. |
| | 82 | * ticketlink_query: Query for linkifying ticket values. |
| | 83 | * '''textarea''': Multi-line text area. |
| | 84 | * label: Descriptive label. |
| | 85 | * value: Default text. |
| | 86 | * rows: Height in lines. |
| | 87 | * order: Sort order placement. |
| | 88 | * max_size: Maximum allowed size in characters (//Since 1.3.2//). |
| | 89 | * format: Either `plain` for plain text or `wiki` to interpret the content as WikiFormatting. |
| | 90 | * '''time''': Date and time picker. (//Since 1.1.1//) |
| | 91 | * label: Descriptive label. |
| | 92 | * value: Default date. |
| | 93 | * order: Sort order placement. |
| | 94 | * format: One of: |
| | 95 | * `relative` for relative dates. |
| | 96 | * `date` for absolute dates. |
| | 97 | * `datetime` for absolute date and time values. |
| | 98 | |
| | 99 | If the `label` is not specified, it will be created by capitalizing the custom field name and replacing underscores with whitespaces. |
| | 100 | |
| | 101 | Macros will be expanded when rendering `textarea` fields with format `wiki`, but not when rendering `text` fields with format `wiki`. |
| | 102 | |
| | 103 | For applicable fields, the `ticketlink_query` option |
| | 104 | overrides [[TracIni#query-ticketlink_query-option|"[query] ticketlink_query"]], and the format is the same as |
| | 105 | that option. When the `ticketlink_query` option |
| | 106 | is not specified, `[query]` `ticketlink_query` is used to |
| | 107 | linkify the field. |
| | 108 | |
| | 109 | === Sample Configuration |
| | 110 | |
| | 111 | {{{#!ini |
| 78 | | }}} |
| 79 | | |
| 80 | | ''Note: `select` タイプのフィールドを非必須 (optional) にしたい場合、 `フィールド名.options` オプションの先頭に `バーティカルパイプ (|)` を設定してください。'' |
| 81 | | |
| 82 | | === カスタム属性を含むレポート === #ReportsInvolvingCustomFields |
| 83 | | |
| 84 | | カスタムチケット属性は `ticket` テーブルに保存されるのではなく、 `ticket_custom` テーブルに保存されます。したがって、レポートのカスタム属性を表示するためには `ticket` と `ticket_custom` の 2 テーブルを join する必要があります。 `progress` と設定されたカスタムチケット属性の使用例を示します。 |
| 85 | | |
| 86 | | {{{ |
| 87 | | #!sql |
| | 141 | |
| | 142 | test_seven = time |
| | 143 | test_seven.label = A relative date |
| | 144 | test_seven.format = relative |
| | 145 | test_seven.value = now |
| | 146 | |
| | 147 | test_eight = time |
| | 148 | test_eight.label = An absolute date |
| | 149 | test_eight.format = date |
| | 150 | test_eight.value = yesterday |
| | 151 | |
| | 152 | test_nine = time |
| | 153 | test_nine.label = A date and time |
| | 154 | test_nine.format = datetime |
| | 155 | test_nine.value = in 2 hours |
| | 156 | }}} |
| | 157 | |
| | 158 | '''Note''': To make a `select` type field optional, specify a leading `|` in `fieldname.options` (e.g. `test_five`). |
| | 159 | |
| | 160 | === Reports Involving Custom Fields |
| | 161 | |
| | 162 | 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`. |
| | 163 | |
| | 164 | {{{#!sql |
| 114 | | この `LEFT OUTER JOIN` ステートメントに特に注意してください。 |
| 115 | | |
| 116 | | === データベースを更新する === #Updatingthedatabase |
| 117 | | |
| 118 | | 上記に記述したとおり、カスタムフィールド設定以前に作成されたチケットには、該当するフィールドの値が定義されていない状態になります。以下のような SQL を Trac のデータベースで直接実行することで、カスタムフィールドの初期値を設定することができます (SQLite 向けの SQL ですので、 DBMS に応じて調整してください)。カスタムフィールド 'request_source' が存在しない、全てのチケットにデフォルト値 'None' が挿入されます: |
| 119 | | |
| 120 | | {{{ |
| 121 | | #!sql |
| 122 | | INSERT INTO ticket_custom |
| 123 | | (ticket, name, value) |
| 124 | | SELECT |
| 125 | | id AS ticket, |
| 126 | | 'request_source' AS name, |
| 127 | | 'None' AS value |
| 128 | | FROM ticket |
| 129 | | WHERE id NOT IN ( |
| 130 | | SELECT ticket FROM ticket_custom |
| 131 | | ); |
| 132 | | }}} |
| 133 | | |
| 134 | | 複数のカスタムフィールドを追加している場合、 {{{ticket}}} 表への副問合わせで対象となるカスタムフィールドの名前を指定しなければなりません (訳注: 通常は上記の例ではなく、こちらを使うといいでしょう): |
| 135 | | |
| 136 | | {{{ |
| 137 | | #!sql |
| 138 | | INSERT INTO ticket_custom |
| 139 | | (ticket, name, value) |
| 140 | | SELECT |
| 141 | | id AS ticket, |
| 142 | | 'request_source' AS name, |
| 143 | | 'None' AS value |
| 144 | | FROM ticket |
| 145 | | WHERE id NOT IN ( |
| 146 | | SELECT ticket FROM ticket_custom WHERE name = 'request_source' |
| 147 | | ); |
| 148 | | }}} |
| | 190 | Note in particular the `LEFT OUTER JOIN` statement here. |
| | 191 | |
| | 192 | Note that option names in trac.ini are case-insensitive, so even if your option name includes uppercase characters: |
| | 193 | {{{#!ini |
| | 194 | [ticket-custom] |
| | 195 | Progress_Type = text |
| | 196 | }}} |
| | 197 | you must use '''lowercase''' in the SQL: `AND c.name = 'progress_type'`. |