mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-30 19:59:35 +02:00
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:
+24
-20
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user