Skip to content

Commit

Permalink
#248 Take into account the new case metrics format in dblist table
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 29, 2017
1 parent a891111 commit 06f28ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions ui/app/scripts/controllers/admin/AdminMetricsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
ListSrv.query({
'listId': 'case_metrics'
}, {}, function(response) {

$scope.metrics = _.values(response).filter(_.isString).map(function(item) {
return JSON.parse(item);
$scope.metrics = _.map(response.toJSON(), function(value, metricId) {
value.id = metricId;
return value;
});

}, function(response) {
Expand All @@ -30,7 +30,7 @@
ListSrv.save({
'listId': 'case_metrics'
}, {
'value': JSON.stringify($scope.metric)
'value': $scope.metric
}, function() {
$scope.initMetrics();

Expand Down
13 changes: 6 additions & 7 deletions ui/app/scripts/services/MetricsCacheSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@

if(metrics === null) {
resource.query({listId: 'case_metrics'}, {}, function(response) {
metrics = {};
var data = _.values(response).filter(_.isString).map(function(item) {
return JSON.parse(item);
});
var json = response.toJSON();

_.each(data, function(m){
metrics[m.name] = m;
});
metrics = {};

_.each(_.values(json), function(metric) {
metrics[metric.name] = metric;
})

deferred.resolve(metrics);
}, function(response) {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/views/partials/case/details/metrics.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h4 class="vpad10 text-primary">
</div>

<dl class="dl-horizontal clear" ng-repeat="(k,v) in caze.metrics">
<dt class="pull-left" uib-tooltip="{{metricsCache[k].description}}">{{metricsCache[k].title}}</dt>
<dt class="pull-left" uib-tooltip="{{metricsCache[k].description}}">{{metricsCache[k].title || k}}</dt>
<dd>
<updatable-simple-text input-type="number" on-update="updateField('metrics.' + k, newValue)" value="caze.metrics[k]"></updatable-simple-text>
</dd>
Expand Down

0 comments on commit 06f28ad

Please sign in to comment.