diff --git a/apps/comments/js/commentcollection.js b/apps/comments/js/commentcollection.js
index 61b5adb7da..1fda4a4c70 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();
- }
- return this.fetch({remove: false});
- },
- reset: function() {
- this._currentIndex = 0;
- OC.Backbone.Collection.prototype.reset.apply(this, arguments);
+ var body = '\n' +
+ '\n' +
+ ' ' + this._limit + '\n';
+
+ if (this.length > 0) {
+ body += ' ' + this.first().get('creationDateTime') + '\n';
+ }
+
+ body += '\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 b1a3f854fe..6e51173280 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -19,10 +19,8 @@
' ' +
'' +
'
{{emptyResultLabel}}
' +
- /*
'' +
- */
'';
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();
},
diff --git a/core/js/oc-backbone-webdav.js b/core/js/oc-backbone-webdav.js
index 7c32116f01..d231a5b1ba 100644
--- a/core/js/oc-backbone-webdav.js
+++ b/core/js/oc-backbone-webdav.js
@@ -76,6 +76,11 @@
* @param {Object} davProperties properties mapping
*/
function parsePropFindResult(result, davProperties) {
+ if (_.isArray(result)) {
+ return _.map(result, function(subResult) {
+ return parsePropFindResult(subResult, davProperties);
+ });
+ }
var props = {
href: result.href
};
@@ -151,15 +156,10 @@
if (isSuccessStatus(response.status)) {
if (_.isFunction(options.success)) {
var propsMapping = _.invert(options.davProperties);
- var results;
+ var results = parsePropFindResult(response.body, propsMapping);
if (options.depth > 0) {
- results = _.map(response.body, function(data) {
- return parsePropFindResult(data, propsMapping);
- });
// discard root entry
results.shift();
- } else {
- results = parsePropFindResult(response.body, propsMapping);
}
options.success(results);
@@ -217,7 +217,13 @@
options.success(responseJson);
return;
}
- options.success(result.body);
+ // if multi-status, parse
+ if (result.status === 207) {
+ var propsMapping = _.invert(options.davProperties);
+ options.success(parsePropFindResult(result.body, propsMapping));
+ } else {
+ options.success(result.body);
+ }
}
});
}
@@ -249,7 +255,7 @@
* DAV transport
*/
function davSync(method, model, options) {
- var params = {type: methodMap[method]};
+ var params = {type: methodMap[method] || method};
var isCollection = (model instanceof Backbone.Collection);
if (method === 'update' && (model.usePUT || (model.collection && model.collection.usePUT))) {
diff --git a/core/vendor/davclient.js/lib/client.js b/core/vendor/davclient.js/lib/client.js
index 1a73c7db02..dbdfd3823e 100644
--- a/core/vendor/davclient.js/lib/client.js
+++ b/core/vendor/davclient.js/lib/client.js
@@ -1,17 +1,17 @@
if (typeof dav == 'undefined') { dav = {}; };
dav._XML_CHAR_MAP = {
- '<': '<',
- '>': '>',
- '&': '&',
- '"': '"',
- "'": '''
+ '<': '<',
+ '>': '>',
+ '&': '&',
+ '"': '"',
+ "'": '''
};
dav._escapeXml = function(s) {
- return s.replace(/[<>&"']/g, function (ch) {
- return dav._XML_CHAR_MAP[ch];
- });
+ return s.replace(/[<>&"']/g, function (ch) {
+ return dav._XML_CHAR_MAP[ch];
+ });
};
dav.Client = function(options) {
@@ -79,17 +79,16 @@ dav.Client.prototype = {
return this.request('PROPFIND', url, headers, body).then(
function(result) {
- var resultBody = this.parseMultiStatus(result.body);
if (depth===0) {
return {
status: result.status,
- body: resultBody[0],
+ body: result.body[0],
xhr: result.xhr
};
} else {
return {
status: result.status,
- body: resultBody,
+ body: result.body,
xhr: result.xhr
};
}
@@ -161,6 +160,7 @@ dav.Client.prototype = {
*/
request : function(method, url, headers, body) {
+ var self = this;
var xhr = this.xhrProvider();
if (this.userName) {
@@ -182,8 +182,13 @@ dav.Client.prototype = {
return;
}
+ var resultBody = xhr.response;
+ if (xhr.status === 207) {
+ resultBody = self.parseMultiStatus(xhr.response);
+ }
+
fulfill({
- body: xhr.response,
+ body: resultBody,
status: xhr.status,
xhr: xhr
});