summaryrefslogtreecommitdiffstats
path: root/core/js/sharedialogshareelistview.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-01-22 17:30:18 +0100
committerVincent Petry <pvince81@owncloud.com>2016-01-28 15:25:34 +0100
commitb063ddb05b71988d92fe140ca003ad58301cfcc8 (patch)
treefebf5d75ec2f5c4d4759d0ab2ad12523ea66a0a6 /core/js/sharedialogshareelistview.js
parent476720ada9f0997bdef7407f8ef15c2c50866011 (diff)
downloadnextcloud-server-b063ddb05b71988d92fe140ca003ad58301cfcc8.tar.gz
nextcloud-server-b063ddb05b71988d92fe140ca003ad58301cfcc8.zip
Share dialog use OCS API
Diffstat (limited to 'core/js/sharedialogshareelistview.js')
-rw-r--r--core/js/sharedialogshareelistview.js60
1 files changed, 17 insertions, 43 deletions
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js
index 5728fbfd210..e26421dcaed 100644
--- a/core/js/sharedialogshareelistview.js
+++ b/core/js/sharedialogshareelistview.js
@@ -16,11 +16,7 @@
var TEMPLATE =
'<ul id="shareWithList" class="shareWithList">' +
'{{#each sharees}}' +
- ' {{#if isCollection}}' +
- ' <li data-collection="{{collectionID}}">{{text}}</li>' +
- ' {{/if}}' +
- ' {{#unless isCollection}}' +
- ' <li data-share-type="{{shareType}}" data-share-with="{{shareWith}}" title="{{shareWith}}">' +
+ ' <li data-share-id="{{shareId}}" data-share-type="{{shareType}}" data-share-with="{{shareWith}}" title="{{shareWith}}">' +
' <a href="#" class="unshare"><span class="icon-loading-small hidden"></span><img class="svg" alt="{{unshareLabel}}" title="{{unshareLabel}}" src="{{unshareImage}}" /></a>' +
' {{#if avatarEnabled}}' +
' <div class="avatar {{#if modSeed}}imageplaceholderseed{{/if}}" data-username="{{shareWith}}" {{#if modSeed}}data-seed="{{shareWith}} {{shareType}}"{{/if}}></div>' +
@@ -56,7 +52,6 @@
' </div>' +
' {{/unless}}' +
' </li>' +
- ' {{/unless}}' +
'{{/each}}' +
'</ul>'
;
@@ -81,12 +76,6 @@
/** @type {Function} **/
_template: undefined,
- /** @type {boolean} **/
- showLink: true,
-
- /** @type {object} **/
- _collections: {},
-
events: {
'click .unshare': 'onUnshare',
'click .permissions': 'onPermissionChange',
@@ -107,23 +96,6 @@
});
},
- processCollectionShare: function(shareIndex) {
- var type = this.model.getCollectionType(shareIndex);
- var id = this.model.getCollectionPath(shareIndex);
- if(type !== 'file' && type !== 'folder') {
- id = this.model.getCollectionSource(shareIndex);
- }
- var displayName = this.model.getShareWithDisplayName(shareIndex);
- if(!_.isUndefined(this._collections[id])) {
- this._collections[id].text = this._collections[id].text + ", " + displayName;
- } else {
- this._collections[id] = {};
- this._collections[id].text = t('core', 'Shared in {item} with {user}', {'item': id, user: displayName});
- this._collections[id].id = id;
- this._collections[id].isCollection = true;
- }
- },
-
/**
*
* @param {OC.Share.Types.ShareInfo} shareInfo
@@ -156,6 +128,7 @@
shareWith: shareWith,
shareWithDisplayName: shareWithDisplayName,
shareType: shareType,
+ shareId: this.model.get('shares')[shareIndex].id,
modSeed: shareType !== OC.Share.SHARE_TYPE_USER,
isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE
});
@@ -187,8 +160,6 @@
deletePermission: OC.PERMISSION_DELETE
};
- this._collections = {};
-
if(!this.model.hasUserShares()) {
return [];
}
@@ -196,15 +167,10 @@
var shares = this.model.get('shares');
var list = [];
for(var index = 0; index < shares.length; index++) {
- if(this.model.isCollection(index)) {
- this.processCollectionShare(index);
- } else {
- // first empty {} is necessary, otherwise we get in trouble
- // with references
- 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);
return list;
},
@@ -244,6 +210,7 @@
},
onUnshare: function(event) {
+ var self = this;
var $element = $(event.target);
if (!$element.is('a')) {
$element = $element.closest('a');
@@ -257,17 +224,24 @@
$loading.removeClass('hidden');
var $li = $element.closest('li');
- var shareType = $li.data('share-type');
- var shareWith = $li.attr('data-share-with');
- this.model.removeShare(shareType, shareWith);
+ var shareId = $li.data('share-id');
+ self.model.removeShare(shareId)
+ .done(function() {
+ $li.remove();
+ })
+ .fail(function() {
+ $loading.addClass('hidden');
+ OC.Notification.showTemporary(t('core', 'Could not unshare'));
+ });
return false;
},
onPermissionChange: function(event) {
var $element = $(event.target);
var $li = $element.closest('li');
+ var shareId = $li.data('share-id');
var shareType = $li.data('share-type');
var shareWith = $li.attr('data-share-with');
@@ -289,7 +263,7 @@
permissions |= $(checkbox).data('permissions');
});
- this.model.setPermissions(shareType, shareWith, permissions);
+ this.model.updateShare(shareId, {permissions: permissions});
},
onCrudsToggle: function(event) {