humanmade / hm-gutenberg-tools

Useful helpers, components or tools for building things with Gutenberg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make it possible to filter posts by date range

Rayhatron opened this issue · comments

Context

Date range filters would help narrow down the number of posts returned by the Post Select component.

This is particularly helpful when you don't know the exact title and maybe the keywords you have are common among several posts. So combining those keywords and a date range in addition to taxonomies will refine the search results much more.

Technical brief

  • Create a form-field-date component here
  • Component to have a DatePicker for use in picking start and end date that'll be used to search for a post
  • Two instances of the component to be added here for the start and end dates respectively
  • Default date to be null so that if no dates are found in the filters then the search won't include dates
  • The values of those FormFieldDate components to be publishedAfter and publishedBefore respectively
  • onChange of those components to use onUpdateFilters to update the values of those two dates
  • Retrieve the publishedAfter and publishedBefore on the postSelect endpoint here
  • If either publishedAfter is not empty or publishedBefore is not empty, set date_query after and before parameters of the query here respectively
  • Post Select button to receive a showDateFilters prop that controls whether the filters are shown on Select modal or not

Acceptance Criteria

  • Two date pickers show up on the select a post modal
  • Setting one of the dates should filter the posts correctly based on that date
  • Setting both dates should filter posts to include only the posts in the date range
  • Date range filters should be an optional addition depending on how Post Select button is setup