Skip to content

Commit a227bcc

Browse files
Backport PR elastic#8312
--------- **Commit 1:** do not remove selection when clicking refreh fields * Original sha: afce3be * Authored by Thomas Neirynck <thomas@elastic.co> on 2016-09-16T17:51:06Z **Commit 2:** improve readability * Original sha: 411957c * Authored by Thomas Neirynck <thomas@elastic.co> on 2016-09-20T21:32:21Z
1 parent 7e82f9a commit a227bcc

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

  • src/core_plugins/kibana/public/management/sections/indices

src/core_plugins/kibana/public/management/sections/indices/_create.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ uiModules.get('apps/management')
4343
};
4444

4545
$scope.refreshFieldList = function () {
46-
fetchFieldList().then(updateFieldList);
46+
const timeField = index.timeField;
47+
fetchFieldList().then(function (results) {
48+
if (timeField) {
49+
updateFieldListAndSetTimeField(results, timeField.name);
50+
} else {
51+
updateFieldList(results);
52+
}
53+
});
4754
};
4855

4956
$scope.createIndexPattern = function () {
@@ -247,6 +254,22 @@ uiModules.get('apps/management')
247254
}, notify.fatal);
248255
}
249256

257+
function updateFieldListAndSetTimeField(results, timeFieldName) {
258+
updateFieldList(results);
259+
260+
if (!results.dateFields.length) {
261+
return;
262+
}
263+
264+
const matchingTimeField = results.dateFields.find(field => field.name === timeFieldName);
265+
const defaultTimeField = results.dateFields[0];
266+
267+
//assign the field from the results-list
268+
//angular recreates a new timefield instance, each time the list is refreshed.
269+
//This ensures the selected field matches one of the instances in the list.
270+
index.timeField = matchingTimeField ? matchingTimeField : defaultTimeField;
271+
}
272+
250273
function updateFieldList(results) {
251274
index.fetchFieldsError = results.fetchFieldsError;
252275
index.dateFields = results.dateFields;

0 commit comments

Comments
 (0)