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(api): add data to CurrentRefinements connector #1550

Merged
merged 1 commit into from
Nov 16, 2016

Conversation

mthuret
Copy link
Contributor

@mthuret mthuret commented Nov 15, 2016

final items structure:

items: [
 {
    label: string (for display),
    attributeName: string, 
    currentRefinement: string, {min/max}, or array
    value: to pass to refine
    items: array optional [{label, value}]
 }
]

@algobot
Copy link
Contributor

algobot commented Nov 15, 2016

By analyzing the blame information on this pull request, we identified @Morhaus, @vvo and @Kikobeats to be potential reviewers

return filters.reduce((res, filter) => filter.clear(res), state);
refine(props, state, items) {
// `value` corresponds to our internal clear function computed in each connector metadata.
const clears = items instanceof Array ? items.map(item => item.value) : [items];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm very not satisfied of this naming. If someone has a better idea, i'll take it!
The tricky part is that either the user pass us an array of items (to remove all of them), or directly a clear function..

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand your comment, can you detail a bit more?

Copy link
Contributor Author

@mthuret mthuret Nov 15, 2016

Choose a reason for hiding this comment

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

refine here has one purpose: calling the clear function to remove refinements.
We hide this to the end user by passing a clear function as value, then he need to use it like this: props.refine(item.value).

However we have two use cases: either we directly have the clear function if it's a single clear, or we get an array of items, and then the idea is to call each clear function to remove all filters at the same time (clearAll behavior).

I'm just unhappy with the naming I found to express this in the code.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's still the naming issue I pointed. It might not be so easy to understand the code. But currently I don't have a better idea for it.

I do not see any BIG issue with it right now, is your naming issue only about "const clears"? Then we can call it "const refinementsToClear"?

@mthuret
Copy link
Contributor Author

mthuret commented Nov 15, 2016

I voluntarly didn't spent much time to improve our CurrentRefinements widget. We first need to determine what would be a kick-ass CurrentRefinements widget.

@mthuret mthuret force-pushed the docs/current-filters-api-change branch from ee3d199 to ca1ef10 Compare November 15, 2016 14:27
@@ -80,7 +80,7 @@ function transformValue(value, limit, props, state) {
* @propType {string} [separator='>'] - Specifies the level separator used in the data.
* @propType {string[]} [rootPath=null] - The already selected and hidden path.
* @propType {boolean} [showParentLevel=true] - Flag to set if the parent level should be displayed.
* @providedPropType {function} refine - a function to remove a single filter
* @providedPropType {function} refine - a function to select a refinement
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it toggle the value or just select it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

toggle is more accurate

@mthuret mthuret force-pushed the docs/current-filters-api-change branch from ca1ef10 to 3462cf0 Compare November 15, 2016 15:55
@vvo
Copy link
Contributor

vvo commented Nov 15, 2016

Are we good here?

@mthuret
Copy link
Contributor Author

mthuret commented Nov 15, 2016

There's still the naming issue I pointed. It might not be so easy to understand the code. But currently I don't have a better idea for it.

BREAKING CHANGE:
some data were added to CurrentRefinements connector if our computed label isn't the one wanted. See the docs for more information about the new structure.
@mthuret mthuret force-pushed the docs/current-filters-api-change branch from 3462cf0 to b810bab Compare November 16, 2016 09:18
@vvo vvo merged commit a9dd0a5 into v2 Nov 16, 2016
@vvo vvo deleted the docs/current-filters-api-change branch November 16, 2016 10:07
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.

4 participants