Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 374637a

Browse files
author
mgrauer
committed
Improve formatting of tracker module scalar details view.
The scalar details view displays rows of metrics with units. This commit rounds the float value of the scalars to 4 decimal places, aligns all of the values to the right for display, and splits out the units to a separate table column so they can also be right aligned for display. If the values and units were left in the same column it would be more difficult to align.
1 parent 79d41da commit 374637a

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

modules/tracker/models/pdo/ScalarModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function getOtherValuesFromSubmission($scalarDao)
116116

117117
/** @var Zend_Db_Table_Row_Abstract $row */
118118
foreach ($rows as $row) {
119-
$scalarDaos[$row['metric_name']] = $row['value'].' '.$row['unit'];
119+
$scalarDaos[$row['metric_name']] = array('value' => number_format((float)$row['value'], 4, '.', ''), 'unit' => $row['unit']);
120120
}
121121

122122
return $scalarDaos;

modules/tracker/public/css/scalar/scalar.details.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/tracker/public/scss/scalar/scalar.details.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ table {
3838
font-weight: bold;
3939
padding-right: 6px;
4040
}
41+
&.otherScalarTable td {
42+
text-align: right;
43+
}
4144
}
4245

4346
div {

modules/tracker/views/scalar/details.phtml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ if (count($this->extraParams)) {
137137
* @var string $metricName
138138
* @var float $value
139139
*/
140-
foreach ($this->otherValues as $metricName => $value) {
141-
echo '<tr><th>'.$this->escape($metricName).':</th><td>'.$this->escape($value).'</td></tr>';
140+
foreach ($this->otherValues as $metricName => $metricProperties) {
141+
$metricValue = $metricProperties['value'];
142+
$metricUnit = $metricProperties['unit'];
143+
echo '<tr><th>'.$this->escape($metricName).':</th><td>'.$this->escape($metricValue).'</td><td>'.$this->escape($metricUnit).'</td></tr>';
142144
}
143145
?>
144146
</tbody>

0 commit comments

Comments
 (0)