Skip to content

Commit ac52ba6

Browse files
dustinhuynhbrendanheywood
authored andcommitted
Make checkbox labels coloured to match the charts #177
1 parent 0adedaa commit ac52ba6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

collector/database/chart.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@
6767
$displayedmetrics[] = $m->get_name();
6868
$displayed = true;
6969
}
70-
71-
$checkboxes[] = ['checkbox' => html_writer::checkbox($m->get_name(), 1, $displayed, $m->get_label(),
72-
['onchange' => 'this.form.submit()'])];
70+
$checkbox = html_writer::checkbox($m->get_name(), 1, $displayed, '',
71+
['id' => $m->get_name(), 'onchange' => 'this.form.submit()']);
72+
$label = html_writer::tag('label', $m->get_label(), ['for' => $m->get_name(), 'style' => 'display:inline-block; margin: 0;']);
73+
$color = html_writer::tag('span', '',
74+
['style' => 'display: inline-block; width: 2.5em; height: 1em; background-color: ' . $m->get_colour() . '; margin: 0 6px; vertical-align: middle;']);
75+
$checkboxes[] = [
76+
'checkbox' => html_writer::tag('div', $checkbox . $color . $label, [
77+
'style' => 'display: inline-flex; align-items: center; margin-right: 16px;',
78+
]),
79+
];
7380

7481
if (!in_array($m->group, $groups) && !empty($m->group)) {
7582
$groups += [$m->group => get_string($m->group, 'tool_cloudmetrics')];
@@ -304,7 +311,7 @@
304311
$context['checkboxes'] = $checkboxes;
305312
$context['metriclabel'] = $context['metriclabel'] ?? get_string('multiplemetrics', 'cltr_database');
306313
$context['frequency'] = html_writer::empty_tag('input',
307-
array('type' => 'hidden', 'name' => 'graphfrequency', 'value' => $displayfrequency));
314+
['type' => 'hidden', 'name' => 'graphfrequency', 'value' => $displayfrequency]);
308315
$renderer = $PAGE->get_renderer('tool_cloudmetrics');
309316

310317
echo $OUTPUT->header();

tests/tool_cloudmetrics_collect_metrics_test.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ public function receive(array $names) {
5858
*/
5959
class helper_collect_metrics_task extends collect_metrics_task {
6060

61-
/**
62-
* @var object mock variable
63-
*/
64-
public $mock;
65-
6661
/**
6762
* Constructer for helper_collect_metrics_task
6863
*

0 commit comments

Comments
 (0)