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

Feature/1374 configurable search options #1496

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

linusfj
Copy link
Member

@linusfj linusfj commented Apr 9, 2024

Closes #1374.

This commit introduces a new JSON structure in the client for managing and controlling which search functionalities are enabled. The updated structure utilizes an array named `enabledSearchOptions`, including the following options:

- matchCase
- activeSpatialFilter
- wildcardAtStart
- searchInVisibleLayers
- wildcardAtEnd
- enableLabelOnHighlight

This approach allows for centralized management of search options, making it easy to enable or disable specific functionalities directly through the admin UI. To ensure these settings always take effect when changed, they are not stored in `localStorage`.
@Hallbergs Hallbergs self-requested a review April 23, 2024 06:59
Hallbergs
Hallbergs previously approved these changes Apr 23, 2024
Copy link
Member

@Hallbergs Hallbergs left a comment

Choose a reason for hiding this comment

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

Works well!

The code could be refactored though. For example the following is repeated in several places:

onChange={(e) => {
                const { checked } = e.target;
                this.setState((prevState) => {
                  const enabledSearchOptions = new Set(
                    prevState.enabledSearchOptions
                  );
                  if (checked) {
                    enabledSearchOptions.add("searchInVisibleLayers");
                  } else {
                    enabledSearchOptions.delete("searchInVisibleLayers");
                  }
                  return {
                    enabledSearchOptions: Array.from(enabledSearchOptions),
                  };
                });
              }}

Refactor repeated `onChange` logic into a reusable method `handleOnChange`.
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.

Make the function "search only in visible layers" optional in admin
2 participants