From afce3bede7c948db02373e6d55ff227ad2220e58 Mon Sep 17 00:00:00 2001 From: Thomas Neirynck Date: Fri, 16 Sep 2016 13:51:06 -0400 Subject: [PATCH] do not remove selection when clicking refreh fields --- .../management/sections/indices/_create.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/core_plugins/kibana/public/management/sections/indices/_create.js b/src/core_plugins/kibana/public/management/sections/indices/_create.js index cb98e8682457..ff3a8d3baba2 100644 --- a/src/core_plugins/kibana/public/management/sections/indices/_create.js +++ b/src/core_plugins/kibana/public/management/sections/indices/_create.js @@ -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;