This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from NuCivic/filterHandler
Add Filter handler
- Loading branch information
Showing
16 changed files
with
174 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Filter Handlers | ||
Filter handlers are similar to Data Handlers but are fired before the the data is fetched. This allows the ability to change the values which are used to filter the data. | ||
|
||
## filterHandler definition | ||
|
||
Filter handlers are declared in the ``settings.json`` file similar to data handlers. A key is required which is the filter for which the values will be altered. The value is the function which will return the altered values: | ||
|
||
```javascript | ||
filterHandlers: [ | ||
{ | ||
"filterToUpdate": "functionToFilterValues" | ||
} | ||
], | ||
``` | ||
|
||
And following is the implmentation of the filterHandler function. It receives the . | ||
|
||
```javascript | ||
functionToFilterValues: (componentData, dashboardData, handler, filter, state, payload) => { | ||
// Get current values. | ||
const vals = filter.vals; | ||
// Do logic to get different values; | ||
const newVals = functionThatGetsNewVals(vals); | ||
return newVals; | ||
} | ||
``` | ||
|
||
## datahandler arguments | ||
|
||
### componentData | ||
Data set on the component as this.state.data - this could come from a fetch call, be passed as props, or through some novel method on a custom component. | ||
|
||
### dashboardData | ||
Also referred to as globalData - this is the data available to the entire dashboard | ||
|
||
### handler | ||
The handler as deffined in settings.js. Any properties set on the handler are available as `handler.foo`, etc | ||
|
||
### filter | ||
The filter to which values are being updated. | ||
|
||
### state | ||
Current app state. | ||
|
||
### payload | ||
The update event that comes from a filter component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ Data Handling | |
overview | ||
datahandlers | ||
statehandlers | ||
filterhandlers | ||
backends |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.