summaryrefslogtreecommitdiffstats
path: root/apps/comments/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-01-28 14:24:12 +0100
committerVincent Petry <pvince81@owncloud.com>2016-02-02 18:01:15 +0100
commit29386eccf96aec3e6a4c776f43e74c95474697bb (patch)
tree48675aa104747f87a6ebb1d4750cad13e434fde4 /apps/comments/js
parentd1518045ecdf4dd006224256b25b292a92b1202d (diff)
downloadnextcloud-server-29386eccf96aec3e6a4c776f43e74c95474697bb.tar.gz
nextcloud-server-29386eccf96aec3e6a4c776f43e74c95474697bb.zip
Add pagination support for comments GUI
Diffstat (limited to 'apps/comments/js')
-rw-r--r--apps/comments/js/commentcollection.js54
-rw-r--r--apps/comments/js/commentstabview.js7
2 files changed, 45 insertions, 16 deletions
diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js
index 61b5adb7da7..1fda4a4c709 100644
--- a/apps/comments/js/commentcollection.js
+++ b/apps/comments/js/commentcollection.js
@@ -10,9 +10,7 @@
(function(OC, OCA) {
- function filterFunction(model, term) {
- return model.get('name').substr(0, term.length) === term;
- }
+ var NS_OWNCLOUD = 'http://owncloud.org/ns';
/**
* @class OCA.Comments.CommentsCollection
@@ -32,7 +30,7 @@
_objectId: null,
_endReached: false,
- _currentIndex: 0,
+ _limit : 5,
initialize: function(models, options) {
options = options || {};
@@ -58,22 +56,54 @@
return !this._endReached;
},
+ reset: function() {
+ this._endReached = false;
+ return OC.Backbone.Collection.prototype.reset.apply(this, arguments);
+ },
+
/**
* Fetch the next set of results
*/
- fetchNext: function() {
+ fetchNext: function(options) {
+ var self = this;
if (!this.hasMoreResults()) {
return null;
}
- if (this._currentIndex === 0) {
- return this.fetch();
+
+ var body = '<?xml version="1.0" encoding="utf-8" ?>\n' +
+ '<D:report xmlns:D="DAV:" xmlns:oc="http://owncloud.org/ns">\n' +
+ ' <oc:limit>' + this._limit + '</oc:limit>\n';
+
+ if (this.length > 0) {
+ body += ' <oc:datetime>' + this.first().get('creationDateTime') + '</oc:datetime>\n';
}
- return this.fetch({remove: false});
- },
- reset: function() {
- this._currentIndex = 0;
- OC.Backbone.Collection.prototype.reset.apply(this, arguments);
+ body += '</D:report>\n';
+
+ var oldLength = this.length;
+
+ options = options || {};
+ var success = options.success;
+ options = _.extend({
+ remove: false,
+ data: body,
+ davProperties: CommentsCollection.prototype.model.prototype.davProperties,
+ success: function(resp) {
+ if (resp.length === oldLength) {
+ // no new entries, end reached
+ self._endReached = true;
+ }
+ if (!self.set(resp, options)) {
+ return false;
+ }
+ if (success) {
+ success.apply(null, arguments);
+ }
+ self.trigger('sync', 'REPORT', self, options);
+ }
+ }, options);
+
+ return this.sync('REPORT', this, options);
}
});
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js
index b1a3f854fe1..6e511732803 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -19,10 +19,8 @@
' </ul>' +
'</div>' +
'<div class="empty hidden">{{emptyResultLabel}}</div>' +
- /*
'<input type="button" class="showMore hidden" value="{{moreLabel}}"' +
' name="show-more" id="show-more" />' +
- */
'<div class="loading hidden" style="height: 50px"></div>';
var COMMENT_TEMPLATE =
@@ -44,7 +42,8 @@
className: 'tab commentsTabView',
events: {
- 'submit .newCommentForm': '_onSubmitComment'
+ 'submit .newCommentForm': '_onSubmitComment',
+ 'click .showMore': '_onClickShowMore'
},
initialize: function() {
@@ -144,7 +143,7 @@
this.collection.fetchNext();
},
- _onClickShowMoreVersions: function(ev) {
+ _onClickShowMore: function(ev) {
ev.preventDefault();
this.nextPage();
},