origo-map / origo

Origo
Other
50 stars 56 forks source link

Replace value of attribute #1424

Open johnnyblasta opened 2 years ago

johnnyblasta commented 2 years ago

Is your feature request related to a problem? Please describe. When getting data from external source and the data is in english f.e. it would be nice to be able to replace the values with the swedish translation. The first use case in my mind is when the attribute contains a short list of known values f.e. status or some property.

Describe the solution you'd like I would like to be able to add a key/values object specifying the what should be replaced. If the value isn't in the list the original value is kept.

"attributes": [
  {
    "name":"status",
    "title": "Status: ",
    "replaceValue": {"open": "öppen", "closed": "stängd"}
  }
]
MattiasSp commented 2 years ago

Great suggestion!

This idea made QGIS' handling of its "Value Map" in its attribute form come to mind.

Perhaps there is something to be gained by having a look at the https://origo-map.github.io/origo-documentation/latest/#editor-attributes while implementing this.

Like, instead of adding replaceValue as a new option, maybe the options functionality could be expanded to use a key/value map. Then that could work just as you suggested when opening a feature info window, but supply a drop down with permitted values when editing?

johnnyblasta commented 2 years ago

Great suggestion!

This idea made QGIS' handling of its "Value Map" in its attribute form come to mind.

Perhaps there is something to be gained by having a look at the https://origo-map.github.io/origo-documentation/latest/#editor-attributes while implementing this.

Like, instead of adding replaceValue as a new option, maybe the options functionality could be expanded to use a key/value map. Then that could work just as you suggested when opening a feature info window, but supply a drop down with permitted values when editing?

I've already implemented it but can look to see if a rework is appropriate.