feat: group child tags by type in add-child wizard
When adding a child to leaflet-map, the tag select is now grouped into categories: Tile Layers, Markers, Shapes, Data, Overlays, Groups, and Controls, using <optgroup> elements.
This commit is contained in:
parent
275c74f0c2
commit
26e110d0b4
27
index.html
27
index.html
@ -354,6 +354,18 @@
|
|||||||
'leaflet-geojson': ['leaflet-popup', 'leaflet-tooltip'],
|
'leaflet-geojson': ['leaflet-popup', 'leaflet-tooltip'],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const TAG_GROUPS = {
|
||||||
|
'leaflet-map': [
|
||||||
|
{ label: 'Tile Layers', tags: ['leaflet-tile-layer', 'leaflet-tile-layer-wms'] },
|
||||||
|
{ label: 'Markers', tags: ['leaflet-marker'] },
|
||||||
|
{ label: 'Shapes', tags: ['leaflet-circle', 'leaflet-circle-marker', 'leaflet-polygon', 'leaflet-polyline', 'leaflet-rectangle'] },
|
||||||
|
{ label: 'Data', tags: ['leaflet-geojson'] },
|
||||||
|
{ label: 'Overlays', tags: ['leaflet-image-overlay', 'leaflet-video-overlay', 'leaflet-svg-overlay'] },
|
||||||
|
{ label: 'Groups', tags: ['leaflet-layer-group', 'leaflet-feature-group'] },
|
||||||
|
{ label: 'Controls', tags: ['leaflet-control-zoom', 'leaflet-control-scale', 'leaflet-control-attribution'] },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
const ATTRS = {
|
const ATTRS = {
|
||||||
'leaflet-map': {
|
'leaflet-map': {
|
||||||
View: [
|
View: [
|
||||||
@ -1096,12 +1108,27 @@
|
|||||||
form.appendChild(h5);
|
form.appendChild(h5);
|
||||||
|
|
||||||
const select = document.createElement('select');
|
const select = document.createElement('select');
|
||||||
|
const groups = TAG_GROUPS[tagName(parentEl)];
|
||||||
|
if (groups) {
|
||||||
|
for (const group of groups) {
|
||||||
|
const optgroup = document.createElement('optgroup');
|
||||||
|
optgroup.label = group.label;
|
||||||
|
for (const childTag of group.tags) {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = childTag;
|
||||||
|
opt.textContent = childTag;
|
||||||
|
optgroup.appendChild(opt);
|
||||||
|
}
|
||||||
|
select.appendChild(optgroup);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (const childTag of validChildren) {
|
for (const childTag of validChildren) {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = childTag;
|
opt.value = childTag;
|
||||||
opt.textContent = childTag;
|
opt.textContent = childTag;
|
||||||
select.appendChild(opt);
|
select.appendChild(opt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
form.appendChild(select);
|
form.appendChild(select);
|
||||||
|
|
||||||
// Preview
|
// Preview
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user