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'') |
78 | | 以下の例は `progress` という名前のカスタム属性を含むレポートです: |
| 82 | {{{ |
| 83 | #!sql |
| 84 | SELECT 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' |
| 88 | AND 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 | |
| 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. |
95 | | この `LEFT OUTER JOIN` ステートメントに特に注意してください。 |
| 110 | Note in particular the `LEFT OUTER JOIN` statement here. |
| 111 | |
| 112 | === Updating the database === |
| 113 | |
| 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: |
| 115 | |
| 116 | {{{ |
| 117 | #!sql |
| 118 | INSERT 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 | |
| 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: |
| 131 | |
| 132 | {{{ |
| 133 | #!sql |
| 134 | INSERT 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 | }}} |