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,6 +296,9 @@
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');
var permissions = OC.PERMISSION_READ;
if (this.model.isFolder()) {
// adjust checkbox states // adjust checkbox states
var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]'); var $checkboxes = $('.permissions', $li).not('input[name="edit"]').not('input[name="share"]');
var checked; var checked;
@ -308,8 +311,12 @@
checked = numberChecked > 0; checked = numberChecked > 0;
$('input[name="edit"]', $li).prop('checked', checked); $('input[name="edit"]', $li).prop('checked', checked);
} }
} else {
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', $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);