Set rules for attributes in edit mode (featuregrid.editors.customEditors)

99 views
Skip to first unread message

Maël REBOUX

unread,
Jul 16, 2021, 5:03:47 AM7/16/21
to mapstor...@googlegroups.com

Hello

 

Me again for questions in the edit mode.

 

We want to set tup rules for do not let users to let empty / null attributes when editing.

 

https://mapstore.geosolutionsgroup.com/mapstore/docs/api/plugins#plugins.FeatureEditor

https://mapstore.geosolutionsgroup.com/mapstore/docs/api/framework#components.data.featuregrid.editors.customEditors

 

For example, we don not want the "code_rm" attribute to be empty.

So we put :

 

{

  "cfg": {

    "editingAllowedRoles": [

      "ADMIN",

      "USER",

      "EL_MAJ_COMPTAGESROUTIERS"

    ],

    "customEditorsOptions": {

      "rules": [

          "regex": {

            "attribute": "^code_rm$",

            "typeName": "^maj:comptage_station$"

          },

          "editorProps": {

            "allowEmpty": false

          }

        }

      ]

    }

  },

  "override": {}

}

 

 

But it has no impact in the context (station_uid and comm_insee) are required because in DB it is not null attributes and GeoServer knows it) :

 

 

What is wrong / missing ?

 

 

Maël REBOUX
Service Information Géographique Rennes Métropole

 

image001.png

Tobia Di Pisa

unread,
Jul 21, 2021, 11:30:44 AM7/21/21
to mapstor...@googlegroups.com
Dear Mael,

it seems you forgot to specify the editor name in your configuration: see the editor property reported in plugin doc here.
If some attributes are not nillable, GeoServer reports this information in the DescribeFeatureType response so that MapStore can inform the user if a mandatory value has not been provided during the editing process.
Anyway, if you also want to prevent users to put empty values client side you can also use the FormatEditor editor type as follow:

{
   "cfg":{
      "customEditorsOptions":{
         "rules":[
            {
               "regex":{
                  "attribute":"^SUB_REGION$",
                  "typeName":"^gs:us_states$"
               },
               "editor":"FormatEditor",
               "editorProps":{
                  "formatRegex":"
.+"
               }
            }
         ]
      },
      "override":{ }
   }

I hope the above can help.

Regards,
     Tobia Di Pisa

--
You received this message because you are subscribed to the Google Groups "mapstore-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapstore-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapstore-users/005601d77a21%247b9cebf0%2472d6c3d0%24%40rennesmetropole.fr.


--


==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.
==
Dott. Ing. Tobia Di Pisa
Technical Lead / Project Manager


GeoSolutions Group
phone: +39 0584 962313
fax:      +39 0584 1660272

https://www.geosolutionsgroup.com/
http://twitter.com/geosolutions_it
-------------------------------------------------------


Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.

GB RL

unread,
Oct 18, 2023, 4:07:51 AM10/18/23
to mapstore-users
Hi,

In addition, is it possible to avoid new entity save without input any attributes value ?

Use case to avoid (joined GIF): 

1. Clic on "add new entity"
2. Add geom
3. Clic on "save"
4. Entity was created without attributes

In many use cases, it's not possible to allow feature creation without complete required attributes values. 
I think geoserver can return an error if the table refuse NOT NULL field value. How to manage FeatureEditor required fields (i didn't see any allowEmpty field show in first comment) ?

Thanks :)

Gaetan B
emptyValues.gif
Reply all
Reply to author
Forward
0 new messages