-
-
Notifications
You must be signed in to change notification settings - Fork 708
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
Paginate Exchange Products API endpoint #4471
Paginate Exchange Products API endpoint #4471
Conversation
9a44964
to
50237ee
Compare
8368956
to
99cbbe6
Compare
9477b55
to
dfd9775
Compare
090841f
to
8d90e66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. 👍
{ | ||
results: results.total_count, | ||
pages: results.num_pages, | ||
results: paginated_products.total_count, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the same as the count of the new endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this is products count, the new endpoint is variants count.
$scope.selectAllVariants = (exchange, selected) -> | ||
$scope.loadAllExchangeProducts(exchange).then -> | ||
$scope.setExchangeVariants(exchange, $scope.suppliedVariants(exchange.enterprise_id), selected) | ||
$scope.$apply() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to manually call $scope.apply()
is a code smell in Angular...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, agree. this is the only way I managed to refresh the page after the load process finishes. angular is not triggering a re-render.
anyway, this is supposed to disappear as we implement #4487
|
||
$scope.addSupplier = ($event) -> | ||
$event.preventDefault() | ||
OrderCycle.addSupplier $scope.new_supplier_id | ||
|
||
# To select all variants we first need to load them all from the server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the best way to handle selecting all variants? Can't we decouple the saving of the "selected" state from loading all the products?
So instead of fetching and loading all the available variants in the exchange first, then sending another request to include all those variants in the exchange (and save it), can't we just have an endpoint on the server-side that handles the task of "select all the available variants in this exchange" and call that directly without doing the first step?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! that's exactly #4487
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I wasn't looking at all the issues at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no problem, it's good you described the issue in your comment without looking at it :-)
This commit breaks the OC page when there are more than 100 products in an exchange
…include summary of number of products loaded already
…ucts before triggering the select all process
… by using the total count of variants to see if all variants are selected or not, even if not all variants are loaded
…ange_products_renderer
…nt to partial templates
8d90e66
to
a104bf8
Compare
thanks @RachL Re numbers on the summary "x / y select " - I believe this is pre-existing problem and now I know why it happens. This is caused by products that changed suppliers. There are products selected in the OC that have a different supplier. Supplier caled "bb". If we change supplier again back to Dorv the numbers will become correct again. I think this can go live with this or maybe we should check if it is pre-existing. I'd open a separate issue for this. re numbers of products - argh I have not thought about this problem! this will confuse the users... but the numbers are correct, above we see number of variants, below we see numbers of products :-( |
Point 2 is a bug, those line should not show up in the simple form where we just load all the products for now. |
…include header and footer (product count and pagination) of the non-simple OC form
779f717
to
db71460
Compare
I'd say we can skip code review as I just moved files around. Meanwhile reviews can comment/review if they think is required. |
I have redepoyed this last version to au staging (now running on ruby 2.3.7). |
Alright so the error is fix! Moving to ready to go and creating the other issues. |
great, thanks @RachL |
What? Why?
Follow up from #4455
Closes #4476
This PR makes the OC pages able to handle exchanges with thousands of products by paginating the server queries to list exchange products.
More up to date demo:
http://g.recordit.co/HixXjlxPvk.gif
This PR opens up a few more major possibilities for improving performance, see isues #4480, #4481, #4482, #4487 and #4488
What should we test?
Verify the OC create and edit pages work correctly and specifically validate the list of products is loaded correctly when an exchange has more than 100 products (100 is the size of each page of products).
We should test the interaction between the load all products and the select all buttons in the exchange panel: if we click "select all" all checkboxes of the loaded products should be ticked.
One detail that may not be obvious to the user:
Release notes
Changelog Category: Changed
The pages to create and edit Order Cycles can now handle enterprises providing or selling thousands of products. This is accomplished by handling the list of products in small pages instead of handling the full list of products all the time.
Dependencies
This cannot be merged before #4455