In AppAddView.post() we already distinguish between Ajax POSTs and form POSTs. If it's an AJAX request, it gets the apps to be added from the request body and adds them to the repo. If not, it just returns 404 because this is not used.
window.onscroll=function(ev){if ((window.innerHeight+window.pageYOffset)>=document.body.offsetHeight){// at the end of the page}}
In this function I make an Ajax request saying I need the next 15 apps. Django returns the apps JSON encoded. I use the data to imitate the behavior of Django's for loop in the template. This adds the apps to the page while scrolling. When the user comes close to the end of the page again, the described action chain starts again. If everything goes smooth, the user should not reach the end of the page until there are no more in the remote repo(s).
If JavaScript is enabled, the pagination element is hidden completely. I'm unsure at the moment whether I should add an element to the end of the pages saying there are now more apps or if I should leave that out.
The JavaScript request looks like the following:
request.open("POST",'')request.setRequestHeader('RM-ACTION','LOAD_MORE')request.send({appsStart:15})// First loadrequest.send({appsStart:55})// Fourth load
The Django post() looks something like this (semi-pseudo):
defpost(self,request,*args,**kwargs):ifrequest.is_ajax():ifrequest.header.rm_actionis'ADD':# Current codeifrequest.header.rm_actionis'LOAD_MORE':qs=self.get_queryset()qs=qs[request.appsStart:request.appsStart+15]
Do you have more details on how you want to add the apps to the page? Do you want to manually construct the HTML? Are there any libraries we could use for that task, maybe even re-use our app widget template?
When loading more, why not use the existing pagination methods to get the other apps instead of fiddling yourself with the query set and app numbers?
Please don't implement this for the remote repo app adding right away. Let's start with the repo index, because that is easier.
Do you have more details on how you want to add the apps to the page? Do you want to manually construct the HTML? Are there any libraries we could use for that task, maybe even re-use our app widget template?
I don't think we need a library here as it's a simple DOM manipulation:
Just to be clear: Loading on scroll like discussed in #70 (closed) can be part of this ticket as well. If that's too much for one MR, please just open a new ticket for it.