diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-11-02 14:17:49 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-11-22 16:05:50 +0100 |
commit | dc8ce87a26aaeeec655530e2960561498e61c94a (patch) | |
tree | 1672ef688aae9514841289c02c95d1a784126f0e /apps/files/js | |
parent | f20232d4bd3e78c4ea980aa03849c3f9bcf5b893 (diff) | |
download | nextcloud-server-dc8ce87a26aaeeec655530e2960561498e61c94a.tar.gz nextcloud-server-dc8ce87a26aaeeec655530e2960561498e61c94a.zip |
Query tags/favorite through Webdav in file list
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/filelist.js | 32 | ||||
-rw-r--r-- | apps/files/js/tagsplugin.js | 32 |
2 files changed, 60 insertions, 4 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 2c97816df00..83c7e147d46 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1377,6 +1377,13 @@ }, /** + * Returns list of webdav properties to request + */ + _getWebdavProperties: function() { + return this.filesClient.getPropfindProperties(); + }, + + /** * Reloads the file list using ajax call * * @return ajax call object @@ -1390,7 +1397,12 @@ this._currentFileModel = null; this.$el.find('.select-all').prop('checked', false); this.showMask(); - this._reloadCall = this.filesClient.getFolderContents(this.getCurrentDirectory(), {includeParent: true}); + this._reloadCall = this.filesClient.getFolderContents( + this.getCurrentDirectory(), { + includeParent: true, + properties: this._getWebdavProperties() + } + ); if (this._detailsView) { // close sidebar this._updateDetailsView(null); @@ -1939,7 +1951,11 @@ ) .done(function() { // TODO: error handling / conflicts - self.filesClient.getFileInfo(targetPath) + self.filesClient.getFileInfo( + targetPath, { + properties: self._getWebdavProperties() + } + ) .then(function(status, data) { self.add(data, {animate: true, scrollTo: true}); deferred.resolve(status, data); @@ -1989,7 +2005,11 @@ this.filesClient.createDirectory(targetPath) .done(function(createStatus) { - self.filesClient.getFileInfo(targetPath) + self.filesClient.getFileInfo( + targetPath, { + properties: self._getWebdavProperties() + } + ) .done(function(status, data) { self.add(data, {animate: true, scrollTo: true}); deferred.resolve(status, data); @@ -2002,7 +2022,11 @@ .fail(function(createStatus) { // method not allowed, folder might exist already if (createStatus === 405) { - self.filesClient.getFileInfo(targetPath) + self.filesClient.getFileInfo( + targetPath, { + properties: self._getWebdavProperties() + } + ) .done(function(status, data) { // add it to the list, for completeness self.add(data, {animate: true, scrollTo: true}); diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 23945d52603..81b22e34cc2 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -161,6 +161,38 @@ fileInfo.tags = tags; return fileInfo; }; + + var NS_OC = 'http://owncloud.org/ns'; + + var oldGetWebdavProperties = fileList._getWebdavProperties; + fileList._getWebdavProperties = function() { + var props = oldGetWebdavProperties.apply(this, arguments); + props.push('{' + NS_OC + '}tags'); + props.push('{' + NS_OC + '}favorite'); + return props; + }; + + fileList.filesClient.addFileInfoParser(function(response) { + var data = {}; + var props = response.propStat[0].properties; + var tags = props['{' + NS_OC + '}tags']; + var favorite = props['{' + NS_OC + '}favorite']; + if (tags && tags.length) { + tags = _.chain(tags).filter(function(xmlvalue) { + return (xmlvalue.namespaceURI === NS_OC && xmlvalue.nodeName.split(':')[1] === 'tag'); + }).map(function(xmlvalue) { + return xmlvalue.textContent || xmlvalue.text; + }).value(); + } + if (tags) { + data.tags = tags; + } + if (favorite && parseInt(favorite, 10) !== 0) { + data.tags = data.tags || []; + data.tags.push(OC.TAG_FAVORITE); + } + return data; + }); }, attach: function(fileList) { |