From 47ca36574891ebed90e6fc7582637c62c6dcca99 Mon Sep 17 00:00:00 2001 From: kobelb Date: Mon, 20 Mar 2017 14:18:48 -0400 Subject: [PATCH 1/2] Fixing bug where an error is displayed when saving a new scripted field When a new scripted field is saved, there is a moment where a mapping error validation message is displayed because there's a field with the same name. Added a `saving` flag that is used to no longer show the validation message in this situation. --- src/ui/public/field_editor/field_editor.html | 2 +- src/ui/public/field_editor/field_editor.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/public/field_editor/field_editor.html b/src/ui/public/field_editor/field_editor.html index e6592bd8f9d77..4a04d8790b6c2 100644 --- a/src/ui/public/field_editor/field_editor.html +++ b/src/ui/public/field_editor/field_editor.html @@ -16,7 +16,7 @@ class="form-control" data-test-subj="editorFieldName"> -
+

Mapping Conflict: diff --git a/src/ui/public/field_editor/field_editor.js b/src/ui/public/field_editor/field_editor.js index 8f883b2f571bc..289bfad8080c3 100644 --- a/src/ui/public/field_editor/field_editor.js +++ b/src/ui/public/field_editor/field_editor.js @@ -57,6 +57,8 @@ uiModules self.cancel = redirectAway; self.save = function () { + self.saving = true; + const indexPattern = self.indexPattern; const fields = indexPattern.fields; const field = self.field.toActualField(); From fe7eb987b0c5359d2eda64198bf656dcab1c5f01 Mon Sep 17 00:00:00 2001 From: kobelb Date: Tue, 21 Mar 2017 12:55:19 -0400 Subject: [PATCH 2/2] Switching approach to copying fieldNames on instantiation --- src/ui/public/field_editor/field_editor.html | 2 +- src/ui/public/field_editor/field_editor.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ui/public/field_editor/field_editor.html b/src/ui/public/field_editor/field_editor.html index 4a04d8790b6c2..c44a375c49853 100644 --- a/src/ui/public/field_editor/field_editor.html +++ b/src/ui/public/field_editor/field_editor.html @@ -16,7 +16,7 @@ class="form-control" data-test-subj="editorFieldName">

-
+

Mapping Conflict: diff --git a/src/ui/public/field_editor/field_editor.js b/src/ui/public/field_editor/field_editor.js index 289bfad8080c3..7607fcb7871c4 100644 --- a/src/ui/public/field_editor/field_editor.js +++ b/src/ui/public/field_editor/field_editor.js @@ -52,13 +52,12 @@ uiModules // only init on first create self.creating = !self.indexPattern.fields.byName[self.field.name]; + self.existingFieldNames = self.indexPattern.fields.map(field => field.name); //used for mapping conflict validation self.selectedFormatId = _.get(self.indexPattern, ['fieldFormatMap', self.field.name, 'type', 'id']); self.defFormatType = initDefaultFormat(); self.cancel = redirectAway; self.save = function () { - self.saving = true; - const indexPattern = self.indexPattern; const fields = indexPattern.fields; const field = self.field.toActualField();