summaryrefslogtreecommitdiffstats
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
parent858a2a4e6c42f8cc68212439930c16029a6bba36 (diff)
downloadnextcloud-server-258a2e2696c0c2a1e784fe27cbd8ca9a4dc8b8ca.tar.gz
nextcloud-server-258a2e2696c0c2a1e784fe27cbd8ca9a4dc8b8ca.zip
now you even can share
-rw-r--r--apps/files_sharing/appinfo/app.php1
-rw-r--r--apps/files_sharing/css/sharetabview.css1
-rw-r--r--core/js/shareconfigmodel.js8
-rw-r--r--core/js/sharedialogshareelistview.js8
-rw-r--r--core/js/sharedialogview.js46
-rw-r--r--core/js/shareitemmodel.js41
6 files changed, 94 insertions, 11 deletions
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 2bb872eaad6..8d919d1466f 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -61,6 +61,7 @@ $eventDispatcher->addListener(
\OCP\Util::addScript('files_sharing', 'share');
\OCP\Util::addScript('files_sharing', 'sharetabview');
\OCP\Util::addScript('files_sharing', 'external');
+ \OCP\Util::addStyle('files_sharing', 'sharetabview');
}
);
diff --git a/apps/files_sharing/css/sharetabview.css b/apps/files_sharing/css/sharetabview.css
index 8b9af852531..96a75717c53 100644
--- a/apps/files_sharing/css/sharetabview.css
+++ b/apps/files_sharing/css/sharetabview.css
@@ -5,7 +5,6 @@
.shareTabView .oneline { white-space: nowrap; }
.shareTabView .shareWithLoading {
- display: inline-block !important;
padding-left: 10px;
position: relative;
right: 30px;
diff --git a/core/js/shareconfigmodel.js b/core/js/shareconfigmodel.js
index 472fdcc75d7..98280e01eb6 100644
--- a/core/js/shareconfigmodel.js
+++ b/core/js/shareconfigmodel.js
@@ -20,6 +20,7 @@
enforcePasswordForPublicLink: oc_appconfig.core.enforcePasswordForPublicLink,
isDefaultExpireDateEnforced: oc_appconfig.core.defaultExpireDateEnforced === true,
defaultExpireDate: oc_appconfig.core.defaultExpireDate,
+ isResharingAllowed: oc_appconfig.core.resharingAllowed
},
/**
@@ -54,13 +55,6 @@
/**
* @returns {boolean}
*/
- isResharingAllowed: function() {
- return oc_appconfig.core.resharingAllowed
- },
-
- /**
- * @returns {boolean}
- */
isShareWithLinkAllowed: function() {
return $('#allowShareWithLink').val() === 'yes';
},
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js
index 6a356b8144c..4ac669ee2b9 100644
--- a/core/js/sharedialogshareelistview.js
+++ b/core/js/sharedialogshareelistview.js
@@ -161,7 +161,7 @@
deletePermissionLabel: t('core', 'delete'),
crudsLabel: t('core', 'access control'),
triangleSImage: OC.imagePath('core', 'actions/triangle-s'),
- isResharingAllowed: this.configModel.isResharingAllowed(),
+ isResharingAllowed: this.configModel.get('isResharingAllowed'),
sharePermissionPossible: this.model.sharePermissionPossible(),
editPermissionPossible: this.model.editPermissionPossible(),
createPermissionPossible: this.model.createPermissionPossible(),
@@ -185,10 +185,12 @@
if(this.model.isCollection(index)) {
this.processCollectionShare(index);
} else {
- list.push(_.extend(universal, this.getShareeObject(index)))
+ // first empty {} is necessary, otherwise we get in trouble
+ // with references
+ list.push(_.extend({}, universal, this.getShareeObject(index)));
}
- list = _.union(_.values(this._collections), list);
}
+ list = _.union(_.values(this._collections), list);
return list;
},
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 12e682a3b82..e3da0384fa4 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -100,6 +100,36 @@
? new OC.Share[className](subViewOptions)
: options[name];
}
+
+ _.bindAll(this, 'autocompleteHandler');
+ },
+
+ autocompleteHandler: function (search, response) {
+ var view = this;
+ var $loading = this.$el.find('.shareWithLoading');
+ $loading.removeClass('hidden');
+ $loading.addClass('inlineblock');
+ $.get(OC.filePath('core', 'ajax', 'share.php'), {
+ fetch: 'getShareWith',
+ search: search.term.trim(),
+ limit: 200,
+ itemShares: OC.Share.itemShares,
+ itemType: view.model.get('itemType')
+ }, function (result) {
+ $loading.addClass('hidden');
+ $loading.removeClass('inlineblock');
+ if (result.status == 'success' && result.data.length > 0) {
+ $("#shareWith").autocomplete("option", "autoFocus", true);
+ response(result.data);
+ } else {
+ response();
+ }
+ }).fail(function () {
+ $loading.addClass('hidden');
+ $loading.removeClass('inlineblock');
+ OC.Notification.show(t('core', 'An error occured. Please try again'));
+ window.setTimeout(OC.Notification.hide, 5000);
+ });
},
render: function() {
@@ -111,6 +141,22 @@
remoteShareInfo: this._renderRemoteShareInfoPart(),
}));
+ var view = this;
+ this.$el.find('#shareWith').autocomplete({
+ minLength: 2,
+ delay: 750,
+ source: this.autocompleteHandler,
+ select: function(e, s) {
+ var expiration = '';
+ if($('#expirationCheckbox').is(':checked') === true) {
+ expiration = view.$el.find('#expirationDate').val()
+ }
+ view.model.addShare(e, s, {
+ expiration: expiration
+ });
+ }
+ });
+
this.resharerInfoView.$el = this.$el.find('.resharerInfoView');
this.resharerInfoView.render();
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}
*/