mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Backport PR #8312
--------- **Commit 1:** do not remove selection when clicking refreh fields * Original sha:afce3bede7
* Authored by Thomas Neirynck <thomas@elastic.co> on 2016-09-16T17:51:06Z **Commit 2:** improve readability * Original sha:411957cd96
* Authored by Thomas Neirynck <thomas@elastic.co> on 2016-09-20T21:32:21Z
This commit is contained in:
parent
322f391c99
commit
db3874c405
1 changed files with 24 additions and 1 deletions
|
@ -43,7 +43,14 @@ uiModules.get('apps/management')
|
|||
};
|
||||
|
||||
$scope.refreshFieldList = function () {
|
||||
fetchFieldList().then(updateFieldList);
|
||||
const timeField = index.timeField;
|
||||
fetchFieldList().then(function (results) {
|
||||
if (timeField) {
|
||||
updateFieldListAndSetTimeField(results, timeField.name);
|
||||
} else {
|
||||
updateFieldList(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.createIndexPattern = function () {
|
||||
|
@ -247,6 +254,22 @@ uiModules.get('apps/management')
|
|||
}, notify.fatal);
|
||||
}
|
||||
|
||||
function updateFieldListAndSetTimeField(results, timeFieldName) {
|
||||
updateFieldList(results);
|
||||
|
||||
if (!results.dateFields.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const matchingTimeField = results.dateFields.find(field => field.name === timeFieldName);
|
||||
const defaultTimeField = results.dateFields[0];
|
||||
|
||||
//assign the field from the results-list
|
||||
//angular recreates a new timefield instance, each time the list is refreshed.
|
||||
//This ensures the selected field matches one of the instances in the list.
|
||||
index.timeField = matchingTimeField ? matchingTimeField : defaultTimeField;
|
||||
}
|
||||
|
||||
function updateFieldList(results) {
|
||||
index.fetchFieldsError = results.fetchFieldsError;
|
||||
index.dateFields = results.dateFields;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue