OpenTreeOfLife / opentree

Opentree browsing and curation web site. For overarching or cross-repo concerns, please see the 'germinator' repo.
http://tree.opentreeoflife.org/
BSD 2-Clause "Simplified" License
107 stars 26 forks source link

Provide controlled vocabularies via JSON (vs. hard-coded in web UI) #595

Open jimallman opened 9 years ago

jimallman commented 9 years ago

In the study-curation webapp, some lists of options (e.g. search contexts) are fetched as JSON from smarter services and applied in the UI. But others are hard-coded in Javascript, or in HTML as Knockout bindings, which means any new values or labels will require code-level changes.

If such updates are expected to be frequent, we should consider moving more of these definitions into remote JSON that can be fetched and incorporated on-the-fly.

jimallman commented 9 years ago

One option might be to include these in the study-editor page using a SCRIPT element, like so: read in via script tag:

<SCRIPT TYPE="application/json" SRC="url/to/enumerations.json" ID="enumerations"></SCRIPT>

It might be structured something like this. Note that general changes (is a value optional? does it support multiple values from the list?) are probably best handled in source, as we do now.

{
    /* N.B. An existing value should never be changed,
     * unless you're willing to sweep all the Nexson in
     * phylesystem to match it!
     */
    'inference methods': [ 
        {"value":"bayesian", "label":"Bayesian inference"}, 
        {"value":"Least squares", "label":"Least squares"}, 
        ... 
    ],
    'tree types': [
        ...
    ],
    ...
}

@mtholder, where and how would you anticipate these values to be defined?