Skip to content

Commit dacfa6b

Browse files
committed
fixed issue in metric_segment
1 parent 04a5ad5 commit dacfa6b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

public/app/core/directives/metric_segment.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,27 @@ function (_, $, coreModule) {
186186

187187
$scope.getOptionsInternal = function() {
188188
if ($scope.options) {
189-
var optionSegments = _.map($scope.options, function(option) {
189+
cachedOptions = _.map($scope.options, function(option) {
190190
return uiSegmentSrv.newSegment({value: option.text});
191191
});
192-
return $q.when(optionSegments);
192+
return $q.when(cachedOptions);
193193
} else {
194194
return $scope.getOptions().then(function(options) {
195-
cachedOptions = options;
196-
return _.map(options, function(option) {
195+
cachedOptions =_.map(options, function(option) {
196+
if (option.html) {
197+
return option;
198+
}
197199
return uiSegmentSrv.newSegment({value: option.text});
198200
});
201+
return cachedOptions;
199202
});
200203
}
201204
};
202205

203206
$scope.onSegmentChange = function() {
204-
var options = $scope.options || cachedOptions;
205207

206-
if (options) {
207-
var option = _.find(options, {text: $scope.segment.value});
208+
if (cachedOptions) {
209+
var option = _.find(cachedOptions, {value: $scope.segment.value});
208210
if (option && option.value !== $scope.property) {
209211
$scope.property = option.value;
210212
} else if (attrs.custom !== 'false') {

0 commit comments

Comments
 (0)