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

feat: multi-selection time period filters #4507

Merged
merged 1 commit into from
Mar 15, 2021

Conversation

iskounen
Copy link
Contributor

@iskounen iskounen commented Mar 9, 2021

The type of this PR is: Feature

This PR resolves FX-2624

This PR is the work of @dzucconi, @dblandin, and @anandaroop

Description

  • Allows multiple selection of time period (a.k.a. major period) filters on artwork grids.

Screenshots

Before

before_time_options

After

after_time_options

PR Checklist (tick all before merging)

  • I have included screenshots or videos to illustrate my changes, or I have not changed anything that impacts the UI.
  • I have added tests for my changes, or my changes don't require testing, or I have included a link to a separate Jira ticket covering the tests.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added an app state migration, or my changes do not require one. (What are migrations?)
  • I have added a CHANGELOG.yml entry or my changes do not require one.

@iskounen iskounen force-pushed the iskounen/update-artwork-time-period-filter branch from 7e3f051 to de3c702 Compare March 9, 2021 04:21
@iskounen iskounen marked this pull request as draft March 9, 2021 04:31
@iskounen
Copy link
Contributor Author

iskounen commented Mar 9, 2021

The Apply button is currently displaying "Apply (1)" for any combination of time periods because we pass all selected options as one array of values like so:

[{"displayText": "2010-2019", "paramName": "majorPeriods", "paramValue": ["2020", "2010"]}]

The "Ways to buy" filter, however, can display "Apply (2)" when two options are selected because it passes each selected option as a separate filter like so:

[{"displayText": "Bid", "paramName": "atAuction", "paramValue": true}, {"displayText": "Make offer", "paramName": "offerable", "paramValue": true}]

@iskounen iskounen force-pushed the iskounen/update-artwork-time-period-filter branch from de3c702 to 500eda5 Compare March 9, 2021 04:45
@iskounen iskounen marked this pull request as ready for review March 9, 2021 04:52
@MounirDhahri
Copy link
Member

This looks good.

About the designs, I thought we were trying to push more into the direction of using checkmarks instead of toggle switches to have more consistent behavior in all filter types. It offers a better UX (since the user will expect to check an item by pressing anywhere in the row instead of only selecting the toggle switch). But I see that the filters specs made by CX are designed differently than the ones made by FX. @samchieng do you mind if you clear this out to make sure we don't have more different type of filters in the future.

The Apply button is currently displaying "Apply (1)" for any combination of time periods because we pass all selected options as one array of values like so:

That's great, that's the behavior we want.

The "Ways to buy" filter, however, can display "Apply (2)" when two options are selected because it passes each selected option as a separate filter like so:

Ideally we should be showing this as 1 as well. Take a look at this

// For Sale Artworks, the artistsIDs and the includeArtworksByFollowedArtists filters behave like one
if (state.filterType === "saleArtwork") {
const hasArtistsIFollow = !!state.selectedFilters.find(
(filter) => filter.paramName === FilterParamName.artistsIFollow
)
const hasArtistIDs = !!state.selectedFilters.find((filter) => filter.paramName === FilterParamName.artistIDs)
if (hasArtistIDs && hasArtistsIFollow) {
--selectedFiltersSum
}
}
and this
// For Sale Artworks, the artistsIDs and the includeArtworksByFollowedArtists filters behave like one
// Therefore we need to decrement the number of filters by one to give the user the impression they are one
if (state.filterType === "saleArtwork") {
const hasArtistsIFollow = !!state.appliedFilters.find(
(filter) => filter.paramName === FilterParamName.artistsIFollow
)
const hasArtistIDs = !!state.appliedFilters.find((filter) => filter.paramName === FilterParamName.artistIDs)
if (hasArtistIDs && hasArtistsIFollow) {
--selectedFiltersSum
}
}

Copy link
Member

@anandaroop anandaroop left a comment

Choose a reason for hiding this comment

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

Nice, and thanks for leading this mob 🙏


expect(item).not.toBeUndefined()
if (item) {
expect(extractText(item)).toContain("2020, 2000")
Copy link
Member

Choose a reason for hiding this comment

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

Based on real-world data I was expecting to see these as ranges ("2000–2010" etc) — but this is fine bc they match the mock data, yeah?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's correct. I confirmed by changing the mocked data to ["Roger", "Robert"] and observing that the result was a comma-separated string "Roger, Robert".

Copy link
Member

@dblandin dblandin left a comment

Choose a reason for hiding this comment

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

LGTM 👍 💯

CHANGELOG.yml Outdated Show resolved Hide resolved
@samchieng
Copy link

@MounirDhahri yes, apologies for the inconsistencies right now! Currently collaborating with Tricia to refine the final filter specs.

@iskounen iskounen force-pushed the iskounen/update-artwork-time-period-filter branch from 500eda5 to 3077a51 Compare March 10, 2021 12:48
@iskounen iskounen marked this pull request as draft March 10, 2021 12:58
@iskounen
Copy link
Contributor Author

iskounen commented Mar 11, 2021

This PR will be in a draft state until the work to place it behind a feature flag is complete.

@iskounen iskounen force-pushed the iskounen/update-artwork-time-period-filter branch from 3077a51 to df78831 Compare March 12, 2021 14:29
@iskounen iskounen force-pushed the iskounen/update-artwork-time-period-filter branch 2 times, most recently from 784d3ff to 9eca6ad Compare March 12, 2021 15:48
@iskounen iskounen marked this pull request as ready for review March 12, 2021 15:58
includeArtworksByFollowedArtists: false,
inquireableOnly: false,
latestCreatedYear: undefined,
majorPeriods: undefined,
majorPeriods: [],
Copy link
Contributor Author

@iskounen iskounen Mar 12, 2021

Choose a reason for hiding this comment

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

I didn't put this behind a feature flag because I don't think that the actual value matters for the single-selection implementation, as long as there is one.

I tested the "All" option on the time periods filter with and without the feature flag to confirm this, and both the results and the filters screen behaved as expected.

Copy link
Member

@dzucconi dzucconi left a comment

Choose a reason for hiding this comment

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

Looks good to me. Feel free to merge after the changelog conflict is resolved 😞

@iskounen iskounen force-pushed the iskounen/update-artwork-time-period-filter branch from 2d3f1be to b7448f2 Compare March 15, 2021 15:50
@iskounen iskounen merged commit 52994d4 into master Mar 15, 2021
@iskounen iskounen deleted the iskounen/update-artwork-time-period-filter branch March 15, 2021 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants