mirror of
https://github.com/nextcloud/server.git
synced 2026-04-02 15:45:38 -04:00
make permission/cruds checkboxes work
This commit is contained in:
parent
c7453b4db1
commit
a0fa7186f5
3 changed files with 36 additions and 37 deletions
|
|
@ -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('');
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in a new issue