diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-08-10 10:32:59 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-10-03 09:06:51 +0200 |
commit | 5cda38346086ebc78f27eda412d316000f5131a1 (patch) | |
tree | 110ccf36572c7c663753d5cfb5f37b4d01aa8ab9 /core | |
parent | 7533fcb977f6153065ad99b9c9e046c4e744f84e (diff) | |
download | nextcloud-server-5cda38346086ebc78f27eda412d316000f5131a1.tar.gz nextcloud-server-5cda38346086ebc78f27eda412d316000f5131a1.zip |
Make can edit checkbox work for file shares
Diffstat (limited to 'core')
-rw-r--r-- | core/js/sharedialogshareelistview.js | 29 | ||||
-rw-r--r-- | core/js/tests/specs/sharedialogshareelistview.js | 5 |
2 files changed, 22 insertions, 12 deletions
diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 7caefcca30d..0b4658f92f0 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -296,20 +296,27 @@ var $li = $element.closest('li[data-share-id]'); var shareId = $li.data('share-id'); - // adjust checkbox states - var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]'); - var checked; - if ($element.attr('name') === 'edit') { - checked = $element.is(':checked'); - // Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck - $($checkboxes).prop('checked', checked); + var permissions = OC.PERMISSION_READ; + + if (this.model.isFolder()) { + // adjust checkbox states + var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]'); + var checked; + if ($element.attr('name') === 'edit') { + checked = $element.is(':checked'); + // Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck + $($checkboxes).prop('checked', checked); + } else { + var numberChecked = $checkboxes.filter(':checked').length; + checked = numberChecked > 0; + $('input[name="edit"]', $li).prop('checked', checked); + } } else { - var numberChecked = $checkboxes.filter(':checked').length; - checked = numberChecked > 0; - $('input[name="edit"]', $li).prop('checked', checked); + if ($element.attr('name') === 'edit' && $element.is(':checked')) { + permissions |= OC.PERMISSION_UPDATE; + } } - var permissions = OC.PERMISSION_READ; $('.permissions', $li).not('input[name="edit"]').filter(':checked').each(function(index, checkbox) { permissions |= $(checkbox).data('permissions'); }); diff --git a/core/js/tests/specs/sharedialogshareelistview.js b/core/js/tests/specs/sharedialogshareelistview.js index cef97469753..9aab46d9117 100644 --- a/core/js/tests/specs/sharedialogshareelistview.js +++ b/core/js/tests/specs/sharedialogshareelistview.js @@ -102,6 +102,7 @@ describe('OC.Share.ShareDialogShareeListView', function () { share_with: 'user1', share_with_displayname: 'User One' }]); + shareModel.set('itemType', 'folder'); listView.render(); listView.$el.find("input[name='edit']").click(); expect(listView.$el.find("input[name='update']").is(':checked')).toEqual(true); @@ -115,8 +116,10 @@ describe('OC.Share.ShareDialogShareeListView', function () { permissions: 1, share_type: OC.Share.SHARE_TYPE_USER, share_with: 'user1', - share_with_displayname: 'User One' + share_with_displayname: 'User One', + itemType: 'folder' }]); + shareModel.set('itemType', 'folder'); listView.render(); listView.$el.find("input[name='update']").click(); expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true); |