summaryrefslogtreecommitdiffstats
path: root/apps/files/js/fileinfomodel.js
diff options
context:
space:
mode:
authorMichael Jobst <mjobst+github@tecratech.de>2016-11-21 15:03:45 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-12-23 16:56:55 +0100
commit969c19b2e926331e2686208507c2643107caf5a1 (patch)
treec0c03ac7bbcdc7760e97e35ddacef8919ed527e6 /apps/files/js/fileinfomodel.js
parent56c016946d0695a62e418839cf19786a223b4ae7 (diff)
downloadnextcloud-server-969c19b2e926331e2686208507c2643107caf5a1.tar.gz
nextcloud-server-969c19b2e926331e2686208507c2643107caf5a1.zip
Fixed size issues on main detail view and disappearing of share recipients (#26603)
* fixed size issues on main detail view and disappearing of share recipients * Changes due to code comments * Moved reloadProperties() to FileInfoModel * Solved Scrutinizer issues * Bugfix: undefined value used on error * check if options are set for FileInfoModel.initialize() Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/files/js/fileinfomodel.js')
-rw-r--r--apps/files/js/fileinfomodel.js47
1 files changed, 45 insertions, 2 deletions
diff --git a/apps/files/js/fileinfomodel.js b/apps/files/js/fileinfomodel.js
index de1b143a160..9d1eac31940 100644
--- a/apps/files/js/fileinfomodel.js
+++ b/apps/files/js/fileinfomodel.js
@@ -36,10 +36,18 @@
path: ''
},
- initialize: function(data) {
+ _filesClient: null,
+
+ initialize: function(data, options) {
if (!_.isUndefined(data.id)) {
data.id = parseInt(data.id, 10);
}
+
+ if( options ){
+ if (options.filesClient) {
+ this._filesClient = options.filesClient;
+ }
+ }
},
/**
@@ -73,6 +81,42 @@
*/
getFullPath: function() {
return OC.joinPaths(this.get('path'), this.get('name'));
+ },
+
+ /**
+ * Reloads missing properties from server and set them in the model.
+ * @param properties array of properties to be reloaded
+ * @return ajax call object
+ */
+ reloadProperties: function(properties) {
+ if( !this._filesClient ){
+ return;
+ }
+
+ var self = this;
+ var deferred = $.Deferred();
+
+ var targetPath = OC.joinPaths(this.get('path') + '/', this.get('name'));
+
+ this._filesClient.getFileInfo(targetPath, {
+ properties: properties
+ })
+ .then(function(status, data) {
+ // the following lines should be extracted to a mapper
+
+ if( properties.indexOf(OC.Files.Client.PROPERTY_GETCONTENTLENGTH) !== -1
+ || properties.indexOf(OC.Files.Client.PROPERTY_SIZE) !== -1 ) {
+ self.set('size', data.size);
+ }
+
+ deferred.resolve(status, data);
+ })
+ .fail(function(status) {
+ OC.Notification.showTemporary(t('files', 'Could not load info for file "{file}"', {file: self.get('name')}));
+ deferred.reject(status);
+ });
+
+ return deferred.promise();
}
});
@@ -82,4 +126,3 @@
OCA.Files.FileInfoModel = FileInfoModel;
})(OC, OCA);
-