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

#9180: Attribute Table in read only mode #9212

Merged
merged 5 commits into from
Jun 13, 2023

Conversation

dsuren1
Copy link
Contributor

@dsuren1 dsuren1 commented Jun 8, 2023

Description

This PR adds a feature to layer setting to disable editing in Attribute table

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Feature

Issue

What is the current behavior?

What is the new behavior?

  • The option is un-ticket by default
  • The enabling it will disable editing in Attribute table
  • The attribute edit icon is hidden in Identify panel for the selected layer
  • The options is saved along with layer setting

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

#7285 (comment)

@dsuren1 dsuren1 added this to the 2023.02.00 milestone Jun 8, 2023
@dsuren1 dsuren1 requested a review from offtherailz June 8, 2023 07:44
@dsuren1 dsuren1 self-assigned this Jun 8, 2023
@dsuren1 dsuren1 linked an issue Jun 8, 2023 that may be closed by this pull request
4 tasks
Copy link
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • change the flag readOnlyAttribute to disableFeaturesEditing

  • having a selector(Creator) that relies on a type of a plugin passed to get the proper layer rises the complxity of the solution without helping too much on future maintainence.

I suggest to refactor this solution by:

  • keeping isEditingAllowedSelector untouched, without transforming it in a selector creator. This selector tells only if the editor is enabled in general.
  • remove readOnlyAttributeSelector that is hard to maintain (it relies on two plugins state)
  • Whenever a button that open the feature editor is present, add the additional check to hide it :
    • you can add an additional utility function like areFeaturesEditable that checks the particular flag and supportsFeatureEditing that checks the type.
// utils
const supportedEditLayerTypes = [ "wms", "wfs"];
function supportsFeatureEditing(layer) {return includes(supportedEditLayerTypes, layer.type) };
function areLayerFeaturesEditable(layer) =>  !layer?.disableFeaturesEditing && supportsFeatureEditing(layer);}

For instance in IdentifyContainer:

showEdit: showEdit && areLayerFeaturesEditable(layer) && isEditingAllowed && !!targetResponse && responseValidForEdit(targetResponse),

(and similar in feature grid toolbar).

This reduces a lot:

  • the code to use
  • the tests
  • the maintainance
  • the complexity

Please let me know what you think.

@dsuren1
Copy link
Contributor Author

dsuren1 commented Jun 13, 2023

I agree. I initially thought of adding funcs as suggested but later thought it would be easier to manage in one place by a selector.

Anyway, I will make the necessary modification. Thanks!

@dsuren1 dsuren1 requested a review from offtherailz June 13, 2023 08:49
@dsuren1
Copy link
Contributor Author

dsuren1 commented Jun 13, 2023

Coveralls failing
image

@offtherailz
Copy link
Member

trying to re-run

Copy link
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector is not needed anymore. Applying remove

@offtherailz offtherailz enabled auto-merge (squash) June 13, 2023 12:15
@offtherailz
Copy link
Member

When merged (it should auto-merge if coveralls responds), please @ElenaGalltest this on DEV. Thank you 🚀

@offtherailz offtherailz merged commit b18c10a into geosolutions-it:master Jun 13, 2023
@offtherailz
Copy link
Member

@ElenaGallo, could you please test this on DEV ? Thank you

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

Successfully merging this pull request may close these issues.

Attribute Table in read only mode
3 participants