Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,64 @@ button.preset-reset .label.flash-bg {
fill: var(--text-color);
}

/* Subtag category icons – same as remove/revert buttons in label row */
.field-label .subtag-icons {
display: flex;
flex-flow: row nowrap;
flex: 0 0 auto;
align-items: stretch;
}
.field-label .subtag-icon {
display: inline-block;
}
.field-label .subtag-icon .icon {
width: 14px;
height: 14px;
}
.field-label .subtag-icon.active,
.field-label .tag-reference-button.active {
background-color: var(--active-bg-color);
}
.field-label .subtag-icon.active .icon,
.field-label .tag-reference-button.active .icon {
opacity: 1;
}

/* Wrapper around all expanded subtag fields (grouping + rounded border) */
.subtag-expanded-outer {
margin-top: 0;
margin-left: 0;
margin-right: 0;
margin-bottom: 10px;
padding: 8px 10px 10px;
border: 1px solid var(--border-color);
border-radius: 6px;
background: var(--fill-secondary);
}
.subtag-expanded-outer:last-child {
margin-bottom: 0;
}
/* One section per expanded category inside the outer wrapper */
.subtag-expanded-wrap {
margin-top: 8px;
}
.subtag-expanded-wrap:first-child {
margin-top: 0;
}
/* Each row is a full preset field (wrap-form-field) – same as sidebar */
.subtag-expanded-row {
margin-top: 6px;
}
.subtag-expanded-row:first-child {
margin-top: 0;
}
.subtag-expanded-outer .form-field {
margin-bottom: 0;
}
.subtag-expanded-outer .wrap-form-field:last-child .form-field {
margin-bottom: 0;
}

.field-label .modified-icon,
.field-label .remove-icon,
.field-label .remove-icon-multilingual {
Expand Down
7 changes: 7 additions & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,13 @@ en:
add_fields: "Add field:"
lock:
suggestion: 'The "{label}" field is locked because there is a Wikidata tag. You can delete it or edit the tags in the "Tags" section.'
subtag:
check_date: Additional related tag – when this was last verified (so you can check it more easily).
note_desc: Additional related tags – notes or descriptions (so you can check them more easily).
source: Additional related tag – source of this value (so you can check it more easily).
conditional: Additional related tag – conditional value, e.g. weather or time (so you can check it more easily).
numeric: Tags with numeric postfix (e.g. 1, 2, 3) for this key (so you can check them more easily).
other: Other additional related tags (so you can check them more easily).
display_name_addr: "{housenumber} {streetOrPlace}"
display_name_addr_with_unit: "{unit}, {housenumber} {streetOrPlace}"
display_name:
Expand Down
17 changes: 16 additions & 1 deletion modules/ui/entity_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ export function uiEntityEditor(context) {
var _newFeature;

var _sections;
/**
* D3 selection of the inspector body container. Kept so the preset fields
* section can be re-rendered when a subtag category is expanded.
* @type {d3.Selection}
*/
let _bodySelection;

function entityEditor(selection) {

Expand Down Expand Up @@ -88,19 +94,28 @@ export function uiEntityEditor(context) {
.merge(bodyEnter);

if (!_sections) {
const presetFieldsSection = uiSectionPresetFields(context)
.on('change', changeTags)
.on('revert', revertTags)
.on('expandSubtag', function() {
if (_bodySelection) {
_bodySelection.call(presetFieldsSection.render);
}
});
_sections = [
uiSectionSelectionList(context),
uiSectionFeatureType(context).on('choose', function(presets) {
dispatch.call('choose', this, presets);
}),
uiSectionEntityIssues(context),
uiSectionPresetFields(context).on('change', changeTags).on('revert', revertTags),
presetFieldsSection,
uiSectionRawTagEditor('raw-tag-editor', context).on('change', changeTags),
uiSectionRawMemberEditor(context),
uiSectionRawMembershipEditor(context)
];
}

_bodySelection = body;
_sections.forEach(function(section) {
if (section.entityIDs) {
section.entityIDs(_entityIDs);
Expand Down
47 changes: 45 additions & 2 deletions modules/ui/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { uiFields } from './fields';
import { LANGUAGE_SUFFIX_REGEX } from './fields/localized';
import { uiTagReference } from './tag_reference';
import { utilRebind, utilUniqueDomId } from '../util';
import { renderSubtagIcons, renderSubtagExpanded } from './field_subtag_icons';


export function uiField(context, presetField, entityIDs, options) {
Expand All @@ -19,10 +20,11 @@ export function uiField(context, presetField, entityIDs, options) {
wrap: true,
remove: true,
revert: true,
info: true
info: true,
showSubtagIcons: true
}, options);

var dispatch = d3_dispatch('change', 'revert');
var dispatch = d3_dispatch('change', 'revert', 'expandSubtag');
var field = Object.assign({}, presetField); // shallow copy
field.domId = utilUniqueDomId('form-field-' + field.safeid);
var _show = options.show;
Expand All @@ -38,6 +40,11 @@ export function uiField(context, presetField, entityIDs, options) {
}

var _locked = false;
/**
* Keys of subtag categories whose editable blocks are expanded (multiple can be open).
* @type {Set<string>}
*/
let _expandedSubtagCategories = new Set();
var _lockedTip = uiTooltip()
.title(() => t.append('inspector.lock.suggestion', { label: field.title }))
.placement('bottom');
Expand Down Expand Up @@ -166,6 +173,12 @@ export function uiField(context, presetField, entityIDs, options) {
.append('span')
.attr('class', 'label-textannotation');

if (options.showSubtagIcons) {
labelEnter
.append('span')
.attr('class', 'subtag-icons');
}

if (options.remove) {
labelEnter
.append('button')
Expand Down Expand Up @@ -246,6 +259,19 @@ export function uiField(context, presetField, entityIDs, options) {
}

d.impl.tags(_tags);

// Expandable sub-fields for editing subtags (top-level preset fields only)
if (options.showSubtagIcons) {
renderSubtagExpanded(selection, {
field,
_tags,
allKeys,
_expandedSubtagCategories,
entityIDs,
createFieldComponent: (config, eids, opts) => uiField(context, config, eids, opts),
dispatch
});
}
});


Expand All @@ -255,6 +281,23 @@ export function uiField(context, presetField, entityIDs, options) {
.classed('present', tagsContainFieldKey());


// Subtag icons: show category icons only on top-level preset fields
if (options.showSubtagIcons) {
renderSubtagIcons(container, {
field,
_tags,
allKeys,
_expandedSubtagCategories,
dispatch
}, function (categoryKey) {
if (_expandedSubtagCategories.has(categoryKey)) {
_expandedSubtagCategories.delete(categoryKey);
} else {
_expandedSubtagCategories.add(categoryKey);
}
});
}

// show a tip and lock icon if the field is locked
var annotation = container.selectAll('.field-label .label-textannotation');
var icon = annotation.selectAll('.icon')
Expand Down
Loading