From 361f008c705009eee8d7435f46095760ac706456 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 12 Sep 2016 17:09:46 +0200 Subject: Make it possible to filter by tags with REPORT method Enhanced the REPORT method on the Webdav endpoint and added a "oc:favorite" filter rule. When set, it will return a flat list of results filtered with only favorite files. The web UI was also adjusted to use this REPORT method instead of the private API endpoint. Signed-off-by: Roeland Jago Douma --- core/js/files/client.js | 6 +++++- core/js/tests/specs/files/clientSpec.js | 4 +--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'core/js') diff --git a/core/js/files/client.js b/core/js/files/client.js index a195258afbb..572f7879e17 100644 --- a/core/js/files/client.js +++ b/core/js/files/client.js @@ -437,6 +437,7 @@ * * @param {Object} filter filter criteria * @param {Object} [filter.systemTagIds] list of system tag ids to filter by + * @param {bool} [filter.favorite] set it to filter by favorites * @param {Object} [options] options * @param {Array} [options.properties] list of Webdav properties to retrieve * @@ -454,7 +455,7 @@ properties = options.properties; } - if (!filter || !filter.systemTagIds || !filter.systemTagIds.length) { + if (!filter || (!filter.systemTagIds && _.isUndefined(filter.favorite))) { throw 'Missing filter argument'; } @@ -480,6 +481,9 @@ _.each(filter.systemTagIds, function(systemTagIds) { body += ' ' + escapeHTML(systemTagIds) + '\n'; }); + if (filter.favorite) { + body += ' ' + (filter.favorite ? '1': '0') + '\n'; + } body += ' \n'; // end of root diff --git a/core/js/tests/specs/files/clientSpec.js b/core/js/tests/specs/files/clientSpec.js index 7673ec6e0fc..f75998029a9 100644 --- a/core/js/tests/specs/files/clientSpec.js +++ b/core/js/tests/specs/files/clientSpec.js @@ -461,9 +461,7 @@ describe('OC.Files.Client tests', function() { it('throws exception if arguments are missing', function() { var thrown = null; try { - client.getFilteredFiles({ - systemTagIds: [] - }); + client.getFilteredFiles({}); } catch (e) { thrown = true; } -- cgit v1.2.3