mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 03:38:47 +02:00
Added an checkbox to change all operations of a permission.
This commit is contained in:
parent
ac302ab16a
commit
35dd1fabc0
3 changed files with 36 additions and 1 deletions
|
@ -219,6 +219,17 @@ $(document).on("ajaxUI:start ajaxUI:reload", function() {
|
|||
unchecked: "false",
|
||||
indeterminate: "indeterminate",
|
||||
});
|
||||
|
||||
$('.permission_multicheckbox:checkbox').change(function() {
|
||||
//Find the other checkboxes in this row, and change their value
|
||||
var $row = $(this).parents('tr');
|
||||
|
||||
//@ts-ignore
|
||||
var new_state = $(this).tristate('state');
|
||||
|
||||
//@ts-ignore
|
||||
$('.tristate:checkbox', $row).tristate('state', new_state;
|
||||
});
|
||||
});
|
||||
|
||||
//Re initialize fileinputs on reload
|
||||
|
|
|
@ -40,6 +40,7 @@ use Symfony\Component\Form\Exception;
|
|||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
|
@ -70,6 +71,10 @@ class PermissionType extends AbstractType implements DataMapperInterface
|
|||
return $options['name'];
|
||||
});
|
||||
|
||||
$resolver->setDefault('multi_checkbox', function (Options $options) {
|
||||
return !$options['disabled'];
|
||||
});
|
||||
|
||||
$resolver->setDefaults([
|
||||
]);
|
||||
}
|
||||
|
@ -90,6 +95,11 @@ class PermissionType extends AbstractType implements DataMapperInterface
|
|||
$builder->setDataMapper($this);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['multi_checkbox'] = $options['multi_checkbox'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the view data of a compound form to its children.
|
||||
*
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
{% block permission_row %}
|
||||
<tr>
|
||||
<td>
|
||||
<b>{{ form.vars.label | trans }}</b>
|
||||
{% if multi_checkbox %}
|
||||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input tristate permission_multicheckbox" id="mulit_check_{{ form.vars.label }}">
|
||||
<label class="custom-control-label" for="mulit_check_{{ form.vars.label }}">
|
||||
<b>{{ form.vars.label | trans }}</b>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<b>{{ form.vars.label | trans }}</b>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{# #}
|
||||
{{ form_errors(form) }}
|
||||
</td>
|
||||
<td>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue