origo icon indicating copy to clipboard operation
origo copied to clipboard

attribute constraint for layer in editor might work better as an obj since more than one value is possible

Open Grammostola opened this issue 2 years ago • 1 comments

Describe the bug Comma is currrently the value separator when defining multiple values in a constraint which means that a value name with a comma will not produce the desired result (nothing appears to happen including the constrained field becoming visible)

To Reproduce Steps to reproduce the behavior:

  • (latest Origo)
  • Have an editable layer like so:
            "attributes": [
                {
                    "name": "kategori",
                    "title": "Kategori: ",
                    "type": "dropdown",
                    "maxLength": 50,
                    "options": [
                        "Visas inte i kartan",
                        "Bostäder",
                        "Förskola och skola",
                        "Handel, kontor och industri",
                        "Kultur och fritid",
                        "Trafik och infrastruktur",
                        "Utemiljö",
                        "Vård och omsorg",
                        "Flera kategorier"
                    ]
                },
                {
                    "name": "rubrik",
                    "title": "Rubrik: ",
                    "type": "textarea",
                    "textarea": 20,
                    "maxLength": 150,
                    "constraint": "change:kategori:[Bostäder,Förskola och skola,Handel, kontor och industri]"
                },
  • Edit the attributes of a feature of this layer, choose Bostäder in the kategori dropdown and the Rubrik field appears
  • choose Visas inte i kartan in the kategori dropdown so that the Rubrik field disappears
  • choose Handel, kontor och industri in the kategori dropdown and the Rubrik field fails to show

Expected behavior

  • for the Rubrik field to show

Additional context Escaped double quotes or single quotes around the value with the comma do not make this work. (it doesn't matter what type the attrib defining the constraint is)

I think it has to do with https://github.com/origo-map/origo/pull/1260 , where the enablement of multiple values preserved the current schema (constraint takes a string).

Perhaps the schema might change so that constraint takes an object like so:

  {
      "name": "rubrik",
      "title": "Rubrik: ",
      "type": "textarea",
      "textarea": 20,
      "maxLength": 150,
      "constraint": {
        "target": "change:kategori",
        "values": [
            "Bostäder",
            "Förskola och skola",
            "Handel, kontor och industri"
        ]
    }
  }

edits because spelling is hard

Grammostola avatar Oct 31 '22 14:10 Grammostola