WIP on external presets

- preset data is no longer bundled into iD.js
- some code pathways commented out re: external presets
- many changes so that tests can run without presets at start, or async
- still need to make sure fallbacks are always there (point, line, area, etc)
This commit is contained in:
Bryan Housel
2020-02-05 09:38:26 -05:00
parent a333a341ec
commit 0fe766d9a4
21 changed files with 1435 additions and 1435 deletions
+24 -20
View File
@@ -549,26 +549,30 @@ export function coreContext() {
_features.init();
_photos.init();
let presetsParameter = hash.presets;
if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
// a URL of external presets file
_presets.fromExternal(external, (externalPresets) => {
context.presets = () => externalPresets; // default + external presets...
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
});
} else {
let addablePresetIDs;
if (presetsParameter) {
// a list of allowed preset IDs
addablePresetIDs = presetsParameter.split(',');
}
_presets.init(addablePresetIDs);
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
}
// let presetsParameter = hash.presets;
// if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
// // a URL of external presets file
// _presets.fromExternal(external, (externalPresets) => {
// context.presets = () => externalPresets; // default + external presets...
// osmSetAreaKeys(_presets.areaKeys());
// osmSetPointTags(_presets.pointTags());
// osmSetVertexTags(_presets.vertexTags());
// });
// } else {
// let addablePresetIDs;
// if (presetsParameter) {
// // a list of allowed preset IDs
// addablePresetIDs = presetsParameter.split(',');
// }
// _presets.init(addablePresetIDs);
_presets.init()
.then(() => {
osmSetAreaKeys(_presets.areaKeys());
osmSetPointTags(_presets.pointTags());
osmSetVertexTags(_presets.vertexTags());
});
// }
return context;
};
+9 -5
View File
@@ -6,7 +6,7 @@ import { data as _data } from '../../data'; // prebundled data
// The coreData module fetches data from JSON files
//
export function coreData(context) {
let _module = {};
let _this = {};
let _inflight = {};
let _fileMap = {
'address_formats': 'data/address_formats.min.json',
@@ -20,6 +20,10 @@ export function coreData(context) {
'nsi_filters': 'https://cdn.jsdelivr.net/npm/name-suggestion-index@3/dist/filters.min.json',
'oci_features': 'https://cdn.jsdelivr.net/npm/osm-community-index@2/dist/features.min.json',
'oci_resources': 'https://cdn.jsdelivr.net/npm/osm-community-index@2/dist/resources.min.json',
'preset_categories': 'data/preset_categories.min.json',
'preset_defaults': 'data/preset_defaults.min.json',
'preset_fields': 'data/fields.min.json',
'preset_presets': 'data/presets.min.json',
'phone_formats': 'data/phone_formats.min.json',
'shortcuts': 'data/shortcuts.min.json',
'territory_languages': 'data/territory_languages.min.json',
@@ -29,7 +33,7 @@ export function coreData(context) {
// Returns a Promise to fetch data
// (resolved with the data if we have it already)
_module.get = (which) => {
_this.get = (which) => {
if (_data[which]) {
return Promise.resolve(_data[which]);
}
@@ -62,12 +66,12 @@ export function coreData(context) {
// Accessor for the file map
_module.fileMap = function(val) {
_this.fileMap = function(val) {
if (!arguments.length) return _fileMap;
_fileMap = val;
return _module;
return _this;
};
return _module;
return _this;
}