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

Arrange for pager to adapt itself to numberOfResults on each new query #465

Merged
merged 5 commits into from May 23, 2017

Conversation

olamothe
Copy link
Member

This allows the ResultsPerPage component to modify the number of results in a page on each new query, and the pager will correctly recalculate it's boundary.

This also ensure you cannot "go over" the max number of page and get stuck.

Deploy

@olamothe
Copy link
Member Author

I added @fbeaudoincoveo so you can review the doc comments on the deprecated option.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.789% when pulling 17f22cc on JSUI-1584 into 72d0bc2 on master.

Copy link
Contributor

@francoislg francoislg left a comment

Choose a reason for hiding this comment

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

👍

import { QueryEvents, INewQueryEventArgs, IBuildingQueryEventArgs, IQuerySuccessEventArgs, INoResultsEventArgs } from '../../events/QueryEvents';
import {
QueryEvents, INewQueryEventArgs, IBuildingQueryEventArgs, IQuerySuccessEventArgs, INoResultsEventArgs,
IDoneBuildingQueryEventArgs
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird alignment => Either 1-line or multiple lines

this.bind.onRootElement(QueryEvents.newQuery, (args: INewQueryEventArgs) => this.handleNewQuery(args));
this.bind.onRootElement(QueryEvents.buildingQuery, (args: IBuildingQueryEventArgs) => this.handleBuildingQuery(args));
this.bind.onRootElement(QueryEvents.doneBuildingQuery, (args: IBuildingQueryEventArgs)=> this.handleDoneBuildingQuery(args));
Copy link
Contributor

Choose a reason for hiding this comment

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

formatting: () => (space)

There are others in this file and PagerTest.ts

lastValidPage = possibleValidPage;
}
} else if (this.currentPage > this.getMaxNumberOfPagesForCurrentResultsPerPage()) {
// Second scenario : Someone tried to access a non-valid page by the URL for example, which is higher than the current possible with the number of
Copy link
Contributor

Choose a reason for hiding this comment

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

An ogre ran away with the end of this comment. Get it back! 👹 ⚔️ 🏃

// before triggering/queuing the next query;
// if we cannot find a lastValidPage to go to, do nothing : this means it's a query that simply return nothing.
if (lastValidPage != null) {
Defer.defer(()=> this.setPage(lastValidPage));
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about deferring to execute after other callbacks. Can't you handle this directly in the querySuccess event?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. There's actually a mechanism to retry the query, just like the DidYouMean feature use.

It's a flag on the noResults data that I can use to retry the query immediately.

*/
maxNumberOfPages: ComponentOptions.buildNumberOption({ defaultValue: undefined })
maximumNumberOfResultsFromIndex: ComponentOptions.buildNumberOption({
Copy link
Contributor

Choose a reason for hiding this comment

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

Specifies the maximum number of results that the index can return for any query.

Default value is 1000 in a Coveo index.

If this value was modified in your Coveo index, you must specify the new value in this option for the Pager component to work properly.

*
* @deprecated
*/
maxNumberOfPages: ComponentOptions.buildNumberOption({
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not quite sure we should update the actual documentation of deprecated options.

We could rather add the new info next to the @deprecated tag.

So, we would have something like this:

Specifies the maximum number of pages to display if enough results are available.

This property is typically set when the default number of accessible results from the index has been changed from its default value of `1000` (10 results per page X 100 `maxNumberOfPages`).

Default value is `100`

@deprecated This is a deprecated option. The `Pager` now automatically adapts itself on each new query, so you no longer need to specify a value for this option. However, if the default maximum number of accessible results value was changed on your Coveo index, you should use the [`maximumNumberOfResultsFromIndex`]{@link Pager.options.maximumNumberOfResultsFromIndex} option to specify the new value.

On the generated doc site, the "deprecated" tag, along with its text, will be displayed in bright red at the very beginning of the option documentation. Should be clear enough :)

Copy link
Contributor

@fbeaudoincoveo fbeaudoincoveo left a comment

Choose a reason for hiding this comment

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

See my two comments

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.831% when pulling 1b40489 on JSUI-1584 into c5b7caa on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.831% when pulling 1b40489 on JSUI-1584 into c5b7caa on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants