summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-09-14 17:47:47 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-16 07:23:28 +0200
commit06b11dd602b5073d383d14e10072708907513cb3 (patch)
treec210dfa045cbe5ea1dffe736ef98b457eb6a7434 /core/js
parente90065881d47a64b6c376208ece208932711c765 (diff)
downloadnextcloud-server-06b11dd602b5073d383d14e10072708907513cb3.tar.gz
nextcloud-server-06b11dd602b5073d383d14e10072708907513cb3.zip
Fix shares list events
Some events need preventing default like unshare, but setting permissions doesn't.
Diffstat (limited to 'core/js')
-rw-r--r--core/js/sharedialogshareelistview.js34
-rw-r--r--core/js/sharedialogview.js17
-rw-r--r--core/js/shareitemmodel.js9
3 files changed, 29 insertions, 31 deletions
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js
index cf8905ff982..8f68231398e 100644
--- a/core/js/sharedialogshareelistview.js
+++ b/core/js/sharedialogshareelistview.js
@@ -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;
}
diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js
index 416fff53de4..c0020d5b031 100644
--- a/core/js/sharedialogview.js
+++ b/core/js/sharedialogview.js
@@ -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');
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index 949c86599bc..877b3cb230d 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -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);
},