From 918481909c2e53994d907b39923da5c4711f1456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sat, 8 Oct 2016 10:23:30 +0200 Subject: [PATCH] fix(metricsegment): fixed issue with metric segment, fixes #6212 --- public/app/core/directives/metric_segment.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/public/app/core/directives/metric_segment.js b/public/app/core/directives/metric_segment.js index 2001073ed80..c3e51dc7a0c 100644 --- a/public/app/core/directives/metric_segment.js +++ b/public/app/core/directives/metric_segment.js @@ -43,7 +43,7 @@ function (_, $, coreModule) { var selected = _.find($scope.altSegments, {value: value}); if (selected) { segment.value = selected.value; - segment.html = selected.html; + segment.html = selected.html || selected.value; segment.fake = false; segment.expandable = selected.expandable; } @@ -186,27 +186,26 @@ function (_, $, coreModule) { $scope.getOptionsInternal = function() { if ($scope.options) { - cachedOptions = _.map($scope.options, function(option) { - return uiSegmentSrv.newSegment({value: option.text}); - }); - return $q.when(cachedOptions); + cachedOptions = $scope.options; + return $q.when(_.map($scope.options, function(option) { + return {value: option.text}; + })); } else { return $scope.getOptions().then(function(options) { - cachedOptions =_.map(options, function(option) { + cachedOptions = options; + return _.map(options, function(option) { if (option.html) { return option; } - return uiSegmentSrv.newSegment({value: option.text}); + return {value: option.text}; }); - return cachedOptions; }); } }; $scope.onSegmentChange = function() { - if (cachedOptions) { - var option = _.find(cachedOptions, {value: $scope.segment.value}); + var option = _.find(cachedOptions, {text: $scope.segment.value}); if (option && option.value !== $scope.property) { $scope.property = option.value; } else if (attrs.custom !== 'false') {