hoobs-org / hoobsd

Server component for the certified HOOBS smart home stack.
GNU General Public License v3.0
8 stars 4 forks source link

Form Schema JSON Capabilities - Form Definition Defaults in Schema (Radio Buttons via x-schema-form) #96

Open mkormendy opened 3 years ago

mkormendy commented 3 years ago

As a user, I am noticing a number of features that are not in parity with the native Homebridge implementation of the config.schema.json for the form based configuration user interface.

This issue deals with the ability to use the x-schema-form property to implement one-off form alterations instead of having to define an entire form definition for all items of a schema (which is cumbersome). In my case, I wanted to display radio buttons for one field yet not have to define form definition for the entire schema. I performed this with the following block of code:

"trigger": {
  "title": "Force Trigger State (optional)",
  "type": "string",
  "enum": [
    "high",
    "low"
  ],
  "x-schema-form": {
    "type": "radios",
    "titleMap": [{
        "value": "high",
        "name": "High (unselected default)"
      },
      {
        "value": "low",
        "name": "Low"
      }
    ]
  }
},

This produces the expected output here in Homebridge:

Screen Shot 2021-07-20 at 12 13 06 AM

However in HOOBS it produces this:

Screen Shot 2021-07-20 at 12 13 37 AM

Again, this isn't a showstopper but it was actually nicer to see the options up-front without having to expand the select field to access what is available (and possibly select an option by accident because there is an intermittent bug with that select control that selects the first item after, when you blur out of focus on the control).