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

Update docs and allow for numeric filter value. #1307

Merged
merged 3 commits into from
Jun 10, 2024

Conversation

dbauszus-glx
Copy link
Member

The filter_in function should work on an array of numeric values.

eg.

{
  "field": "minutes",
  "type": "integer",
  "filter": {
    "type": "in",
    "searchbox": true
}

The searchbox function doesn't require a defaultSearch method which was used as a method to append the no search results.

The searchbox function should warn if no searchFunction is provided.

I split the add() and remove() methods from the pills(component) method for clarity.

Updated the docs for
@module /ui/layers/filters, @function filter_in

@module /ui/elements/searchbox, @function searchbox

@module /ui/elements/pills, @function pills, @function add, @function remove

I found this hard to understand.

        filtered
        .filter(i => !pillComponent.pills.has(i)) // only those not selected already
        .map((i, j) => {
          if(j > 9) return; // show only 10 top matches
          searchbox.list.appendChild(mapp.utils.html.node`<li onclick=${e => {
            if(pillComponent.pills.has(i)) return;
            pillComponent.add(i);
          }}>${i}`);

I prefer to use named variables, where can be the index. Using i as value, and j as index was very hard to understand.
I prefer to use filter separately eg (i<9) opposed to a condition in an array map/forEach method. I prefer to use forEach if nothing is returned from the method which is the point of the map method.

        filtered
          .filter(val => !pillComponent.pills.has(val)) // only those not selected already
          .filter((val, i) => i < 9)
          .forEach(val => {

            // Append li element to searchbox.list
            searchbox.list.append(mapp.utils.html.node`
              <li onclick=${() => {
                // Add pill not yet in pillComponent
                !pillComponent.pills.has(val) && pillComponent.add(val);
              }}>${val}`)
          });

@dbauszus-glx dbauszus-glx added Bug A genuine bug. There must be some form of error exception to work with. Code Issues related to the code structure and performance. Documentation Adding or updating documentation. labels Jun 6, 2024
@dbauszus-glx dbauszus-glx linked an issue Jun 6, 2024 that may be closed by this pull request
Copy link

sonarcloud bot commented Jun 7, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@AlexanderGeere AlexanderGeere left a comment

Choose a reason for hiding this comment

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

Looks Good to me!

@dbauszus-glx dbauszus-glx merged commit 374c5da into GEOLYTIX:main Jun 10, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A genuine bug. There must be some form of error exception to work with. Code Issues related to the code structure and performance. Documentation Adding or updating documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requirements for searchbox filtering search function
2 participants