diff --git a/CHANGELOG.md b/CHANGELOG.md index baf1c2307..855a30685 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ _Breaking developer changes, which may affect downstream projects or sites that # Unreleased (2.32.0-dev) #### :sparkles: Usability & Accessibility +* Autocomplete changeset `source` tag with sources of the previous 100 changesets of the user ([#10764], thanks [@k-yle]) * Also show search result for coordinates in `lon/lat` order in search results ([#10720], thanks [@Deeptanshu-sankhwar]) * Allow broken (unclosed) areas to be continued ([#9635], thanks [@k-yle]) #### :scissors: Operations @@ -68,6 +69,7 @@ _Breaking developer changes, which may affect downstream projects or sites that [#10747]: https://github.com/openstreetmap/iD/issues/10747 [#10748]: https://github.com/openstreetmap/iD/issues/10748 [#10755]: https://github.com/openstreetmap/iD/issues/10755 +[#10764]: https://github.com/openstreetmap/iD/issues/10764 [#10766]: https://github.com/openstreetmap/iD/pull/10766 [@hlfan]: https://github.com/hlfan [@Deeptanshu-sankhwar]: https://github.com/Deeptanshu-sankhwar diff --git a/modules/ui/changeset_editor.js b/modules/ui/changeset_editor.js index 292136bd5..5b078d6ea 100644 --- a/modules/ui/changeset_editor.js +++ b/modules/ui/changeset_editor.js @@ -57,6 +57,7 @@ export function uiChangesetEditor(context) { if (initial) { var commentField = selection.select('.form-field-comment textarea'); + const sourceField = _fieldsArr.find(field => field.id === 'source'); var commentNode = commentField.node(); if (commentNode) { @@ -82,6 +83,15 @@ export function uiChangesetEditor(context) { .call(commentCombo .data(utilArrayUniqBy(comments, 'title')) ); + + // add extra dropdown options to the `source` field + // based on the values used in recent changesets. + const recentSources = changesets + .flatMap((changeset) => changeset.tags.source?.split(';')) + .filter(Boolean) + .map(title => ({ title, value: title, klass: 'raw-option' })); + + sourceField.impl.setCustomOptions(utilArrayUniqBy(recentSources, 'title')); }); } } diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index caacf33a7..346d063eb 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -43,6 +43,7 @@ export function uiFieldCombo(field, context) { var _tags; var _countryCode; var _staticPlaceholder; + var _customOptions = []; // initialize deprecated tags array var _dataDeprecated = []; @@ -181,7 +182,7 @@ export function uiFieldCombo(field, context) { } else { options = [].concat(field.options, stringsField.options).filter(Boolean); } - return options.map(function(v) { + const result = options.map(function(v) { const labelId = getLabelId(stringsField, v); return { key: v, @@ -191,6 +192,7 @@ export function uiFieldCombo(field, context) { klass: stringsField.hasTextForStringId(labelId) ? '' : 'raw-option' }; }); + return [...result, ..._customOptions]; } @@ -926,6 +928,10 @@ export function uiFieldCombo(field, context) { ); } + combo.setCustomOptions = (newValue) => { + _customOptions = newValue; + }; + combo.focus = function() { _input.node().focus();