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)
This commit is contained in:
Bryan Housel
2017-04-11 22:34:02 -04:00
parent b9f5001017
commit 87618f9a6b
2 changed files with 10 additions and 4 deletions
+4 -4
View File
@@ -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;
});
+6
View File
@@ -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);