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

Allow setting custom IntGrid values #1136

Open
wants to merge 2 commits into
base: dev-1.5.4
Choose a base branch
from

Conversation

billylegota
Copy link

This pull request introduces the ability for users to edit IntGridValueDef values through an input field, while ensuring proper validation and rule updates.

Closes #1083.

Overview:

  • Changed value indicator to an input field in editLayerDefs.html
  • Added IntInput to the value input field with the following:
    • Validation rule: LayerDef.isIntGridValueValid ensures that 0 < value <= 999 and no other IntGridValueDef on this layer uses the same value.
    • On invalid: Created new notification invalidValue.
    • Setter: calls new method, updateIntGridValue, on the current layer instance with the old and new value.
  • Added updateIntGridValue method to LayerInstance which does the following:
    • Updates the IntGridValueDef to change the value.
    • Updates all stored values by calling setIntGrid.
    • Updates the current layer's definition's auto rules (as the patterns need to be updated with the new value).
    • Updates the auto rules for all levels whose auto source is this layer (not combined with the previous step as the current layer does not have a reference to itself in autoSourceLayerDefUid).

Notes:

  • Changing the value indicator to an input field altered the text formatting slightly, but I am unsure how to restore the original formatting. I can look into it further if needed.
  • The range validation is currently handled in LayerDef.isIntGridValueValid to centralize the logic across the layer. If preferred, I can refactor this to use IntInput.setBounds for inline validation.
  • The invalidValue notification uses similar messaging to invalidIdentifier. However, I can modify it to explicitly state the value restrictions (e.g., "Value must be a positive integer less than 1000 and unique within the layer.") if you'd prefer a more detailed message.
  • I tried to keep the code style as close as I could to the existing code. Let me know if you have any recommendations.

Example Usage:

Below is an example of updating the IntGridValueDef, including verification that changes are properly reflected in the map, auto rules, and when reloading the file.

Initial IntGrid settings:
image

Selecting the value for the IntGridValueDef we want to update:
image

Changing the value to 2:
image

Verifying that the map has updated:
image

Verifying that the rules have updated:
image

Verifying that the contents are preserved when loading the file again:
image


By submitting this pull request, I hereby assign all copyright and related rights in the changes contained in this pull request to the maintainer(s) of this project, to the extent permitted by law.

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

Successfully merging this pull request may close these issues.

1 participant