diff options
Diffstat (limited to 'core/js/sharedialogshareelistview.js')
-rw-r--r-- | core/js/sharedialogshareelistview.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index f078ab8a06b..1f53a479fb5 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -214,6 +214,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); return this; @@ -248,6 +249,34 @@ return false; }, + onPermissionChange: function(element, view) { + var $element = $(element); + 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"]'); + if ($element.attr('name') === 'edit') { + var 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; + $('input[name="edit"]', $li).attr('checked', checked); + } + + var permissions = OC.PERMISSION_READ; + $('.permissions', $li).not('input[name="edit"]').filter(':checked').each(function(index, checkbox) { + permissions |= $(checkbox).data('permissions'); + }); + + view.model.setPermissions(shareType, shareWith, permissions); + + return false; + }, + onCrudsToggle: function() { $(this).siblings('.cruds').toggleClass('hidden'); return false; |