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

Filter queries using correct operators #952

Merged
merged 5 commits into from Dec 10, 2020

Conversation

Atmire-Kristof
Copy link
Contributor

@Atmire-Kristof Atmire-Kristof commented Nov 19, 2020

References

Description

This PR ensures operators are added when sending requests containing facets or filters through discovery. The operators are retrieved from the relevant part of the search link returned by the server, rather than have the UI construct the query on its own.

Instructions for Reviewers

Changes made:

  • A util file was added called search.utils.ts containing a method (getFacetValueForType()) to retrieve the relevant facet value with operator from the search link returned by the server. The util file also contains functions to strip an operator from a filter's value or add one to it.
  • When a user types or selects a suggested filter, the operator "query" is added to the value
  • Modified labels to strip the operator (using the util function) wherever the filter values displayed (below the search box for example)

How to test:

  • Visit the discovery page
  • Add filters by selecting one from the sidebar or typing them yourself (and/or selecting from the suggestion dropdown)
  • Verify the requests sent contain the correct operators for each filter value
  • Verify any values displayed in the UI don't contain the operators

Known Issue
Issue #3057 on the REST API might cause unexpected behaviour.

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes TSLint validation using yarn run lint
  • My PR doesn't introduce circular dependencies
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new, third-party dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.

@artlowel artlowel added this to Needs Reviewers Assigned in DSpace 7 Beta 5 via automation Nov 19, 2020
@lgtm-com
Copy link

lgtm-com bot commented Nov 19, 2020

This pull request introduces 2 alerts when merging cb6381f into 8d44b5d - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

@tdonohue tdonohue added 1 APPROVAL pull request only requires a single approval to merge bug labels Nov 19, 2020
@tdonohue tdonohue moved this from Needs Reviewers Assigned to Under Review in DSpace 7 Beta 5 Nov 19, 2020
@tdonohue tdonohue added this to the 7.0beta5 milestone Dec 3, 2020
@tdonohue tdonohue requested review from tdonohue and removed request for atarix83 December 3, 2020 15:52
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks @Atmire-Kristof . This code looks good & works well.

@artlowel mentioned in today's meeting we may want to eventually think about updating the backend to use templated links (as originally described in this comment). However, this current implementation seems "good enough" for now, and it fixes the immediate bugs.

DSpace 7 Beta 5 automation moved this from Under Review to Reviewer Approved Dec 10, 2020
@tdonohue tdonohue merged commit ab9d5b4 into DSpace:main Dec 10, 2020
DSpace 7 Beta 5 automation moved this from Reviewer Approved to Done Dec 10, 2020
DSpace 7 Beta 5 automation moved this from Done to Reviewer Approved Apr 15, 2021
DSpace 7 Beta 5 automation moved this from Reviewer Approved to Done Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 APPROVAL pull request only requires a single approval to merge bug
Projects
No open projects
2 participants