Skip to content

Commit 372c077

Browse files
committed
custom fields+
1 parent 76c63db commit 372c077

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

accounts.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
</tr>
154154
<? endforeach ?>
155155
<tr>
156-
<th>Tempo</th>
156+
<th align="right">Tempo</th>
157157
<td><a href="tempo.php">probably <?= $user->has_tempo ? '' : 'not' ?></a></td>
158158
</tr>
159159
<tr valign="top">
@@ -170,6 +170,20 @@
170170
<? endforeach ?>
171171
</td>
172172
</tr>
173+
<tr valign="top">
174+
<th align="right">Show custom fields</th>
175+
<td>
176+
<? foreach ($user->custom_field_ids as $name => $id):
177+
$checked = in_array($id, $user->selected_show_custom_fields) ? 'checked' : '';
178+
?>
179+
<label>
180+
<input type="checkbox" name="config[show_custom_fields][]" value="<?= $id ?>" <?= $checked ?> />
181+
<span class="board-id">(<?= $id ?>)</span>
182+
<?= html($name) ?>
183+
</label>
184+
<? endforeach ?>
185+
</td>
186+
</tr>
173187
</table>
174188
<p><button>Save</button></p>
175189
</form>

inc.user.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class User extends db_generic_record {
3232
'required' => false,
3333
),
3434
'agile_view_ids' => FALSE,
35+
'show_custom_fields' => FALSE,
3536
);
3637

3738
function __construct() {
@@ -191,6 +192,7 @@ function get_custom_field_ids() {
191192
$fields[mb_strtolower($field->name)] = $field->id;
192193
}
193194

195+
ksort($fields);
194196
$this->cache__custom_field_ids = serialize($fields);
195197
$this->save(array('cache__custom_field_ids' => $this->cache__custom_field_ids));
196198
}
@@ -204,6 +206,12 @@ function get_selected_agile_boards() {
204206
return $ids;
205207
}
206208

209+
function get_selected_show_custom_fields() {
210+
$ids = $this->config('show_custom_fields', '');
211+
$ids = array_filter(explode(',', $ids));
212+
return $ids;
213+
}
214+
207215
function get_agile_boards() {
208216
if ( !$this->cache__agile_boards ) {
209217
$boards = jira_get('/rest/agile/1.0/board');

issue.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@
179179
echo '<div class="issue-description markup">' . ( do_remarkup($issue->renderedFields->description) ?: '<em>No description</em>' ) . '</div>';
180180

181181
$customs = array();
182-
foreach ( $user->custom_field_ids as $cfName => $cfKey ) {
182+
foreach ( $user->selected_show_custom_fields as $cfKey ) {
183+
$cfName = array_search($cfKey, $user->custom_field_ids);
183184
if ( $value = @$issue->renderedFields->$cfKey ) {
184185
$customs[$cfName] = print_r($value, 1);
185186
}
@@ -188,7 +189,7 @@
188189
}
189190
}
190191

191-
if ( $customs ) {
192+
if ( count($customs) ) {
192193
echo '<h2 class="visiblity-toggle-header open"><a id="custom-fields-toggler" href="#">' . count($customs) . ' custom fields</a></h2>';
193194
echo '<div class="custom-fields">';
194195
foreach ($customs as $cfName => $text) {
@@ -202,7 +203,7 @@
202203
?>
203204
<script>
204205
(function(a) {
205-
a.parentNode.classList.remove('open');
206+
// a.parentNode.classList.remove('open');
206207
a.addEventListener('click', function(e) {
207208
e.preventDefault();
208209
var h2 = this.parentNode;

0 commit comments

Comments
 (0)