Fix shares list events
Some events need preventing default like unshare, but setting permissions doesn't.
This commit is contained in:
parent
e90065881d
commit
06b11dd602
|
@ -81,6 +81,12 @@
|
|||
/** @type {object} **/
|
||||
_collections: {},
|
||||
|
||||
events: {
|
||||
'click .unshare': 'onUnshare',
|
||||
'click .permissions': 'onPermissionChange',
|
||||
'click .showCruds': 'onCrudsToggle'
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
if(!_.isUndefined(options.configModel)) {
|
||||
this.configModel = options.configModel;
|
||||
|
@ -212,10 +218,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
var view = this;
|
||||
this.$el.find('.unshare').click(function() { view.onUnshare(this, view); });
|
||||
this.$el.find('.permissions').click(function() { view.onPermissionChange(this, view); });
|
||||
this.$el.find('.showCruds').click(this.onCrudsToggle);
|
||||
this.delegateEvents();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -231,8 +234,8 @@
|
|||
return this._template;
|
||||
},
|
||||
|
||||
onUnshare: function(element, view) {
|
||||
var $element = $(element);
|
||||
onUnshare: function(event) {
|
||||
var $element = $(event.target);
|
||||
|
||||
if($element.hasClass('icon-loading-small')) {
|
||||
// in process
|
||||
|
@ -244,26 +247,27 @@
|
|||
var shareType = $li.data('share-type');
|
||||
var shareWith = $li.attr('data-share-with');
|
||||
|
||||
view.model.removeShare(shareType, shareWith);
|
||||
this.model.removeShare(shareType, shareWith);
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
onPermissionChange: function(element, view) {
|
||||
var $element = $(element);
|
||||
onPermissionChange: function(event) {
|
||||
var $element = $(event.target);
|
||||
var $li = $element.closest('li');
|
||||
var shareType = $li.data('share-type');
|
||||
var shareWith = $li.attr('data-share-with');
|
||||
|
||||
// adjust checkbox states
|
||||
var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]');
|
||||
var checked;
|
||||
if ($element.attr('name') === 'edit') {
|
||||
var checked = $element.is(':checked');
|
||||
checked = $element.is(':checked');
|
||||
// Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck
|
||||
$($checkboxes).attr('checked', checked);
|
||||
} else {
|
||||
var numberChecked = $checkboxes.filter(':checked').length;
|
||||
var checked = numberChecked > 0;
|
||||
checked = numberChecked > 0;
|
||||
$('input[name="edit"]', $li).attr('checked', checked);
|
||||
}
|
||||
|
||||
|
@ -272,13 +276,11 @@
|
|||
permissions |= $(checkbox).data('permissions');
|
||||
});
|
||||
|
||||
view.model.setPermissions(shareType, shareWith, permissions);
|
||||
|
||||
return false;
|
||||
this.model.setPermissions(shareType, shareWith, permissions);
|
||||
},
|
||||
|
||||
onCrudsToggle: function() {
|
||||
$(this).siblings('.cruds').toggleClass('hidden');
|
||||
onCrudsToggle: function(event) {
|
||||
this.$el.find('.cruds').toggleClass('hidden');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
: options[name];
|
||||
}
|
||||
|
||||
_.bindAll(this, 'autocompleteHandler');
|
||||
_.bindAll(this, 'autocompleteHandler', '_onSelectRecipient');
|
||||
},
|
||||
|
||||
autocompleteHandler: function (search, response) {
|
||||
|
@ -151,6 +151,11 @@
|
|||
.appendTo(ul);
|
||||
},
|
||||
|
||||
_onSelectRecipient: function(e, s) {
|
||||
e.preventDefault();
|
||||
this.model.addShare(s.item.value);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var baseTemplate = this._getTemplate('base', TEMPLATE_BASE);
|
||||
|
||||
|
@ -165,15 +170,7 @@
|
|||
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
|
||||
});
|
||||
}
|
||||
select: this._onSelectRecipient
|
||||
}).data('ui-autocomplete')._renderItem = this.autocompleteRenderItem;
|
||||
|
||||
this.resharerInfoView.$el = this.$el.find('.resharerInfoView');
|
||||
|
|
|
@ -201,11 +201,9 @@
|
|||
this.get('linkShare').password = password;
|
||||
},
|
||||
|
||||
addShare: function(event, selected, options) {
|
||||
event.preventDefault();
|
||||
|
||||
var shareType = selected.item.value.shareType;
|
||||
var shareWith = selected.item.value.shareWith;
|
||||
addShare: function(attributes, options) {
|
||||
var shareType = attributes.shareType;
|
||||
var shareWith = attributes.shareWith;
|
||||
var fileName = this.fileInfoModel.get('name');
|
||||
options = options || {};
|
||||
|
||||
|
@ -241,6 +239,7 @@
|
|||
var itemType = this.get('itemType');
|
||||
var itemSource = this.get('itemSource');
|
||||
|
||||
// TODO: in the future, only set the permissions on the model but don't save directly
|
||||
OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue