diff --git a/src/parking/controls/editor/editor-form.ts b/src/parking/controls/editor/editor-form.ts
index f487819..072ac08 100644
--- a/src/parking/controls/editor/editor-form.ts
+++ b/src/parking/controls/editor/editor-form.ts
@@ -4,6 +4,7 @@ import { WaysInRelation } from '../../../utils/types/osm-data-storage'
import { OsmKeyValue } from '../../../utils/types/preset'
import { presets } from './presets'
import { getAllTagsBlock } from '../lane-info'
+import { parseConditionalTag, ConditionalValue } from '../../../utils/conditional-tag'
export function getLaneEditForm(osm: OsmWay, waysInRelation: WaysInRelation, cutLaneListener: (way: OsmWay) => void): HTMLFormElement {
const form = hyper`
@@ -91,6 +92,7 @@ const parkingLaneTagTemplates = [
'parking:condition:{side}',
'parking:condition:{side}:time_interval',
'parking:condition:{side}:default',
+ 'parking:condition:{side}:conditional',
'parking:condition:{side}:maxstay',
'parking:lane:{side}:capacity',
'parking:lane:{side}:surface',
@@ -112,6 +114,13 @@ function getTagInput(osm: OsmWay, side: string, parkingType: string, tagTemplate
const tagSplit = tag.split(':')
const label = tagSplit[Math.floor(tagSplit.length / 2) * 2 - 1]
+ if (tagTemplate === 'parking:condition:{side}:conditional') {
+ const conditionTag = 'parking:condition:{side}'
+ .replace('{side}', side)
+ const hide = !osm.tags[conditionTag]
+ return getConditionalInput(osm, tag, label, hide)
+ }
+
const value = osm.tags[tag]
let input: HTMLInputElement | HTMLSelectElement
@@ -126,6 +135,7 @@ function getTagInput(osm: OsmWay, side: string, parkingType: string, tagTemplate
case 'parking:condition:{side}:time_interval':
input = getTextInput(tag, value)
input.oninput = handleTimeIntervalTagInput
+ hide = !osm.tags[tagTemplate.replace('{side}', side)]
break
case 'parking:lane:{side}:{type}': {
@@ -169,14 +179,7 @@ function getTagInput(osm: OsmWay, side: string, parkingType: string, tagTemplate
break
}
- input.onchange = (e) => {
- if (!(e.currentTarget instanceof HTMLInputElement || e.currentTarget instanceof HTMLSelectElement) ||
- e.currentTarget.form == null)
- return
-
- const newOsm = formToOsmWay(osm, e.currentTarget.form)
- osmChangeListener?.(newOsm)
- }
+ input.onchange = (e) => handleInputChange(e, osm)
return hyper`
` as HTMLElement
}
+function handleInputChange(e: Event, osm: OsmWay) {
+ if (!(e.currentTarget instanceof HTMLInputElement || e.currentTarget instanceof HTMLSelectElement) ||
+ e.currentTarget.form == null)
+ return
+
+ const newOsm = formToOsmWay(osm, e.currentTarget.form)
+ osmChangeListener?.(newOsm)
+}
+
function getSelectInput(tag: string, value: string, values: string[]): HTMLSelectElement {
const options = !value || values.includes(value) ?
['', ...values] :
['', value, ...values]
return hyper`
-