Skip to content

Add pagination to Studio's Files and Uploads page - #1912

Merged
andy-armstrong merged 2 commits into
masterfrom
andy/asset-pagination
Jan 6, 2014
Merged

Add pagination to Studio's Files and Uploads page #1912
andy-armstrong merged 2 commits into
masterfrom
andy/asset-pagination

Conversation

@andy-armstrong

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown

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

@cahrens

cahrens commented Dec 11, 2013

Copy link
Copy Markdown

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).

Comment thread cms/static/js/views/paging_header.js Outdated

Copy link
Copy Markdown
Contributor

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.

@cahrens

cahrens commented Dec 11, 2013

Copy link
Copy Markdown

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"].

Comment thread cms/static/js/collections/asset.js Outdated

Copy link
Copy Markdown
Contributor

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.

@cahrens

cahrens commented Dec 11, 2013

Copy link
Copy Markdown

Get rid of this from the URL (form submission). awefjaseofj?page-number=-2#

Copy link
Copy Markdown

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).

@cahrens

cahrens commented Dec 11, 2013

Copy link
Copy Markdown

This general approach looks good.

@andy-armstrong

Copy link
Copy Markdown
Contributor Author

@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!

@andy-armstrong

Copy link
Copy Markdown
Contributor Author

@frrrances I've fixed all the bugs including the performance problem you were seeing (I think). Can you try this again. Two issues remain:

  1. I tried to implement the 'is-disabled' logic but it doesn't seem to disable the links.
  2. The 'no assets' variant of the page doesn't get the same box rendering as the 'no templates' does.

Can you help me look into these two. In the meantime I'm going to get back to testing.

@andy-armstrong

Copy link
Copy Markdown
Contributor Author

@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?

@frrrances

Copy link
Copy Markdown
Contributor

@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.

@frrrances

Copy link
Copy Markdown
Contributor

Performance and everything else looks good to me now. 👍

@andy-armstrong

Copy link
Copy Markdown
Contributor Author

@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

Copy link
Copy Markdown

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.

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.

6 participants