Skip to content

Dynamic filter #231

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

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

Dynamic filter #231

wants to merge 2 commits into from

Conversation

SerVitasik
Copy link
Contributor

No description provided.

Copy link
Contributor

@ivictbor ivictbor left a comment

Choose a reason for hiding this comment

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

I think if we did not disable poly search and do validating, lets finish it so it will be universal (might happen indeed)

: [col.foreignResource.searchableFields];

searchableFields.forEach((fieldName) => {
if (typeof fieldName !== 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

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

@SerVitasik or text at least

const targetResource = this.inputConfig.resources.find((r) => r.resourceId === pr.resourceId || r.table === pr.resourceId);
if (targetResource) {
const hasField = targetResource.columns.some((targetCol) => targetCol.name === fieldName);
if (!hasField) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so if at least one resource will not have column it will crash. This should be changed to - if there are no resources which have this column then crash.
Probably a little bit implicit but i suggest next behaviour:

if poly has 2 resources:

  • if res A has column C and res be has no col C - then when searching use column C in where of res A query, but dont use in query of res B (in query for res b use columns which exist)
  • if both res A and B has col C - use it in both queries (to both resources)
  • if no of resources has column C - drop this error here and say explicitly - we can't find this column neither in A nor in B.

So when applying poly search (later in code) - extract subset of this searchable fields which exist in resource and use only them in search with disjunction way

@@ -905,6 +905,34 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
throw new Error(`Wrong filter object value: ${JSON.stringify(filters)}`);
}
}

if (search && search.trim() && columnConfig.foreignResource.searchableFields) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think poly case is not implemented here at all - it should do parallel queries

Copy link
Contributor

Choose a reason for hiding this comment

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

or probably you can do it on frontend (later) - should be possible also, maybe even better

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