do not remove selection when clicking refreh fields

This commit is contained in:
Thomas Neirynck 2016-09-16 13:51:06 -04:00
parent 84a504ecf0
commit afce3bede7

View file

@ -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 () {
@ -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;