mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-21 11:24:40 +02:00
Added permission system, to control who can edit Twig labels.
This commit is contained in:
parent
f1a6bc31a1
commit
1a35adab17
6 changed files with 41 additions and 8 deletions
|
@ -40,12 +40,16 @@ class LabelProfileAdminForm extends BaseEntityAdminForm
|
|||
'class' => 'checkbox-custom',
|
||||
],
|
||||
]);
|
||||
$builder->add('options', LabelOptionsType::class);
|
||||
$builder->add('options', LabelOptionsType::class, [
|
||||
'label' => false,
|
||||
'disabled' => $options['disable_options'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
$resolver->setDefault('data_class', LabelProfile::class);
|
||||
$resolver->setDefault('disable_options', false);
|
||||
}
|
||||
}
|
|
@ -29,9 +29,17 @@ use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class LabelOptionsType extends AbstractType
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('width', NumberType::class, [
|
||||
|
@ -120,7 +128,8 @@ class LabelOptionsType extends AbstractType
|
|||
],
|
||||
'label_attr' => [
|
||||
'class' => 'radio-custom radio-inline'
|
||||
]
|
||||
],
|
||||
'disabled' => !$this->security->isGranted('@labels.use_twig')
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class LabelDialogType extends AbstractType
|
|||
|
||||
$builder->add('options', LabelOptionsType::class, [
|
||||
'label' => false,
|
||||
'disabled' => !$this->security->isGranted('@labels.edit_options'),
|
||||
'disabled' => !$this->security->isGranted('@labels.edit_options') || $options['disable_options'],
|
||||
|
||||
]);
|
||||
$builder->add('update', SubmitType::class, [
|
||||
|
@ -64,6 +64,7 @@ class LabelDialogType extends AbstractType
|
|||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
$resolver->setDefault('mapped', 'false');
|
||||
$resolver->setDefault('mapped', false);
|
||||
$resolver->setDefault('disable_options', false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue