Skip to content
Snippets Groups Projects
Commit 3813a896 authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

added precision to tables

parent 74fa29d2
No related branches found
No related tags found
1 merge request!223Reports overhaul
......@@ -50,7 +50,10 @@ angular.module('reportApp')
scope.addNewTable = function() {
return () => {
let id = getNextItemId('table');
scope.group.addReportItem(id, Array.from(scope.newTable.data));
scope.group.addReportItem(id, {
fields: Array.from(scope.newTable.data),
precision: 10
});
scope.newTable.data.length = 0;
};
};
......
......@@ -49,7 +49,7 @@ angular.module('reportApp')
id='item.id'
show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
fields='item.content'
content='item.content'
>
</div>
<div
......
......@@ -31,17 +31,21 @@ angular.module('reportApp')
scope: {
group: '=',
id: '=',
fields: '=',
content: '=',
showSerialized: '=',
serializeFuncObj: '='
},
link: function(scope){
scope.fields = scope.content.fields;
// add 'expName' to the beginning of the fields to show in the table
// if it isnt already there
if(scope.fields.length === 0 || scope.fields[0] !== 'Experiment'){
scope.fields.unshift('Experiment');
}
// 1 - 10
scope.floatingPointRange = [...(new Array(10)).keys()].map(i => i + 1);
console.log(scope.fields);
scope.tableables = ExperimentsService.tableables || {};
scope.getFieldType = (field) => {
......@@ -76,7 +80,12 @@ angular.module('reportApp')
} else if(!fVal){
val = '-';
} else if(fVal.value){
val = fVal.value;
let tmp = fVal.value;
if(Number.isInteger(tmp)){
val = tmp;
} else {
val = tmp.toFixed(parseInt(scope.content.precision));
}
} else if (fVal){
val = fVal;
}
......@@ -163,6 +172,15 @@ angular.module('reportApp')
button-text="Save Column Choices"
>
</div>
<div class='btn-group' role='group'>
<button class='btn btn-default' id="{{domId}}-precision" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Precision: {{ content.precision }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="{{domId}}-precision">
<li ng-click='content.precision = i' ng-repeat='i in floatingPointRange'><a>{{ i }}</a></li>
</ul>
</div>
<button class='btn btn-default' ng-click='showSerialized.val = !showSerialized.val'>
Toggle Serialize View
</button>
......@@ -199,7 +217,7 @@ angular.module('reportApp')
<tbody>
<tr ng-repeat="exp in group.experiments | orderBy:sortFunc:sortField.isReversed">
<td ng-repeat='field in fields'>
{{ tableables[exp] ? getFieldVal(exp, field) : '' }}
{{ getFieldVal(exp, field) }}
</td>
</tr>
</tbody>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment