diff --git a/assets/ts_src/event_listeners.ts b/assets/ts_src/event_listeners.ts index a5ea85e8..4a31d00c 100644 --- a/assets/ts_src/event_listeners.ts +++ b/assets/ts_src/event_listeners.ts @@ -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 diff --git a/src/Form/Permissions/PermissionType.php b/src/Form/Permissions/PermissionType.php index de9f8835..c1d9e044 100644 --- a/src/Form/Permissions/PermissionType.php +++ b/src/Form/Permissions/PermissionType.php @@ -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. * diff --git a/templates/Form/permissionLayout.html.twig b/templates/Form/permissionLayout.html.twig index ddb026e9..d48715e4 100644 --- a/templates/Form/permissionLayout.html.twig +++ b/templates/Form/permissionLayout.html.twig @@ -1,7 +1,21 @@ {% block permission_row %}