neo4j-labs / neodash

NeoDash - a Dashboard Builder for Neo4j
https://neo4j.com/labs/neodash/
Apache License 2.0
397 stars 129 forks source link

Parameter Select custom query refresh #827

Open sirko-schroeder opened 3 months ago

sirko-schroeder commented 3 months ago

Hi,

there is an issue with global variable changes not being passed on to 'parameter select' reports. e.g. I have two parameter selects for first and last names:

image

Lastname query:

match (p:Person) 
return distinct p.last_name

Firstname query:

call {
  return 
    case
       when size($neodash_lastname) > 0   then $neodash_lastname
       else collect {match (p:Person) return distinct p.last_name}
    end as last_names
}
match (p:Person)
where p.last_name in last_names
return distinct p.first_name

The problem is that the fistname list does not always gets updated after a change of the lastname select. One workaround is to toggle the firstname report to fullscreen but that makes it a bit of a cumbersome userinterface ;) ...

I am using:

sirko-schroeder commented 3 months ago

Another workaround is to "clear" all the selected values with the "X" button that appears once you hover above the value box. If no value is currently selected one must pick one first and "clear" it after. This will trigger a rerun of the query with the current value of the global $neodash_ parameter.

sirko-schroeder commented 3 months ago

Is there an event that fires on global parameter changes? For now I am using the onOpen event...

--- NodePropertyParameterSelect.tsx_org 2024-03-25 11:13:57.411188452 +0930
+++ NodePropertyParameterSelect.tsx 2024-03-25 11:22:15.843667621 +0930
@@ -188,9 +188,12 @@
           return (option && option.toString()) === (value && value.toString());
         }}
         onOpen={() => {
+     /*
           if (extraRecords && extraRecords.length == 0) {
             debouncedQueryCallback(props.query, { input: `${inputDisplayText}`, ...allParameters }, setExtraRecords);
           }
+     */
+     debouncedQueryCallback(props.query, { input: `${inputDisplayText}`, ...allParameters }, setExtraRecords);
         }}
         onBlur={() => {
           // If the user loses focus of the selector, and nothing is selected
alfredorubin96 commented 3 months ago

Hi @sirko-schroeder, thank you for filing the bug. What you're trying to do is to create a new parameter based on another one that you selected, but with the queries that you created you are just refreshing the list of possible values that populate parameter selector. Can you give me a real example of what you want to achieve? It seems a little counterintuitive. Thank you for your help

sirko-schroeder commented 3 months ago

Hi @alfredorubin96,

Can you give me a real example of what you want to achieve? It seems a little counterintuitive. Thank you for your help

The above Last Name / First Name example is my real life use case.

I can pm you a link to my 'test' dashboard if you want me to.

Kind Regards, Sirko

sirko-schroeder commented 3 months ago

To add a bit more meat to the bone. Our first-name list has more than 1400 distinct names on it and without limiting the selectable names by the last-names one could not pick one of the names 'above 1000' with standard settings. Plus it is nicer for a user to only display choices of names that actually exists for existing 'people' that have a given last-name and first-name. Another use case we have is to limit the selectable of local government areas to the ones that are within a selected regional area.

Hope that makes a little more sense.

Kind Regards, Sirko