pete-thompson / spotfire-visuals

A set of custom visualisations built on top of JSViz
MIT License
9 stars 2 forks source link

Support Dot Notation Configs #17

Closed JoshRosenstein closed 3 years ago

JoshRosenstein commented 3 years ago

Currently, any meta-characters in the option name breaks JSVizConfigurator due to invalid selector ids. One use case would to allow dots since it is common to represent nested objects in a flattened dot notation format.

For example while utilizing a graphing library such as plotly, and configuring user controls for individual traces, user configs may grow to be quite complex and may require name spacing to handle splitting out the configurations. IE: image

A workaround i did was to wrap all selectors like so:

function safeSelector (str) {
  return str.replace(/\./g, '_')
}

https://github.com/pete-thompson/spotfire-visuals/blob/8b7bb0bc970054c7de18cfa9c65e0074a529a5c2/lib/JSVizConfigurator.js#L179

var fieldId = safeSelector('QIConfigField-' + option.name)
pete-thompson commented 3 years ago

I've changed the logic so that it creates unique IDs without using the name - so the latest version should work for you