json-schema-form / angular-schema-form

Generate forms from a JSON schema, with AngularJS!
https://json-schema-form.github.io/angular-schema-form
MIT License
2.47k stars 653 forks source link

Decorate a Multiple Select with TitleMap/ Enum #840

Closed rayhooker closed 7 years ago

rayhooker commented 7 years ago

Thanks to your advice, I was able to add a decorator for popuphelp and for adding the capability to do a review of multiple entries. This works for all fields except it does not trigger for a field defined such the following properties def for "things" from your demo:

"things": {
  "type": "array",
  "title": "I like...",
  "items": {
    "type": "string",
    "enum": [
      "clowns",
      "compiling",
      "sleeping"
    ]
  }
},

It works nicely to allow for multiselect using checkboxes. Unfortunately though I can add a title, I cannot decorate it using one of builders. Is there a way to do that?

Ray

P.S. I should note that I update bootstrap-decorator.js to define the builder in the current list (e.g., condition and array) and then added it to the list of default builders. I guess what is used to display "things" is different?

Anthropic commented 7 years ago

Hi @rayhooker I don't remember the other issue, what are you trying to do exactly, can you break it down a bit further for me please as to what you have done so far? A builder is just a function so there's no reason you can't attach a builder to an array or string and have them check they match criteria you want them to before executing.

rayhooker commented 7 years ago

Marcel, So I am talking about a decorator such as "popuphelp" that will take a help string as input and add to the form element an icon that pops up the help. I defined it and added it to the default builders in bootstrap-decorator and then defined it in schema-form.js.

I then created a similar one to allow people to see update history for a rater reliability feature. I noticed that it did not work for multiselect radio box approach implemented using a form item with no type specified pointing to a definition in the properties as an array and a supplied enum. For most fields, that gets called but not for this option. This type of field is demonstrated in the demo for "things" in the kitchen sink option: http://schemaform.io/examples/bootstrap-example.html

Also there is a problem with strapselect select2 but I will have to look at their code. I was only hoping you would comment on why this base feature was not triggering the decorators. I guess you can't add a condition to that field either?

Anthropic commented 7 years ago

Hi Ray, the one you want to look at for that is the checkboxes row, it doesn't use the defaults, although I plan to change that as it uses the defaults with one appended, so that would be a better syntax.

rayhooker commented 7 years ago

Marcel, Excellent! That works. For some reason when I scanned the list I did not notice that checkboxes did not call defaults. I went ahead and added it. I have to update the base code and will try to track as you externalize the ability to specify decorators and builders. For now at least it works!

Thanks.

Anthropic commented 7 years ago

@rayhooker glad to hear it :)