diff --git a/API.md b/API.md
index 01e5b0235..29868521f 100644
--- a/API.md
+++ b/API.md
@@ -43,8 +43,9 @@ of iD (e.g. `http://preview.ideditor.com/release/`), the following parameters ar
* __`photo_overlay`__ - The street-level photo overlay layers to enable.
_Example:_ `photo_overlay=streetside,mapillary,openstreetcam`
_Available values:_ `streetside` (Microsoft Bing), `mapillary`, `mapillary-signs`, `openstreetcam`
-* __`presets`__ - A path to an external presets file.
+* __`presets`__ - A path to an external presets file or a comma-separated list of preset IDs. These will be the only presets the user may select.
_Example:_ `presets=https://path/to/presets.json`
+ _Example 2:_ `presets=building,highway/residential,highway/unclassified`
* __`rtl=true`__ - Force iD into right-to-left mode (useful for testing).
* __`source`__ - Prefills the changeset source. Pass a url encoded string.
_Example:_ `source=Bing%3BMapillary`
diff --git a/modules/core/context.js b/modules/core/context.js
index 97ca63a50..15cbcab1b 100644
--- a/modules/core/context.js
+++ b/modules/core/context.js
@@ -558,8 +558,10 @@ export function coreContext() {
features.init();
photos.init();
- if (utilStringQs(window.location.hash).presets) {
- var external = utilStringQs(window.location.hash).presets;
+ var presetsParameter = utilStringQs(window.location.hash).presets;
+ if (presetsParameter && presetsParameter.indexOf('://') !== -1) {
+ // assume URL of external presets file
+
presets.fromExternal(external, function(externalPresets) {
context.presets = function() { return externalPresets; }; // default + external presets...
osmSetAreaKeys(presets.areaKeys());
@@ -567,7 +569,15 @@ export function coreContext() {
osmSetVertexTags(presets.vertexTags());
});
} else {
- presets.init();
+ var isVisible;
+ if (presetsParameter) {
+ // assume list of allowed preset IDs
+ var visiblePresetIDs = new Set(presetsParameter.split(','));
+ isVisible = function(presetID) {
+ return visiblePresetIDs.has(presetID);
+ };
+ }
+ presets.init(isVisible);
osmSetAreaKeys(presets.areaKeys());
osmSetPointTags(presets.pointTags());
osmSetVertexTags(presets.vertexTags());
diff --git a/modules/presets/index.js b/modules/presets/index.js
index b8c9ee48e..a7c94b6fb 100644
--- a/modules/presets/index.js
+++ b/modules/presets/index.js
@@ -199,10 +199,11 @@ export function presetIndex(context) {
Object.keys(d.presets).forEach(function(id) {
var p = d.presets[id];
var existing = all.index(id);
+ var isVisible = typeof visible === 'function' ? visible(id, p) : visible;
if (existing !== -1) {
- all.collection[existing] = presetPreset(id, p, _fields, visible, rawPresets);
+ all.collection[existing] = presetPreset(id, p, _fields, isVisible, rawPresets);
} else {
- all.collection.push(presetPreset(id, p, _fields, visible, rawPresets));
+ all.collection.push(presetPreset(id, p, _fields, isVisible, rawPresets));
}
});
}
@@ -244,7 +245,7 @@ export function presetIndex(context) {
return all;
};
- all.init = function() {
+ all.init = function(shouldShow) {
all.collection = [];
_favorites = null;
_recents = null;
@@ -252,7 +253,7 @@ export function presetIndex(context) {
_universal = [];
_index = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
- return all.build(data.presets, true);
+ return all.build(data.presets, shouldShow || true);
};
diff --git a/modules/ui/preset_list.js b/modules/ui/preset_list.js
index 48b3d6725..71dbe260f 100644
--- a/modules/ui/preset_list.js
+++ b/modules/ui/preset_list.js
@@ -167,7 +167,11 @@ export function uiPresetList(context) {
function drawList(list, presets) {
var collection = presets.collection.reduce(function(collection, preset) {
if (preset.members) {
- collection.push(CategoryItem(preset));
+ if (preset.members.collection.filter(function(preset) {
+ return preset.visible();
+ }).length > 1) {
+ collection.push(CategoryItem(preset));
+ }
} else if (preset.visible()) {
collection.push(PresetItem(preset));
}