Allow setting custom IntGrid values #1136
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
editLayerDefs.html
IntInput
to thevalue
input field with the following:LayerDef.isIntGridValueValid
ensures that0 < value <= 999
and no otherIntGridValueDef
on this layer uses the samevalue
.invalidValue
.updateIntGridValue
, on the current layer instance with the old and new value.updateIntGridValue
method toLayerInstance
which does the following:IntGridValueDef
to change the value.setIntGrid
.autoSourceLayerDefUid
).Notes:
LayerDef.isIntGridValueValid
to centralize the logic across the layer. If preferred, I can refactor this to useIntInput.setBounds
for inline validation.invalidValue
notification uses similar messaging toinvalidIdentifier
. 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.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:
Selecting the value for the
IntGridValueDef
we want to update:Changing the value to
2
:Verifying that the map has updated:
Verifying that the rules have updated:
Verifying that the contents are preserved when loading the file again:
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.