summaryrefslogtreecommitdiffstats
path: root/core/js/files
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-11-18 15:42:35 +0100
committerLukas Reschke <lukas@owncloud.com>2015-11-22 16:05:50 +0100
commit7ec83fc9fbb7428bde4cf0e1071704c941ac1f37 (patch)
tree74350d1469da69c833c0b3bd099b08121010920f /core/js/files
parent358858c9e3f06560b67b69e1d15c141debb2729a (diff)
downloadnextcloud-server-7ec83fc9fbb7428bde4cf0e1071704c941ac1f37.tar.gz
nextcloud-server-7ec83fc9fbb7428bde4cf0e1071704c941ac1f37.zip
Fix OC.FileInfo to copy all properties
This makes it possible to also store custom properties passed through the data object like tags or shareOwner.
Diffstat (limited to 'core/js/files')
-rw-r--r--core/js/files/fileinfo.js42
1 files changed, 17 insertions, 25 deletions
diff --git a/core/js/files/fileinfo.js b/core/js/files/fileinfo.js
index c4a9eeb3d7c..3bf68d88b15 100644
--- a/core/js/files/fileinfo.js
+++ b/core/js/files/fileinfo.js
@@ -19,39 +19,31 @@
* @since 8.2
*/
var FileInfo = function(data) {
- if (!_.isUndefined(data.id)) {
+ var self = this;
+ _.each(data, function(value, key) {
+ if (!_.isFunction(value)) {
+ self[key] = value;
+ }
+ });
+
+ if (!_.isUndefined(this.id)) {
this.id = parseInt(data.id, 10);
}
// TODO: normalize path
this.path = data.path || '';
- this.name = data.name;
-
- this.mtime = data.mtime;
- this.etag = data.etag;
- this.permissions = data.permissions;
- this.size = data.size;
- this.mimetype = data.mimetype || 'application/octet-stream';
- this.mountType = data.mountType;
- this.icon = data.icon;
-
- if (data.type) {
- this.type = data.type;
- } else if (this.mimetype === 'httpd/unix-directory') {
- this.type = 'dir';
- } else {
- this.type = 'file';
- }
- if (data.tags) {
- this.tags = data.tags;
+ if (this.type === 'dir') {
+ this.mimetype = 'httpd/unix-directory';
+ } else {
+ this.mimetype = this.mimetype || 'application/octet-stream';
}
- if (!this.mimetype) {
- if (this.type === 'dir') {
- this.mimetype = 'httpd/unix-directory';
+ if (!this.type) {
+ if (this.mimetype === 'httpd/unix-directory') {
+ this.type = 'dir';
} else {
- this.mimetype = 'application/octet-stream';
+ this.type = 'file';
}
}
};
@@ -104,7 +96,7 @@
* @type String
* @deprecated rely on mimetype instead
*/
- type: 'file',
+ type: null,
/**
* Permissions.