Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customeditoroptions not applied ? #359

Closed
landryb opened this issue Apr 20, 2021 · 11 comments
Closed

customeditoroptions not applied ? #359

landryb opened this issue Apr 20, 2021 · 11 comments

Comments

@landryb
Copy link
Member

landryb commented Apr 20, 2021

enabling featureeditor in a context via the context editor (not localConfig.json), trying to configure a field to have the dropdown editor:

  "cfg": {
    "customEditorsOptions": {
      "rules": [
        {
          "regex": {
            "attribute": "fictif",
            "typeName": "geor:aerodrome"
          },
          "editor": "DropDownEditor",
          "editorProps": {
            "allowEmpty": true,
            "values": [
              "Oui",
              "Non",
              "NSP",
              "NC"
            ]
          }
        }
      ]
    }
  }

afaict there should be a dropdown when editing field value but this isnt the case. looking at the json returned by /mapstore/rest/geostore/misc/category/name/CONTEXT/resource/name/test/data cfg is stored/saved, but doesnt seem applied ?

i'm not 100% sure but it seems similar to geosolutions-it/MapStore2#6758 (backported in geosolutions-it/MapStore2#6762) so a mapstore submodule update ought to fix that ?

@landryb
Copy link
Member Author

landryb commented Apr 27, 2021

i'm probably doing something wrong, but testing a build including #363 (so with the fixes from geosolutions-it/MapStore2#6762) the customEditorsOptions configured in the context are still not applied, ie no dropdown for the given field when editing the given layer.

@catmorales is seeing the same issue and was wondering if some config should go into localConfig.json, (according to https://mapstore.geo-solutions.it/mapstore/docs/api/framework#components.data.featuregrid.editors.customEditors ?) which seems wrong to me - why would one configure the valid values/constraints for all layers one will want to edit in a generic config file ? @offtherailz any hint ? is there a fullblown & clear working example somewhere ?

@landryb
Copy link
Member Author

landryb commented Apr 27, 2021

my previous testing was with the war from https://github.com/georchestra/mapstore2-georchestra/actions/runs/764177974 which included geosolutions-it/MapStore2#6758 (then this config should work?), so... either it isnt possible to configure customEditorOptions in a context (and only in localConfig.json?), or the config i'm trying is syntaxically wrong. In a plugin config, what's the distinction between cfg and override ?

@tdipisa
Copy link
Collaborator

tdipisa commented Apr 27, 2021

@landryb I will ask @offtherailz to do a quick check asap, early next week.

@sigrmed
Copy link

sigrmed commented Apr 27, 2021

You can reproduce the problem with https://portail-test.sig.rennesmetropole.fr/mapstore/#/context/test_maj
on the layer test-postgis:maj_injection .

Configuration is

{
  "cfg": {
    "customEditorsOptions": {
      "rules": [
        {
          "regex": {
            "attribute": "^num_equipe$",
            "typeName": "^test-postgis:maj_injection$"
          },
          "editor": "NumberEditor",
          "editorProps": {
            "allowEmpty": true,
            "maxValue": 5555,
            "minValue": 1
          }
        },
        {
          "regex": {
            "attribute": "^lieu_collecte$",
            "typeName": "^test-postgis:maj_injection$"
          },
          "editor": "DropDownEditor",
          "editorProps": {
            "values": [
              "DDL",
              "Mairie",
              "Parc_Brequigny",
              "Thabor",
              "Oberthur"
            ]
          }
        }
      ]
    }
  },
  "override": {}
}

I added for @tdipisa the good rôle to edit the layer.

@landryb
Copy link
Member Author

landryb commented Apr 27, 2021

i've also tried putting the cfg block directly in the FeatureEditor section in localConfig.json but it doesnt seem applied there either.

e.g

            {
               "name": "FeatureEditor",
               "cfg": {
                 "customEditorsOptions": {
                   "rules": [

@landryb
Copy link
Member Author

landryb commented May 4, 2021

@offtherailz did you have any luck looking into this ? thanks !

@catmorales
Copy link
Collaborator

I updated mapstore v1.2 (docker image) thinking that your last modifications had solved this problem but no it still doesn't work. The input constraints are not applied.
Please tell us why.

@offtherailz
Copy link
Collaborator

Fixed by. Waiting for revision update today. geosolutions-it/MapStore2#6839

@landryb
Copy link
Member Author

landryb commented May 10, 2021

Fixed by. Waiting for revision update today. geosolutions-it/MapStore2#6839

tested here by locally backporting geosolutions-it/MapStore2@7c299af97 in Mapstore2 subdir, i've been able to successfully test field rules, both DropDownEditor and NumberEditor constraints were properly applied/working. Thanks a lot !

offtherailz added a commit to offtherailz/mapstore2-georchestra that referenced this issue May 10, 2021
@offtherailz
Copy link
Collaborator

backported on 1.2.x #371

@tdipisa tdipisa closed this as completed May 11, 2021
@landryb
Copy link
Member Author

landryb commented May 12, 2021

on my dev instance, testing the war produced by https://github.com/georchestra/mapstore2-georchestra/actions/runs/831669404 that includes this fix, after reloading several times my existing test context where FeatureEditor plugin has this config:

{
  "cfg": {
        "customEditorsOptions": {
      "rules": [
        {
          "regex": {
            "attribute": "avis",
            "typeName": "rtge:avis_partenaires"
          },
          "editor": "DropDownEditor",
          "editorProps": {
            "allowEmpty": true,
            "values": ["Oui", "Non", "A reporter"]
          }
        }
      ]
    }
  },
  "override": {}
}

it now works fine on existing context instances/childs and a newly created context instance/child. Many thanks for fixing it !

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants