-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add pagination to Studio's Files and Uploads page #1912
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
Conversation
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.
What happens if someone accidentally or maliciously passes in a non-integer string for this parameter? Your code should do a try/catch when converting to int, and if a TypeError or ValueError occurs, handle it in some way.
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.
If you want to create a helper method for this, a good place would be /edx-platform/common/djangoapps/util/string_utils.py
|
If I type letters ("abc") in the pagination field, I see the text on top of the page number. I would expect the letters to disappear (and to stay on the same page). |
cms/static/js/views/paging_header.js
Outdated
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.
Translation strings should not contain HTML. Use placeholders (the same way you're already using placeholders for %(start)s and %(end)s) to replace the HTML into the string after it's been localized.
|
If I type -5 in the pagination field and press Enter, about half of the time I get a JavaScript alert dialog with message "Error: [object Object"]. |
cms/static/js/collections/asset.js
Outdated
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.
application/json should be the default accepts header for AJAX requests. You can also pass AJAX options through the model.save() call -- it proxies through Backbone.sync to $.ajax. Backbone's source code is actually very readable, if you want to see how it works under the covers.
|
Get rid of this from the URL (form submission). awefjaseofj?page-number=-2# |
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.
Get rid of old start and max (not working anyway).
|
This general approach looks good. |
|
@frrrances, can you check out this PR when you get a chance. Also, it would be great to finalize how we are going to disable the Next/Previous buttons. Thanks! |
|
@frrrances I've fixed all the bugs including the performance problem you were seeing (I think). Can you try this again. Two issues remain:
Can you help me look into these two. In the meantime I'm going to get back to testing. |
|
@frrrances One more thing: the page input field looks odd when entering text as it still shows the current page number in gray underneath. How would you generally handle this? Could the label be hidden when the input has focus? |
|
@andy-armstrong looks like my sass changed got dropped at some point. I've added them back in and adjusted the focus to handle the transparency a bit better. |
|
Performance and everything else looks good to me now. 👍 |
|
@cahrens @singingwolfboy @frrrances @jzoldak This feature is ready for re-review. BTW, the BDD is also now available if you'd like to review that too: https://edx-wiki.atlassian.net/wiki/display/STU/BDD+specs+for+Asset+Pagination |
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.
Personally, I would create a helper function (can be scoped just to this method) for the 5 lines of duplicated code. But that's a nit. Actually, if you allow URL to be an argument, you could remove another duplicated line of code.
cms/static/js/views/paging_header.js
Outdated
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.
currentPage and pageSize are unused variables.
|
@talbs Since I worked on this feature, can you review my sass/experience work? |
|
Need to update CHANGELOG.rst. Also, you'll want to squash commits at some point. I'd prefer you do it at the end so I can easily see what changes you make in response to feedback. |
|
@singingwolfboy @cahrens, thanks for the detailed feedback. Hopefully I've addressed everything in this latest commit. BTW, Frances wants me to hold off pushing these until Brian returns on Friday so he can review her sass changes. |
cms/static/js/views/paging.js
Outdated
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.
gettext is not listed in requireJS imports. This code does not work if you kill the server and try paging.
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.
Good catch. I guess I should have added a unit test for this method too...
|
There is still a problem with create_sinon being called in a beforeEach section of assets_spec.coffee. I put a couple comments there, but the new comments show up linked to a previous discussion, and therefore you don't see them here at the end of the review. |
|
Still need to update the documentation in assets.py-- Update the documentation, which says that JSON is not supported. Also, documentation around what is returned for HTML needs to be updated. |
|
@cahrens Can you re-re-review :-) |
|
My comments above are on a particular commit-- sorry. Here's a helper function declaration that works. It's not pretty-- I'm sure it could be improved by someone who understands Coffee better! I'm returning requests just in case you need the array later in a particular test. |
|
@cahrens It might make more sense to just explicitly bind the value of setup = (response) ->
requests = create_sinon.requests(this)
@view.setPage(0)
create_sinon.respondWithJson(requests, response)
return requests
it "should render both assets", ->
setup.call(this, @mockAssetsResponse)
expect(@view.$el).toContainText("test asset 1")
expect(@view.$el).toContainText("test asset 2")Aside from that, your Coffeescript looks good to me! :) |
|
@singingwolfboy Yes, that's better. And in that case, setup could access @mockAssetsResponse, so it wouldn't need to be passed in. |
|
👍 After removing AlertView.Error, checking with Don about getting total number of assets, and a few minor updates I suggested, if you are so inclined. |
|
@dmitchell Can you review the Python changes that you helped me with to implement the count parameter. |
|
Yep, those look like the paired programming changes we made :-) 👍 |
|
Unless I hear otherwise, I'll merge this request on Friday once Brian gives the FED his blessing. Thanks for your patience, everyone! |
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.
This looks solid - one question though: should we make this blockish/hover knock-out UI styling a Sass mixin/extend yet? If we're using it in several views now, I'd say "yes" for maintenance and easse of ripping off your good work's sake. If you'd rather do that in a follow up PR, that's fine too.
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.
Good call. I'll put that in a new PR since I know Andy and Christina want this to get in today if possible.
|
Hi, all. My apologies for the holiday break slow-down with this work. I've taken a spin through the UI, design, and Front-end aspects of this feature. Nice work! @frrrances, I made a few comments here and there about specifics. While they'd be good to address if you agree with them, none are major blockers to this work getting merged if its in a hurry. Also, very solid and well done work overall with the UI and styling. Let me know if I can help with anything else in getting this fella to "Mergetown". 👍 |
These changes implement STUD-813. The commit consists of the following logical changes: - a REST API has been implemented for a course's assets - the page itself now fetches the assets client-side - the Backbone.Paginator library is used to support pagination - the AssetCollection has been refactored to extend Backbone.Paginator.requestPager so that it can be paged - an abstract PagingView class has been added to generalize the communication with a paging REST API - the AssetsView has been reimplemented to extend PagingView - two new child views have been added: - PagingHeader: the paging controls above the list of assets - PagingFooter: the paging controls below the assets
Add pagination to Studio's Files and Uploads page. These changes are for STUD-813.
These changes represent the initial implementation of STUD-813 which adds pagination to the Files and Uploads page. @cahrens and @singingwolfboy, please pre-review this code since this is my first major change, and I want to be sure that I'm following best practices.
Note that I will be adding tests in my next commit, so this pull request will not be merged as is.