make unshare work

This commit is contained in:
Arthur Schiwon 2015-09-14 01:24:21 +02:00 committed by Vincent Petry
parent 7ae84e0e5c
commit a5b0ea031d
3 changed files with 34 additions and 43 deletions

View file

@ -885,40 +885,6 @@ $(document).ready(function() {
return false;
});
$(document).on('click', '#dropdown .unshare', function() {
var $li = $(this).closest('li');
var itemType = $('#dropdown').data('item-type');
var itemSource = $('#dropdown').data('item-source');
var shareType = $li.data('share-type');
var shareWith = $li.attr('data-share-with');
var $button = $(this);
if (!$button.is('a')) {
$button = $button.closest('a');
}
if ($button.hasClass('icon-loading-small')) {
// deletion in progress
return false;
}
$button.empty().addClass('icon-loading-small');
OC.Share.unshare(itemType, itemSource, shareType, shareWith, function() {
$li.remove();
var index = OC.Share.itemShares[shareType].indexOf(shareWith);
OC.Share.itemShares[shareType].splice(index, 1);
// updated list of shares
OC.Share.currentShares[shareType].splice(index, 1);
$('#dropdown').trigger(new $.Event('sharesChanged', {shares: OC.Share.currentShares}));
OC.Share.updateIcon(itemType, itemSource);
if (typeof OC.Share.statuses[itemSource] === 'undefined') {
$('#expiration').slideUp(OC.menuSpeed);
}
});
return false;
});
$(document).on('change', '#dropdown .permissions', function() {
var li = $(this).closest('li');
if ($(this).attr('name') == 'edit') {

View file

@ -212,6 +212,9 @@
});
}
var view = this;
this.$el.find('.unshare').click(function() { view.onUnshare(this, view); });
return this;
},
@ -224,6 +227,24 @@
this._template = Handlebars.compile(TEMPLATE);
}
return this._template;
},
onUnshare: function(element, view) {
var $element = $(element);
if($element.hasClass('icon-loading-small')) {
// in process
return;
}
$element.empty().addClass('icon-loading-small');
var $li = $element.closest('li');
var shareType = $li.data('share-type');
var shareWith = $li.attr('data-share-with');
view.model.removeShare(shareType, shareWith);
return false;
}
});

View file

@ -121,15 +121,7 @@
},
removeLinkShare: function() {
var model = this;
var itemType = this.get('itemType');
var itemSource = this.get('itemSource');
OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', function() {
model.fetch();
//FIXME: updateIcon belongs to view
OC.Share.updateIcon(itemType, itemSource);
});
this.removeShare(OC.Share.SHARE_TYPE_LINK, '');
},
setPublicUpload: function(allow) {
@ -179,6 +171,18 @@
});
},
removeShare: function(shareType, shareWith) {
var model = this;
var itemType = this.get('itemType');
var itemSource = this.get('itemSource');
OC.Share.unshare(itemType, itemSource, shareType, shareWith, function() {
model.fetch();
//FIXME: updateIcon belongs to view
OC.Share.updateIcon(itemType, itemSource);
});
},
/**
* @returns {boolean}
*/