Skip to content

Commit

Permalink
do not remove selection when clicking refreh fields
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Sep 16, 2016
1 parent 84a504e commit afce3be
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ uiModules.get('apps/management')
};

$scope.refreshFieldList = function () {
fetchFieldList().then(updateFieldList);
const timeField = index.timeField;
fetchFieldList().then(function (results) {
if (timeField) {
updateFieldListAndSeed(results, timeField);
} else {
updateFieldList(results);
}
});
};

$scope.createIndexPattern = function () {
Expand Down Expand Up @@ -247,6 +254,19 @@ uiModules.get('apps/management')
}, notify.fatal);
}

function updateFieldListAndSeed(results, seedField) {

updateFieldList(results);

if (!results.dateFields.length) {
return;
}

const matchingField = results.dateFields.find(field => field.name === seedField.name);
index.timeField = matchingField ? matchingField : results.dateFields[0];

}

function updateFieldList(results) {
index.fetchFieldsError = results.fetchFieldsError;
index.dateFields = results.dateFields;
Expand Down

0 comments on commit afce3be

Please sign in to comment.