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 filter components to support non metacard based filters, add better number validation #966

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

andrewkfiedler
Copy link
Contributor

@andrewkfiedler andrewkfiedler commented Jul 29, 2024

  • It's useful to use these filter components on non metacard filters in order to build UI components that hit solr for other things, which this will allow.
  • The number validation on some of the filters was preventing users from doing things like deleting their value and starting with a negative, so it's been rewritten to keep values around locally no matter what, and only propagate those as changes to the filter when they're valid. If unvalid, the user is notified that the previous valid value will be used instead.

Copy link

An updated dist branch has been created and pushed to origin.
You can use:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-966",
in your package.json to use this version in your project.

Remember to use "yarn install --force" if you want to pick up changes each time you make a change to this branch by committing.

github-actions bot pushed a commit that referenced this pull request Jul 29, 2024
Copy link

An updated dist branch has been created and pushed to origin.
You can use:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-966",
in your package.json to use this version in your project.

Remember to use "yarn install --force" if you want to pick up changes each time you make a change to this branch by committing.

github-actions bot pushed a commit that referenced this pull request Jul 30, 2024
Copy link

github-actions bot commented Aug 9, 2024

An updated dist branch has been created and pushed to origin.
You can use:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-966",
in your package.json to use this version in your project.

Remember to use "yarn install --force" if you want to pick up changes each time you make a change to this branch by committing.

github-actions bot pushed a commit that referenced this pull request Aug 9, 2024
…etter number validation

 - It's useful to use these filter components on non metacard filters in order to build UI components that hit solr for other things, which this will allow.
 - The number validation on some of the filters was preventing users from doing things like deleting their value and starting with a negative, so it's been rewritten to keep values around locally no matter what, and only propagate those as changes to the filter when they're valid.  If unvalid, the user is notified that the previous valid value will be used instead.
@andrewkfiedler andrewkfiedler changed the title [WIP] Allow non metacard filters to be created Update filter components to support non metacard based filters, add better number validation Aug 15, 2024
}}
/>
)
user
.get('user')
.get('preferences')
.set('dateTimeFormat', Common.getDateTimeFormats()['ISO']['minute'])
setTimeout(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoids the issue where we generate an onChange before the expected onChange around precision.

@@ -59,6 +59,10 @@ const validateDate = (
}

export const DateAroundField = ({ value, onChange }: DateAroundProps) => {
const validValue = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move the handling of optional / invalid values up to this common point rather than down in the component.

value: value.buffer.amount,
}
: {})}
validation={(val) => val > 0}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Notice we can pass in extra validation to the number field, in this case to say we only allow positive numbers.

@@ -26,6 +26,10 @@ const isInvalid = ({ value }: Props) => {
}

export const DateRelativeField = ({ value, onChange }: Props) => {
const validValue = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar change to move handling of invalid values to the top of the component.

Copy link

An updated dist branch has been created and pushed to origin.
You can use:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-966",
in your package.json to use this version in your project.

Remember to use "yarn install --force" if you want to pick up changes each time you make a change to this branch by committing.

github-actions bot pushed a commit that referenced this pull request Aug 15, 2024
React.useState('')

React.useEffect(() => {
if (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is where we decide if we will send the new value to the filter (or other parent component with an onChange).

Copy link

An updated dist branch has been created and pushed to origin.
You can use:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-966",
in your package.json to use this version in your project.

Remember to use "yarn install --force" if you want to pick up changes each time you make a change to this branch by committing.

github-actions bot pushed a commit that referenced this pull request Aug 15, 2024
@@ -0,0 +1,221 @@
import { FilterClass, ValueType, ValueTypes } from './filter.structure'

export const isRelativeValue = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bunch of utilities to make it possible to narrow down what type of filter you're handling.

)
}

export const isValueEmpty = (filter: FilterClass): boolean => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A general utility around deciding if a filter has been "filled out" so to speak and is valid.

@@ -149,3 +152,38 @@ export const getComparators = (attribute: string): ComparatorType[] => {
}
return comparators
}

export const ComparatorContext = React.createContext({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what enables us to properly assign comparators in non metacard situations.

@andrewkfiedler
Copy link
Contributor Author

build now

@cxddfuibot
Copy link
Collaborator

Internal build has been started, your results will be available at build completion.

@cxddfuibot
Copy link
Collaborator

Build SUCCESS See the job results in legacy Jenkins UI or in Blue Ocean UI.

@andrewkfiedler andrewkfiedler merged commit 91e121a into master Aug 15, 2024
3 checks passed
Copy link

You can no longer use:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-966",
in your package.json to use this version in your project, as it has been deleted now that the pull request is closed.

Instead, if the pr was merged you can now access these changes by using:
"catalog-ui-search": "https://github.com/codice/ddf-ui#catalog-ui-search-dist-snapshot",

Remember to use "yarn install --force" if you want to pick up changes to this version.

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.

2 participants