diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-01-28 14:24:12 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-02-02 18:01:15 +0100 |
commit | 29386eccf96aec3e6a4c776f43e74c95474697bb (patch) | |
tree | 48675aa104747f87a6ebb1d4750cad13e434fde4 /core | |
parent | d1518045ecdf4dd006224256b25b292a92b1202d (diff) | |
download | nextcloud-server-29386eccf96aec3e6a4c776f43e74c95474697bb.tar.gz nextcloud-server-29386eccf96aec3e6a4c776f43e74c95474697bb.zip |
Add pagination support for comments GUI
Diffstat (limited to 'core')
-rw-r--r-- | core/js/oc-backbone-webdav.js | 22 | ||||
-rw-r--r-- | core/vendor/davclient.js/lib/client.js | 29 |
2 files changed, 31 insertions, 20 deletions
diff --git a/core/js/oc-backbone-webdav.js b/core/js/oc-backbone-webdav.js index 7c32116f011..d231a5b1ba0 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 1a73c7db020..dbdfd3823e4 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 }); |