Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/plugins/kibana/public/settings/sections/indices/_create.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ define(function (require) {
};

$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 () {
Expand Down Expand Up @@ -250,6 +257,22 @@ define(function (require) {
index.dateFields = results.dateFields;
}

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 promiseMatch(lastPromise, cb) {
if (lastPromise === samplePromise) {
cb();
Expand Down