summaryrefslogtreecommitdiffstats
path: root/core/js/shareitemmodel.js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-09-05 02:02:55 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-16 07:23:27 +0200
commit258a2e2696c0c2a1e784fe27cbd8ca9a4dc8b8ca (patch)
tree158797333115ab4ed60ea876ade7a3f06b69a8e2 /core/js/shareitemmodel.js
parent858a2a4e6c42f8cc68212439930c16029a6bba36 (diff)
downloadnextcloud-server-258a2e2696c0c2a1e784fe27cbd8ca9a4dc8b8ca.tar.gz
nextcloud-server-258a2e2696c0c2a1e784fe27cbd8ca9a4dc8b8ca.zip
now you even can share
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r--core/js/shareitemmodel.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 24aa5fe344d..81e905b082e 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -79,6 +79,8 @@
/** @type {OC.Files.FileInfo} **/
this.fileInfoModel = options.fileInfoModel;
}
+
+ _.bindAll(this, 'addShare');
},
defaults: {
@@ -87,6 +89,45 @@
linkShare: {}
},
+ addShare: function(event, selected, options) {
+ event.preventDefault();
+
+ //console.warn(selected);
+ //return false;
+
+ var shareType = selected.item.value.shareType;
+ var shareWith = selected.item.value.shareWith;
+ var fileName = this.fileInfoModel.get('name');
+ options = options || {};
+
+ // Default permissions are Edit (CRUD) and Share
+ // Check if these permissions are possible
+ var permissions = OC.PERMISSION_READ;
+ if (shareType === OC.Share.SHARE_TYPE_REMOTE) {
+ permissions = OC.PERMISSION_CREATE | OC.PERMISSION_UPDATE | OC.PERMISSION_READ;
+ } else {
+ if (this.updatePermissionPossible()) {
+ permissions = permissions | OC.PERMISSION_UPDATE;
+ }
+ if (this.createPermissionPossible()) {
+ permissions = permissions | OC.PERMISSION_CREATE;
+ }
+ if (this.deletePermissionPossible()) {
+ permissions = permissions | OC.PERMISSION_DELETE;
+ }
+ if (this.configModel.get('isResharingAllowed') && (this.sharePermissionPossible())) {
+ permissions = permissions | OC.PERMISSION_SHARE;
+ }
+ }
+
+ var model = this;
+ OC.Share.share(this.get('itemType'), this.get('itemSource'), shareType, shareWith, permissions, fileName, options.expiration, function() {
+ model.fetch()
+ //FIXME: updateIcon belongs to view
+ OC.Share.updateIcon(itemType, itemSource);
+ });
+ },
+
/**
* @returns {boolean}
*/