Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Always add "Notes" field to preset for iD [WIP] #342

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/renderer/components/MapEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ const fallbackPresets = {
}
}

// iD Editor requires that a "name" field is always defined.
const fallbackFields = {
// iD Editor requires that a "name" field is always defined.
name: {
key: 'name',
type: 'localized',
Expand Down Expand Up @@ -368,17 +368,23 @@ function convertPresets (presetsObj) {
// `categoryId`
Object.keys(presets).forEach(presetId => {
const preset = presets[presetId]
let tags = preset.tags
let fields = preset.fields
if (
Object.keys(preset.tags || {}).length === 0 &&
Object.keys(tags || {}).length === 0 &&
// Skip for fallback presets `point`, `line`, `area`, `relation`
!Object.keys(fallbackPresets).includes(presetId)
) {
presets[presetId] = {
...preset,
tags: {
categoryId: presetId
}
}
tags = { categoryId: presetId }
}
if (!((fields || []).includes('notes'))) {
// Add a notes field before other fields, if it doesn't already exist
fields = ['notes'].concat(fields || [])
}
presets[presetId] = {
...preset,
tags: tags,
fields: fields
}
})

Expand Down