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

Advanced search form is overwhelming #1722

Merged
merged 14 commits into from
Mar 6, 2024
Merged

Advanced search form is overwhelming #1722

merged 14 commits into from
Mar 6, 2024

Conversation

Sandravaphilips
Copy link
Collaborator

@Sandravaphilips Sandravaphilips commented Feb 11, 2024

@Sandravaphilips
Copy link
Collaborator Author

@longhotsummer this is what we have now:
https://www.loom.com/share/a2785ac2bb504e8f986f7dbc4519f497?sid=475202ba-d691-4786-bb7a-29386adf0058
I'm looking for ways to optimize the code, so your ideas are very welcome.

@Sandravaphilips
Copy link
Collaborator Author

Sandravaphilips commented Feb 27, 2024

@longhotsummer
Copy link
Contributor

Looking much better. I still think you're trying to fit the new world too much into how the old world worked. The advanced search UI is no longer field-driven, it's criteria driven, where each criteria is shown as a row, and can apply to one or more fields.

Here's more detail: https://www.loom.com/share/be51337db24e4e06a906aae08e6631e4

And here's some pseudo-code to outline what I think that looks like:

// the rows of the advanced search form
const advancedSearchCriteria = [{
  text: "foo",  // from the input box
  fields: ["title", "content"], // from the fields checkboxes
  condition: "AND",  // from the AND/OR dropdown
  phrase: false,   // from the exact phrase checkbox
}, {
  text: "bar boom",
  fields: [],      // default is ALL
  condition: "NOT",
  phrase: true, 
}];

const advancedSearchDateCriteria = { ... };   // treat the dates separately to the rows above, they're different beasts


// the advanced search params to send to the server
const params = { ... (facets, etc.) }

function formatFieldQuery(criterion, params) {
  let q = "";
  
  if (criterion.condition == "AND") { ... }
  else if (criterion.condition == "NOT" { ... }
  // etc.
  
  // add q to each of the search fields that its applicable to
  // TODO: handle fields is empty therefore ALL fields
  for (const fld of criterion.fields) {
    params[`search_{fld}`] = (params[`search_{fld}`] || "") + " " + q
  }
}


advancedSearchCriteria.forEach(c => addSearchParams(c, params));

@longhotsummer longhotsummer marked this pull request as ready for review March 6, 2024 06:03
@longhotsummer longhotsummer merged commit b311544 into main Mar 6, 2024
9 checks passed
@longhotsummer longhotsummer deleted the sandrava-1714 branch March 6, 2024 06:53
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.

Advanced search form is overwhelming
2 participants