geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
504 stars 388 forks source link

[FeatureEditor] - Allow editing by fields #9849

Open Gaetanbrl opened 8 months ago

Gaetanbrl commented 8 months ago

Description

According to the new Fields UI, it could be usefull to manage edition by fields.

This could be an answer to this use case :

As data manager (e.g natural area) I need to use a configuration from fields UI to allow some reporters to complete the land use value but prevent them to change assigned operator

Many way exists to do that.

I propose first to manage this by customEditorOptions in order to use regeEx control on field name. Then, editors can catch the props and affect editable value (true/false).

Next, I imagine in a second time to manage this type of configuration by the new fields UI. This requires to create a new columns in Fields table but it could be less good than expected. So, another way to do that in fields is to create a "settings" button by fields to open a modal and display many options as allowEdit and future improvements (i will create new ones).

I know that geoserver will always allow edition if someone use Qgis with the correct credentials, but we have many cases where basic user profile just use mapstore and needs to be regulated.

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

Other useful information

Please, share your point of view and technical advices according to mapstore2 good practices and possibility.

Gaetanbrl commented 8 months ago

Currently, if we add editable prop by field for FeatureEditor plugin, this not works fine because editor mode can be activate from each other editable column.

By default, react-data-grid seems correctly check that field is editable or not and need a dble click to open cell editor view. Here a native example where only 2/3 cols are editable :

https://codepen.io/gaetanbrl/pen/OJqyZzQ

Here mapstore example where NOM column have editable: false prop but user can always edit if editor is activated from other column :

reactdatagrid

Maybe MapStore2 gridEvents (or other code) is not compliant with this dev and needs to be change (i will analyse that now).

Gaetanbrl commented 8 months ago

@offtherailz do you know why cell editor still open when we click on other cell ? is this what you want ?

Gaetanbrl commented 8 months ago

I found 2 others alternatives.

Solution - Use disabled props on each Editor

tested and works fine

This solution needs to change Editor code to insert disabled property if the column is not editable.

https://github.com/geosolutions-it/MapStore2/blob/b91cd22265efcfa87c91a81162b576b9d002c42c/web/client/components/data/featuregrid/editors/FormatEditor.jsx#L61-L65

Here, the nom field is disabled and cursor show red circle on hover (ease to understand by all users) :

image

Solution - Return null Editor

tested and works fine

The solution needs to change Editor code to render null if the column is not editable.

Here, the nom field is not editable :

editableRenderNull

Here an Editor (<input>) code example for this solution :

image