georchestra / mapstore2-georchestra

geOrchestra newest viewer
Other
6 stars 23 forks source link

FeatureEditor - relational dropdown according to another field #643

Open Gaetanbrl opened 1 year ago

Gaetanbrl commented 1 year ago

Description

As data editor, i need to select a value from a list calculated by by an other field value, to select a correct relational value (dependent on another).

This contribution could enhance featureEditor rules.

I see 2 solutions.

First, from dropDown, allow to request an API to get a list of values according :

{
  "name": "FeatureEditor",
  "cfg": {
    "maxZoom": 21,
    "customEditorsOptions": {
      "rules": [{
        "regex": {
          "attribute": "NAME_OF_THE_ATTRIBUTE",
          "url": "regex to match a specific url",
          "typeName": "layerName"
        },
        "editor": "DropDownEditor",
        "editorProps": {
          "values": ["Opt1", "Opt2"], => default
          "api": {
            "url": "http://test.fr/", => allow to just keep values returns by entire url API
            "field": "region" => optional => Allow to use another field value as requestParam
          }
        }
      }]
    }
  }
}

Second, use a complex dropDown config to specify many options according to another value.

This second option could use a config like :

{
  "name": "FeatureEditor",
  "cfg": {
    "maxZoom": 21,
    "customEditorsOptions": {
      "rules": [{
        "regex": {
          "attribute": "NAME_OF_THE_ATTRIBUTE",
          "url": "regex to match a specific url",
          "typeName": "layerName"
        },
        "editor": "DropDownEditor",
        "editorProps": {
          "values": ["Opt1", "Opt2"], => default
          "relation": [ => new relational
            {"field": "region", "selected": "britania", "values": ["Opt1", "Opt2"]}
            {"field": "region", "selected": "est", "values": ["Opt1", "Opt2"]}
          ]
        }
      }]
    }
  }
}

I guess that many solutions are possible...

What kind of improvement you want to add? (check one with "x", remove the others)

Other useful information