Make can edit checkbox work for file shares

This commit is contained in:
Roeland Jago Douma 2016-08-10 10:32:59 +02:00 committed by Christoph Wurst
parent 7533fcb977
commit 5cda383460
No known key found for this signature in database
GPG key ID: CC42AC2A7F0E56D8
2 changed files with 22 additions and 12 deletions

View file

@ -296,20 +296,27 @@
var $li = $element.closest('li[data-share-id]'); var $li = $element.closest('li[data-share-id]');
var shareId = $li.data('share-id'); var shareId = $li.data('share-id');
// adjust checkbox states var permissions = OC.PERMISSION_READ;
var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]');
var checked; if (this.model.isFolder()) {
if ($element.attr('name') === 'edit') { // adjust checkbox states
checked = $element.is(':checked'); var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]');
// Check/uncheck Create, Update, and Delete checkboxes if Edit is checked/unck var checked;
$($checkboxes).prop('checked', 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 { } else {
var numberChecked = $checkboxes.filter(':checked').length; if ($element.attr('name') === 'edit' && $element.is(':checked')) {
checked = numberChecked > 0; permissions |= OC.PERMISSION_UPDATE;
$('input[name="edit"]', $li).prop('checked', checked); }
} }
var permissions = OC.PERMISSION_READ;
$('.permissions', $li).not('input[name="edit"]').filter(':checked').each(function(index, checkbox) { $('.permissions', $li).not('input[name="edit"]').filter(':checked').each(function(index, checkbox) {
permissions |= $(checkbox).data('permissions'); permissions |= $(checkbox).data('permissions');
}); });

View file

@ -102,6 +102,7 @@ describe('OC.Share.ShareDialogShareeListView', function () {
share_with: 'user1', share_with: 'user1',
share_with_displayname: 'User One' share_with_displayname: 'User One'
}]); }]);
shareModel.set('itemType', 'folder');
listView.render(); listView.render();
listView.$el.find("input[name='edit']").click(); listView.$el.find("input[name='edit']").click();
expect(listView.$el.find("input[name='update']").is(':checked')).toEqual(true); expect(listView.$el.find("input[name='update']").is(':checked')).toEqual(true);
@ -115,8 +116,10 @@ describe('OC.Share.ShareDialogShareeListView', function () {
permissions: 1, permissions: 1,
share_type: OC.Share.SHARE_TYPE_USER, share_type: OC.Share.SHARE_TYPE_USER,
share_with: 'user1', share_with: 'user1',
share_with_displayname: 'User One' share_with_displayname: 'User One',
itemType: 'folder'
}]); }]);
shareModel.set('itemType', 'folder');
listView.render(); listView.render();
listView.$el.find("input[name='update']").click(); listView.$el.find("input[name='update']").click();
expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true); expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true);