diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-09-14 02:29:22 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-09-16 07:23:28 +0200 |
commit | a0fa7186f55b16ddccbd3780f61433e977cbefd2 (patch) | |
tree | ffe9f121aa20bd58bc5810f0729d0cbb61ed288d /core/js | |
parent | c7453b4db1c31884f798b8aa826bb25560e9551e (diff) | |
download | nextcloud-server-a0fa7186f55b16ddccbd3780f61433e977cbefd2.tar.gz nextcloud-server-a0fa7186f55b16ddccbd3780f61433e977cbefd2.zip |
make permission/cruds checkboxes work
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/share.js | 37 | ||||
-rw-r--r-- | core/js/sharedialogshareelistview.js | 29 | ||||
-rw-r--r-- | core/js/shareitemmodel.js | 7 |
3 files changed, 36 insertions, 37 deletions
diff --git a/core/js/share.js b/core/js/share.js index e3c4d3d91af..c05f3602dd7 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -856,43 +856,6 @@ $(document).ready(function() { } }); - $(document).on('change', '#dropdown .permissions', function() { - var li = $(this).closest('li'); - if ($(this).attr('name') == 'edit') { - var checkboxes = $('.permissions', li); - var checked = $(this).is(':checked'); - // Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck - $(checkboxes).filter('input[name="create"]').attr('checked', checked); - $(checkboxes).filter('input[name="update"]').attr('checked', checked); - $(checkboxes).filter('input[name="delete"]').attr('checked', checked); - } else { - var checkboxes = $('.permissions', li); - // Uncheck Edit if Create, Update, and Delete are not checked - if (!$(this).is(':checked') - && !$(checkboxes).filter('input[name="create"]').is(':checked') - && !$(checkboxes).filter('input[name="update"]').is(':checked') - && !$(checkboxes).filter('input[name="delete"]').is(':checked')) - { - $(checkboxes).filter('input[name="edit"]').attr('checked', false); - // Check Edit if Create, Update, or Delete is checked - } else if (($(this).attr('name') == 'create' - || $(this).attr('name') == 'update' - || $(this).attr('name') == 'delete')) - { - $(checkboxes).filter('input[name="edit"]').attr('checked', true); - } - } - var permissions = OC.PERMISSION_READ; - $(checkboxes).filter(':not(input[name="edit"])').filter(':checked').each(function(index, checkbox) { - permissions |= $(checkbox).data('permissions'); - }); - OC.Share.setPermissions($('#dropdown').data('item-type'), - $('#dropdown').data('item-source'), - li.data('share-type'), - li.attr('data-share-with'), - permissions); - }); - $(document).on('click', '#dropdown #expirationCheckbox', function() { if (this.checked) { OC.Share.showExpirationDate(''); 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; diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index dabcc65c0a1..eb44b735737 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -171,6 +171,13 @@ }); }, + setPermissions: function(shareType, shareWith, permissions) { + var itemType = this.get('itemType'); + var itemSource = this.get('itemSource'); + + OC.Share.setPermissions(itemType, itemSource, shareType, shareWith, permissions); + }, + removeShare: function(shareType, shareWith) { var model = this; var itemType = this.get('itemType'); |