From 87618f9a6b2eb9f9c0433dd5d9eb9187107d253d Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 11 Apr 2017 22:34:02 -0400 Subject: [PATCH] Make it so preset.init() can be called again to reset the datastructures (this is mostly so I can reset recent.collection for the walkthrough) --- modules/presets/collection.js | 8 ++++---- modules/presets/index.js | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/presets/collection.js b/modules/presets/collection.js index ea13f6d8c..35e2b023b 100644 --- a/modules/presets/collection.js +++ b/modules/presets/collection.js @@ -12,14 +12,14 @@ export function presetCollection(collection) { item: function(id) { - return _.find(collection, function(d) { + return _.find(this.collection, function(d) { return d.id === id; }); }, matchGeometry: function(geometry) { - return presetCollection(collection.filter(function(d) { + return presetCollection(this.collection.filter(function(d) { return d.matchGeometry(geometry); })); }, @@ -44,10 +44,10 @@ export function presetCollection(collection) { value = value.toLowerCase(); - var searchable = _.filter(collection, function(a) { + var searchable = _.filter(this.collection, function(a) { return a.searchable !== false && a.suggestion !== true; }), - suggestions = _.filter(collection, function(a) { + suggestions = _.filter(this.collection, function(a) { return a.suggestion === true; }); diff --git a/modules/presets/index.js b/modules/presets/index.js index beb1eadab..16ca78c9c 100644 --- a/modules/presets/index.js +++ b/modules/presets/index.js @@ -107,6 +107,12 @@ export function presetIndex() { all.init = function() { var d = data.presets; + all.collection = []; + recent.collection = []; + fields = {}; + universal = []; + index = { point: {}, vertex: {}, line: {}, area: {}, relation: {} }; + if (d.fields) { _.forEach(d.fields, function(d, id) { fields[id] = presetField(id, d);