From 9f7ef21e5c7b707cc9708243757e83865bf72b94 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 17 Jan 2019 11:37:05 -0500 Subject: [PATCH] The additional fields dropdown now mixes universal and moreFields and is sorted alphabetically --- modules/presets/index.js | 4 ---- modules/ui/preset_editor.js | 15 ++++++--------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/modules/presets/index.js b/modules/presets/index.js index bbccf7bfe..ff346eacf 100644 --- a/modules/presets/index.js +++ b/modules/presets/index.js @@ -131,10 +131,6 @@ export function presetIndex() { }); } - // move the wikidata field to directly follow the wikipedia field - _universal.splice(_universal.indexOf(_fields.wikidata), 1); - _universal.splice(_universal.indexOf(_fields.wikipedia)+1, 0, _fields.wikidata); - if (d.presets) { var rawPresets = d.presets; _forEach(d.presets, function(d, id) { diff --git a/modules/ui/preset_editor.js b/modules/ui/preset_editor.js index 2ccbabd07..508692449 100644 --- a/modules/ui/preset_editor.js +++ b/modules/ui/preset_editor.js @@ -1,5 +1,5 @@ import { dispatch as d3_dispatch } from 'd3-dispatch'; - +import _union from 'lodash-es/union'; import { event as d3_event, select as d3_select @@ -53,16 +53,13 @@ export function uiPresetEditor(context) { ); } - _preset.moreFields.forEach(function(field) { - if (_preset.fields.indexOf(field) === -1) { - _fieldsArr.push( - uiField(context, field, entity, { show: false }) - ); - } + var additionalFields = _union(_preset.moreFields, presets.universal()); + additionalFields.sort(function(field1, field2) { + return field1.label() > field2.label(); }); - presets.universal().forEach(function(field) { - if (_preset.fields.indexOf(field) === -1 && _preset.moreFields.indexOf(field) === -1) { + additionalFields.forEach(function(field) { + if (_preset.fields.indexOf(field) === -1) { _fieldsArr.push( uiField(context, field, entity, { show: false }) );