ideditor / schema-builder

🏗🏷 Create tagging schemas for iD
ISC License
12 stars 16 forks source link

Allow to specify disabled-conditions per side for `directionalCombo` #153

Open tordans opened 2 months ago

tordans commented 2 months ago

The directionalCombo field is great for centerline tagging.

However, for tags that are subtags of other tags, the left|right option should only be active when the given primary tag is present.

Can we maybe add fields to the directionalCombo that allow to disable sides (as in "visible but readonly" based on missing or existing tags?

Examples:

tordans commented 2 months ago

How could we model this?

The closest we have are the prerequisiteTags and locationSet

Taking parking:both:orientation (id-tagging-schema) as an example. Goal: Have the parking:left:orientation disabled if parking:left==NULL|no|separate

(This issue is related to https://github.com/ideditor/schema-builder/issues/137)

a. Add another top level property

"type": "directionalCombo",
// if field is visible 
// See https://github.com/ideditor/schema-builder/issues/137
// the tags array is an "OR" (as in "if any of those keys with matching values is present, allow the field)
"prerequisiteTags": [ 
    { "key": "parking:both", "valueNot": null },
    { "key": "parking:both", "valueNot": "no" }, 
    { "key": "parking:both", "valueNot": "separate" },
    { "key": "parking:left", "valueNot": null },
    { "key": "parking:left", "valueNot": "no" }, 
    { "key": "parking:left", "valueNot": "separate" },
    { "key": "parking:right", "valueNot": null },
    { "key": "parking:right", "valueNot": "no" }, 
    { "key": "parking:right", "valueNot": "separate" }
],
// if field is enabled/disabled
// handles sides separately because type is `directionalCombo`; we don't need to handle the `:both`-case because that is handled by `prerequisiteTags `
// the tags array is an "OR"
"enableTag": {
  left: [
    { "key": "parking:left", "valueNot": null },
    { "key": "parking:left", "valueNot": "no" }, 
    { "key": "parking:left", "valueNot": "separate" }
  ],
  right [
    { "key": "parking:right", "valueNot": null },
    { "key": "parking:right", "valueNot": "no" }, 
    { "key": "parking:right", "valueNot": "separate" }
  ],
},
"locationSet": {
    "include": ["US"],
    "exclude": ["PR", "VI"]
}

a. Redefined enableTag

"type": "directionalCombo",
"prerequisiteTag": {
  // if field is visible 
  // See https://github.com/ideditor/schema-builder/issues/137
  // the tags array is an "OR" (as in "if any of those keys with matching values is present, allow the field)
  "allowed": [ 
      { "key": "parking:both", "valueNot": null },
      { "key": "parking:both", "valueNot": "no" }, 
      { "key": "parking:both", "valueNot": "separate" },
      { "key": "parking:left", "valueNot": null },
      { "key": "parking:left", "valueNot": "no" }, 
      { "key": "parking:left", "valueNot": "separate" },
      { "key": "parking:right", "valueNot": null },
      { "key": "parking:right", "valueNot": "no" }, 
      { "key": "parking:right", "valueNot": "separate" }
  ],
  // if field is enabled/disabled
  // handles sides separately because type is `directionalCombo`; we don't need to handle the `:both`-case because that is handled by `prerequisiteTags `
  "enabled": {
    left: [
      { "key": "parking:left", "valueNot": null },
      { "key": "parking:left", "valueNot": "no" }, 
      { "key": "parking:left", "valueNot": "separate" }
    ],
    right [
      { "key": "parking:right", "valueNot": null },
      { "key": "parking:right", "valueNot": "no" }, 
      { "key": "parking:right", "valueNot": "separate" }
    ],
  },
},
"locationSet": {
    "include": ["US"],
    "exclude": ["PR", "VI"]
}