mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 20:35:08 +02:00
Applied symplify rules to codebase.
This commit is contained in:
parent
2f20d90041
commit
388e847b17
136 changed files with 1370 additions and 789 deletions
|
@ -46,12 +46,16 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('filetype_filter', TextType::class, ['required' => false,
|
||||
$builder->add('filetype_filter', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'attachment_type.edit.filetype_filter',
|
||||
'help' => 'attachment_type.edit.filetype_filter.help',
|
||||
'attr' => ['placeholder' => 'attachment_type.edit.filetype_filter.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'attachment_type.edit.filetype_filter.placeholder',
|
||||
],
|
||||
'empty_data' => '',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
//Normalize data before writing it to database
|
||||
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
|
||||
|
|
|
@ -31,6 +31,7 @@ use App\Form\AttachmentFormType;
|
|||
use App\Form\Type\MasterPictureAttachmentType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use function get_class;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
@ -66,24 +67,42 @@ class BaseEntityAdminForm extends AbstractType
|
|||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder
|
||||
->add('name', TextType::class, ['empty_data' => '', 'label' => 'name.label',
|
||||
'attr' => ['placeholder' => 'part.name.placeholder'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'name.label',
|
||||
'attr' => [
|
||||
'placeholder' => 'part.name.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
])
|
||||
|
||||
->add('parent', StructuralEntityType::class, ['class' => \get_class($entity),
|
||||
'required' => false, 'label' => 'parent.label',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
|
||||
->add('parent', StructuralEntityType::class, [
|
||||
'class' => get_class($entity),
|
||||
'required' => false,
|
||||
'label' => 'parent.label',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
])
|
||||
|
||||
->add('not_selectable', CheckboxType::class, ['required' => false,
|
||||
->add('not_selectable', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'entity.edit.not_selectable',
|
||||
'help' => 'entity.edit.not_selectable.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
])
|
||||
|
||||
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
|
||||
->add('comment', CKEditorType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'comment.label',
|
||||
'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
'help' => 'bbcode.hint',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$this->additionalFormElements($builder, $options, $entity);
|
||||
|
||||
|
@ -110,10 +129,15 @@ class BaseEntityAdminForm extends AbstractType
|
|||
//Buttons
|
||||
$builder->add('save', SubmitType::class, [
|
||||
'label' => $is_new ? 'entity.create' : 'entity.edit.save',
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : ''],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
->add('reset', ResetType::class, ['label' => 'entity.edit.reset',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'class' => $is_new ? 'btn-success' : '',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
])
|
||||
->add('reset', ResetType::class, [
|
||||
'label' => 'entity.edit.reset',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
|
|
|
@ -35,48 +35,84 @@ class CategoryAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('disable_footprints', CheckboxType::class, ['required' => false,
|
||||
$builder->add('disable_footprints', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'category.edit.disable_footprints',
|
||||
'help' => 'category.edit.disable_footprints.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
|
||||
$builder->add('disable_manufacturers', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'category.edit.disable_manufacturers',
|
||||
'help' => 'category.edit.disable_manufacturers.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
|
||||
$builder->add('disable_autodatasheets', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'category.edit.disable_autodatasheets',
|
||||
'help' => 'category.edit.disable_autodatasheets.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('disable_properties', CheckboxType::class, ['required' => false,
|
||||
$builder->add('disable_properties', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'category.edit.disable_properties',
|
||||
'help' => 'category.edit.disable_properties.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
$builder->add('partname_hint', TextType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'category.edit.partname_hint',
|
||||
'attr' => ['placeholder' => 'category.edit.partname_hint.placeholder'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'placeholder' => 'category.edit.partname_hint.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('partname_regex', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
$builder->add('partname_regex', TextType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'category.edit.partname_regex',
|
||||
'attr' => ['placeholder' => 'category.edit.partname_regex.placeholder'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'placeholder' => 'category.edit.partname_regex.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('default_description', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
$builder->add('default_description', TextType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'category.edit.default_description',
|
||||
'attr' => ['placeholder' => 'category.edit.default_description.placeholder'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'placeholder' => 'category.edit.default_description.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('default_comment', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
$builder->add('default_comment', TextType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'category.edit.default_comment',
|
||||
'attr' => ['placeholder' => 'category.edit.default_comment.placeholder'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'placeholder' => 'category.edit.default_comment.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,14 +40,19 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
$builder->add('address', TextareaType::class, [
|
||||
'label' => 'company.edit.address',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.address.placeholder'], 'required' => false,
|
||||
'attr' => [
|
||||
'placeholder' => 'company.edit.address.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('phone_number', TelType::class, [
|
||||
'label' => 'company.edit.phone_number',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.phone_number.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'company.edit.phone_number.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
@ -55,21 +60,30 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
$builder->add('fax_number', TelType::class, [
|
||||
'label' => 'company.edit.fax_number',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
|
||||
'attr' => [
|
||||
'placeholder' => 'company.fax_number.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('email_address', EmailType::class, [
|
||||
'label' => 'company.edit.email',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.email.placeholder'], 'required' => false,
|
||||
'attr' => [
|
||||
'placeholder' => 'company.edit.email.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('website', UrlType::class, [
|
||||
'label' => 'company.edit.website',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.website.placeholder'], 'required' => false,
|
||||
'attr' => [
|
||||
'placeholder' => 'company.edit.website.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
|
@ -77,7 +91,9 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
'label' => 'company.edit.auto_product_url',
|
||||
'help' => 'company.edit.auto_product_url.help',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.auto_product_url.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'company.edit.auto_product_url.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
|
|
@ -39,14 +39,19 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
|||
'required' => false,
|
||||
'label' => 'currency.edit.iso_code',
|
||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('exchange_rate', MoneyType::class, [
|
||||
'required' => false,
|
||||
'label' => 'currency.edit.exchange_rate',
|
||||
'currency' => $this->params->get('default_currency'),
|
||||
'scale' => 6,
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,10 +35,13 @@ class GroupAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('enforce2FA', CheckboxType::class, ['required' => false,
|
||||
$builder->add('enforce2FA', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'group.edit.enforce_2fa',
|
||||
'help' => 'entity.edit.enforce_2fa.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
|
|
|
@ -56,12 +56,20 @@ class ImportType extends AbstractType
|
|||
$builder
|
||||
|
||||
->add('format', ChoiceType::class, [
|
||||
'choices' => ['JSON' => 'json', 'XML' => 'xml', 'CSV' => 'csv', 'YAML' => 'yaml'],
|
||||
'choices' => [
|
||||
'JSON' => 'json',
|
||||
'XML' => 'xml',
|
||||
'CSV' => 'csv',
|
||||
'YAML' => 'yaml',
|
||||
],
|
||||
'label' => 'export.format',
|
||||
'disabled' => $disabled, ])
|
||||
->add('csv_separator', TextType::class, ['data' => ';',
|
||||
'disabled' => $disabled,
|
||||
])
|
||||
->add('csv_separator', TextType::class, [
|
||||
'data' => ';',
|
||||
'label' => 'import.csv_separator',
|
||||
'disabled' => $disabled, ]);
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
|
||||
if ($entity instanceof StructuralDBElement) {
|
||||
$builder->add('parent', StructuralEntityType::class, [
|
||||
|
@ -74,19 +82,38 @@ class ImportType extends AbstractType
|
|||
|
||||
$builder->add('file', FileType::class, [
|
||||
'label' => 'import.file',
|
||||
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],
|
||||
'attr' => [
|
||||
'class' => 'file',
|
||||
'data-show-preview' => 'false',
|
||||
'data-show-upload' => 'false',
|
||||
],
|
||||
'disabled' => $disabled,
|
||||
])
|
||||
|
||||
->add('preserve_children', CheckboxType::class, ['data' => true, 'required' => false,
|
||||
->add('preserve_children', CheckboxType::class, [
|
||||
'data' => true,
|
||||
'required' => false,
|
||||
'label' => 'import.preserve_children',
|
||||
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled, ])
|
||||
->add('abort_on_validation_error', CheckboxType::class, ['data' => true, 'required' => false,
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => $disabled,
|
||||
])
|
||||
->add('abort_on_validation_error', CheckboxType::class, [
|
||||
'data' => true,
|
||||
'required' => false,
|
||||
'label' => 'import.abort_on_validation',
|
||||
'help' => 'import.abort_on_validation.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled, ])
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => $disabled,
|
||||
])
|
||||
|
||||
//Buttons
|
||||
->add('import', SubmitType::class, ['label' => 'import.btn', 'disabled' => $disabled]);
|
||||
->add('import', SubmitType::class, [
|
||||
'label' => 'import.btn',
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,9 +51,11 @@ class MassCreationForm extends AbstractType
|
|||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
->add('lines', TextareaType::class, ['data' => '',
|
||||
->add('lines', TextareaType::class, [
|
||||
'data' => '',
|
||||
'label' => 'mass_creation.lines',
|
||||
'disabled' => $disabled, 'required' => true,
|
||||
'disabled' => $disabled,
|
||||
'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'mass_creation.lines.placeholder',
|
||||
'rows' => 10,
|
||||
|
@ -64,7 +66,8 @@ class MassCreationForm extends AbstractType
|
|||
'class' => $data['entity_class'],
|
||||
'required' => false,
|
||||
'label' => 'parent.label',
|
||||
'disabled' => $disabled, ]);
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
}
|
||||
|
||||
//Buttons
|
||||
|
|
|
@ -35,21 +35,33 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('is_integer', CheckboxType::class, ['required' => false,
|
||||
$builder->add('is_integer', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'measurement_unit.edit.is_integer',
|
||||
'help' => 'measurement_unit.edit.is_integer.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
|
||||
$builder->add('use_si_prefix', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'measurement_unit.edit.use_si_prefix',
|
||||
'help' => 'measurement_unit.edit.use_si_prefix.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('unit', TextType::class, ['required' => false,
|
||||
$builder->add('unit', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'measurement_unit.edit.unit_symbol',
|
||||
'attr' => ['placeholder' => 'measurement_unit.edit.unit_symbol.placeholder'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'attr' => [
|
||||
'placeholder' => 'measurement_unit.edit.unit_symbol.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,28 +40,39 @@ class StorelocationAdminForm extends BaseEntityAdminForm
|
|||
'required' => false,
|
||||
'label' => 'storelocation.edit.is_full.label',
|
||||
'help' => 'storelocation.edit.is_full.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('limit_to_existing_parts', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'storelocation.limit_to_existing.label',
|
||||
'help' => 'storelocation.limit_to_existing.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('only_single_part', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'storelocation.only_single_part.label',
|
||||
'help' => 'storelocation.only_single_part.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('storage_type', StructuralEntityType::class, [
|
||||
'required' => false,
|
||||
'label' => 'storelocation.storage_type.label',
|
||||
'help' => 'storelocation.storage_type.help',
|
||||
'class' => MeasurementUnit::class, 'disable_not_selectable' => true,
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'class' => MeasurementUnit::class,
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ class SupplierForm extends CompanyForm
|
|||
'required' => false,
|
||||
'label' => 'supplier.edit.default_currency',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('shipping_costs', MoneyType::class, [
|
||||
'required' => false,
|
||||
|
|
|
@ -65,20 +65,34 @@ class AttachmentFormType extends AbstractType
|
|||
'label' => 'attachment.edit.attachment_type',
|
||||
'class' => AttachmentType::class,
|
||||
'disable_not_selectable' => true,
|
||||
'attr' => ['class' => 'attachment_type_selector'],
|
||||
'attr' => [
|
||||
'class' => 'attachment_type_selector',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('showInTable', CheckboxType::class, ['required' => false,
|
||||
$builder->add('showInTable', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'attachment.edit.show_in_table',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('secureFile', CheckboxType::class, ['required' => false,
|
||||
$builder->add('secureFile', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'attachment.edit.secure_file',
|
||||
'mapped' => false,
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
'help' => 'attachment.edit.secure_file.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('url', TextType::class, [
|
||||
'label' => 'attachment.edit.url',
|
||||
|
@ -94,18 +108,28 @@ class AttachmentFormType extends AbstractType
|
|||
],
|
||||
]);
|
||||
|
||||
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
|
||||
$builder->add('downloadURL', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'attachment.edit.download_url',
|
||||
'mapped' => false,
|
||||
'disabled' => ! $this->allow_attachments_download,
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('file', FileType::class, [
|
||||
'label' => 'attachment.edit.file',
|
||||
'mapped' => false,
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],
|
||||
'attr' => [
|
||||
'class' => 'file',
|
||||
'data-show-preview' => 'false',
|
||||
'data-show-upload' => 'false',
|
||||
],
|
||||
'constraints' => [
|
||||
new AllowedFileExtension(),
|
||||
new File([
|
||||
|
|
|
@ -56,13 +56,16 @@ class OrderdetailType extends AbstractType
|
|||
|
||||
$builder->add('supplierpartnr', TextType::class, [
|
||||
'label' => 'orderdetails.edit.supplierpartnr',
|
||||
'attr' => ['placeholder' => 'orderdetails.edit.supplierpartnr.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'orderdetails.edit.supplierpartnr.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('supplier', StructuralEntityType::class, [
|
||||
'class' => Supplier::class, 'disable_not_selectable' => true,
|
||||
'class' => Supplier::class,
|
||||
'disable_not_selectable' => true,
|
||||
'label' => 'orderdetails.edit.supplier',
|
||||
]);
|
||||
|
||||
|
@ -74,7 +77,9 @@ class OrderdetailType extends AbstractType
|
|||
|
||||
$builder->add('obsolete', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'label' => 'orderdetails.edit.obsolete',
|
||||
]);
|
||||
|
||||
|
|
|
@ -81,7 +81,9 @@ class PartBaseType extends AbstractType
|
|||
->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'part.edit.name',
|
||||
'attr' => ['placeholder' => 'part.edit.name.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'part.edit.name.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted('name.edit', $part),
|
||||
])
|
||||
->add('description', CKEditorType::class, [
|
||||
|
@ -89,11 +91,17 @@ class PartBaseType extends AbstractType
|
|||
'empty_data' => '',
|
||||
'label' => 'part.edit.description',
|
||||
'config_name' => 'description_config',
|
||||
'attr' => ['placeholder' => 'part.edit.description.placeholder', 'rows' => 2],
|
||||
'attr' => [
|
||||
'placeholder' => 'part.edit.description.placeholder',
|
||||
'rows' => 2,
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted('description.edit', $part),
|
||||
])
|
||||
->add('minAmount', SIUnitType::class, [
|
||||
'attr' => ['min' => 0, 'placeholder' => 'part.editmininstock.placeholder'],
|
||||
'attr' => [
|
||||
'min' => 0,
|
||||
'placeholder' => 'part.editmininstock.placeholder',
|
||||
],
|
||||
'label' => 'part.edit.mininstock',
|
||||
'measurement_unit' => $part->getPartUnit(),
|
||||
'disabled' => ! $this->security->isGranted('minamount.edit', $part),
|
||||
|
@ -117,7 +125,8 @@ class PartBaseType extends AbstractType
|
|||
'empty_data' => '',
|
||||
'attr' => [
|
||||
'class' => 'tagsinput',
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']), ],
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']),
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted('tags.edit', $part),
|
||||
]);
|
||||
|
||||
|
@ -139,7 +148,8 @@ class PartBaseType extends AbstractType
|
|||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'part.edit.mpn',
|
||||
'disabled' => ! $this->security->isGranted('mpn.edit', $part), ])
|
||||
'disabled' => ! $this->security->isGranted('mpn.edit', $part),
|
||||
])
|
||||
->add('manufacturing_status', ChoiceType::class, [
|
||||
'label' => 'part.edit.manufacturing_status',
|
||||
'choices' => $status_choices,
|
||||
|
@ -149,13 +159,17 @@ class PartBaseType extends AbstractType
|
|||
|
||||
//Advanced section
|
||||
$builder->add('needsReview', CheckboxType::class, [
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'required' => false,
|
||||
'label' => 'part.edit.needs_review',
|
||||
'disabled' => ! $this->security->isGranted('edit', $part),
|
||||
])
|
||||
->add('favorite', CheckboxType::class, [
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'required' => false,
|
||||
'label' => 'part.edit.is_favorite',
|
||||
'disabled' => ! $this->security->isGranted('change_favorite', $part),
|
||||
|
@ -178,8 +192,11 @@ class PartBaseType extends AbstractType
|
|||
$builder->add('comment', CKEditorType::class, [
|
||||
'required' => false,
|
||||
'label' => 'part.edit.comment',
|
||||
'attr' => ['rows' => 4],
|
||||
'disabled' => ! $this->security->isGranted('comment.edit', $part), 'empty_data' => '',
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted('comment.edit', $part),
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
//Part Lots section
|
||||
|
|
|
@ -52,43 +52,65 @@ class PartLotType extends AbstractType
|
|||
'label' => 'part_lot.edit.description',
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class,
|
||||
$builder->add('storage_location', StructuralEntityType::class, [
|
||||
'class' => Storelocation::class,
|
||||
'label' => 'part_lot.edit.location',
|
||||
'required' => false,
|
||||
'disable_not_selectable' => true,
|
||||
'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker form-control-sm',
|
||||
'data-live-search' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('amount', SIUnitType::class, [
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'label' => 'part_lot.edit.amount',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('instock_unknown', CheckboxType::class, ['required' => false,
|
||||
$builder->add('instock_unknown', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'part_lot.edit.instock_unknown',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('needs_refill', CheckboxType::class, ['label_attr' => ['class' => 'checkbox-custom'],
|
||||
$builder->add('needs_refill', CheckboxType::class, [
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'label' => 'part_lot.edit.needs_refill',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$builder->add('expirationDate', DateTimeType::class, [
|
||||
'label' => 'part_lot.edit.expiration_date',
|
||||
'attr' => [],
|
||||
'required' => false, ]);
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$builder->add('comment', TextType::class, [
|
||||
'label' => 'part_lot.edit.comment',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'required' => false, 'empty_data' => '',
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,18 +41,25 @@ class PricedetailType extends AbstractType
|
|||
$builder->add('min_discount_quantity', SIUnitType::class, [
|
||||
'label' => false,
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
]);
|
||||
$builder->add('price_related_quantity', SIUnitType::class, [
|
||||
'label' => false,
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'attr' => [
|
||||
'class' => 'form-control-sm',
|
||||
],
|
||||
]);
|
||||
$builder->add('price', NumberType::class, [
|
||||
'label' => false,
|
||||
'scale' => 5,
|
||||
'html5' => true,
|
||||
'attr' => ['min' => 0, 'step' => 'any'],
|
||||
'attr' => [
|
||||
'min' => 0,
|
||||
'step' => 'any',
|
||||
],
|
||||
]);
|
||||
$builder->add('currency', CurrencyEntityType::class, [
|
||||
'required' => false,
|
||||
|
|
|
@ -25,14 +25,16 @@ declare(strict_types=1);
|
|||
namespace App\Form\Permissions;
|
||||
|
||||
use App\Services\PermissionResolver;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* This class is a data mapper that maps the permission data from DB (accessed via a PermissionResolver),
|
||||
* to TristateCheckboxes and vice versa.
|
||||
*/
|
||||
class PermissionsMapper implements DataMapperInterface
|
||||
final class PermissionsMapper implements DataMapperInterface
|
||||
{
|
||||
protected $resolver;
|
||||
protected $inherit;
|
||||
|
@ -49,8 +51,8 @@ class PermissionsMapper implements DataMapperInterface
|
|||
* The method is responsible for calling {@link FormInterface::setData()}
|
||||
* on the children of compound forms, defining their underlying model data.
|
||||
*
|
||||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
*/
|
||||
public function mapDataToForms($viewData, $forms): void
|
||||
{
|
||||
|
@ -95,14 +97,14 @@ class PermissionsMapper implements DataMapperInterface
|
|||
* The model data can be an array or an object, so this second argument is always passed
|
||||
* by reference.
|
||||
*
|
||||
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
*/
|
||||
public function mapFormsToData($forms, &$viewData): void
|
||||
{
|
||||
if ($this->inherit) {
|
||||
throw new \RuntimeException('The permission type is readonly when it is showing read only data!');
|
||||
throw new RuntimeException('The permission type is readonly when it is showing read only data!');
|
||||
}
|
||||
|
||||
foreach ($forms as $form) {
|
||||
|
|
|
@ -58,7 +58,12 @@ class TFAGoogleSettingsType extends AbstractType
|
|||
TextType::class,
|
||||
[
|
||||
'mapped' => false,
|
||||
'attr' => ['maxlength' => '6', 'minlength' => '6', 'pattern' => '\d*', 'autocomplete' => 'off'],
|
||||
'attr' => [
|
||||
'maxlength' => '6',
|
||||
'minlength' => '6',
|
||||
'pattern' => '\d*',
|
||||
'autocomplete' => 'off',
|
||||
],
|
||||
'constraints' => [new ValidGoogleAuthCode()],
|
||||
]
|
||||
);
|
||||
|
@ -77,7 +82,9 @@ class TFAGoogleSettingsType extends AbstractType
|
|||
} else {
|
||||
$form->add('submit', SubmitType::class, [
|
||||
'label' => 'tfa_google.disable',
|
||||
'attr' => ['class' => 'btn-danger'],
|
||||
'attr' => [
|
||||
'class' => 'btn-danger',
|
||||
],
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace App\Form\Type;
|
|||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use ReflectionClass;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
|
@ -41,7 +42,9 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
|
||||
$resolver->setDefaults([
|
||||
'filter' => 'picture',
|
||||
'attr' => ['class' => 'selectpicker'],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
],
|
||||
'choice_attr' => function (Options $options) {
|
||||
return function ($choice, $key, $value) use ($options) {
|
||||
/** @var Attachment $choice */
|
||||
|
@ -58,7 +61,7 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
},
|
||||
'choice_label' => 'name',
|
||||
'class' => function (Options $options) {
|
||||
$short_class_name = (new \ReflectionClass($options['entity']))->getShortName();
|
||||
$short_class_name = (new ReflectionClass($options['entity']))->getShortName();
|
||||
//Category becomes CategoryAttachment
|
||||
return 'App\\Entity\\Attachments\\'.$short_class_name.'Attachment';
|
||||
},
|
||||
|
|
|
@ -36,8 +36,9 @@ use Symfony\Component\Form\FormInterface;
|
|||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Traversable;
|
||||
|
||||
class SIUnitType extends AbstractType implements DataMapperInterface
|
||||
final class SIUnitType extends AbstractType implements DataMapperInterface
|
||||
{
|
||||
protected $si_formatter;
|
||||
|
||||
|
@ -80,7 +81,9 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
|
||||
return null;
|
||||
},
|
||||
'error_mapping' => ['.' => 'value'],
|
||||
'error_mapping' => [
|
||||
'.' => 'value',
|
||||
],
|
||||
]);
|
||||
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
|
@ -117,7 +120,13 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
if ($options['show_prefix']) {
|
||||
$builder->add('prefix', ChoiceType::class, [
|
||||
'label' => 'false',
|
||||
'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3, 'µ' => -6],
|
||||
'choices' => [
|
||||
'M' => 6,
|
||||
'k' => 3,
|
||||
'' => 0,
|
||||
'm' => -3,
|
||||
'µ' => -6,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -143,8 +152,8 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
* The method is responsible for calling {@link FormInterface::setData()}
|
||||
* on the children of compound forms, defining their underlying model data.
|
||||
*
|
||||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
|
||||
*/
|
||||
|
@ -193,9 +202,9 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
* The model data can be an array or an object, so this second argument is always passed
|
||||
* by reference.
|
||||
*
|
||||
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
* @param FormInterface[]|Traversable $forms A list of {@link FormInterface} instances
|
||||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
|
||||
*/
|
||||
|
|
|
@ -50,7 +50,9 @@ class StructuralEntityType extends AbstractType
|
|||
{
|
||||
protected $em;
|
||||
protected $options;
|
||||
/** @var NodesListBuilder */
|
||||
/**
|
||||
* @var NodesListBuilder
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, NodesListBuilder $builder)
|
||||
|
@ -81,9 +83,11 @@ class StructuralEntityType extends AbstractType
|
|||
return new CallbackChoiceLoader(function () use ($options) {
|
||||
return $this->getEntries($options);
|
||||
});
|
||||
}, 'choice_label' => function ($choice, $key, $value) {
|
||||
},
|
||||
'choice_label' => function ($choice, $key, $value) {
|
||||
return $this->generateChoiceLabels($choice, $key, $value);
|
||||
}, 'choice_attr' => function ($choice, $key, $value) {
|
||||
},
|
||||
'choice_attr' => function ($choice, $key, $value) {
|
||||
return $this->generateChoiceAttr($choice, $key, $value);
|
||||
},
|
||||
]);
|
||||
|
@ -91,7 +95,10 @@ class StructuralEntityType extends AbstractType
|
|||
$resolver->setDefault('empty_message', null);
|
||||
|
||||
$resolver->setDefault('attr', function (Options $options) {
|
||||
$tmp = ['class' => 'selectpicker', 'data-live-search' => true];
|
||||
$tmp = [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
];
|
||||
if ($options['empty_message']) {
|
||||
$tmp['data-none-Selected-Text'] = $options['empty_message'];
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
@ -32,7 +33,7 @@ use Symfony\Component\Form\FormInterface;
|
|||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TriStateCheckboxType extends AbstractType implements DataTransformerInterface
|
||||
final class TriStateCheckboxType extends AbstractType implements DataTransformerInterface
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
|
@ -42,8 +43,12 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'label_attr' => ['class' => 'checkbox-custom checkbox-inline'],
|
||||
'attr' => ['class' => 'tristate'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom checkbox-inline',
|
||||
],
|
||||
'attr' => [
|
||||
'class' => 'tristate',
|
||||
],
|
||||
'compound' => false,
|
||||
]);
|
||||
}
|
||||
|
@ -115,7 +120,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
return 'indeterminate';
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid value encountered!: '.$value);
|
||||
throw new InvalidArgumentException('Invalid value encountered!: '.$value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,7 +161,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
case 'indeterminate':
|
||||
return null;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid value encountered!: '.$value);
|
||||
throw new InvalidArgumentException('Invalid value encountered!: '.$value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,9 @@ class UserAdminForm extends AbstractType
|
|||
->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.username.label',
|
||||
'attr' => ['placeholder' => 'user.username.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'user.username.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted('edit_username', $entity),
|
||||
])
|
||||
|
||||
|
@ -82,19 +84,25 @@ class UserAdminForm extends AbstractType
|
|||
'required' => false,
|
||||
'label' => 'group.label',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => ! $this->security->isGranted('change_group', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted('change_group', $entity),
|
||||
])
|
||||
|
||||
->add('first_name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.firstName.label',
|
||||
'attr' => ['placeholder' => 'user.firstName.placeholder'], 'required' => false,
|
||||
'attr' => [
|
||||
'placeholder' => 'user.firstName.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
||||
->add('last_name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.lastName.label',
|
||||
'attr' => ['placeholder' => 'user.lastName.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'user.lastName.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
@ -102,14 +110,19 @@ class UserAdminForm extends AbstractType
|
|||
->add('email', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.email.label',
|
||||
'attr' => ['placeholder' => 'user.email.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'user.email.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
||||
->add('department', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.department.label',
|
||||
'attr' => ['placeholder' => 'user.department.placeholder'],
|
||||
'attr' => [
|
||||
'placeholder' => 'user.department.placeholder',
|
||||
],
|
||||
'required' => false,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
@ -117,7 +130,10 @@ class UserAdminForm extends AbstractType
|
|||
//Config section
|
||||
->add('language', LanguageType::class, [
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
],
|
||||
'placeholder' => 'user_settings.language.placeholder',
|
||||
'label' => 'user.language_select',
|
||||
'preferred_choices' => ['en', 'de'],
|
||||
|
@ -125,7 +141,10 @@ class UserAdminForm extends AbstractType
|
|||
])
|
||||
->add('timezone', TimezoneType::class, [
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
],
|
||||
'placeholder' => 'user_settings.timezone.placeholder',
|
||||
'label' => 'user.timezone.label',
|
||||
'preferred_choices' => ['Europe/Berlin'],
|
||||
|
@ -137,7 +156,9 @@ class UserAdminForm extends AbstractType
|
|||
'choice_label' => function ($entity, $key, $value) {
|
||||
return $value;
|
||||
},
|
||||
'attr' => ['class' => 'selectpicker'],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
],
|
||||
'placeholder' => 'user_settings.theme.placeholder',
|
||||
'label' => 'user.theme.label',
|
||||
'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
|
||||
|
@ -150,8 +171,12 @@ class UserAdminForm extends AbstractType
|
|||
|
||||
->add('new_password', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'first_options' => ['label' => 'user.settings.pw_new.label'],
|
||||
'second_options' => ['label' => 'user.settings.pw_confirm.label'],
|
||||
'first_options' => [
|
||||
'label' => 'user.settings.pw_new.label',
|
||||
],
|
||||
'second_options' => [
|
||||
'label' => 'user.settings.pw_confirm.label',
|
||||
],
|
||||
'invalid_message' => 'password_must_match',
|
||||
'required' => false,
|
||||
'mapped' => false,
|
||||
|
@ -164,14 +189,18 @@ class UserAdminForm extends AbstractType
|
|||
|
||||
->add('need_pw_change', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'label' => 'user.edit.needs_pw_change',
|
||||
'disabled' => ! $this->security->isGranted('set_password', $entity),
|
||||
])
|
||||
|
||||
->add('disabled', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'label' => 'user.edit.user_disabled',
|
||||
'disabled' => ! $this->security->isGranted('set_password', $entity)
|
||||
|| $entity === $this->security->getUser(),
|
||||
|
@ -206,7 +235,9 @@ class UserAdminForm extends AbstractType
|
|||
//Buttons
|
||||
$builder->add('save', SubmitType::class, [
|
||||
'label' => $is_new ? 'user.create' : 'user.edit.save',
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : ''],
|
||||
'attr' => [
|
||||
'class' => $is_new ? 'btn-success' : '',
|
||||
],
|
||||
])
|
||||
->add('reset', ResetType::class, [
|
||||
'label' => 'entity.edit.reset',
|
||||
|
|
|
@ -79,7 +79,10 @@ class UserSettingsType extends AbstractType
|
|||
->add('language', LanguageType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
],
|
||||
'placeholder' => 'user_settings.language.placeholder',
|
||||
'label' => 'user.language_select',
|
||||
'preferred_choices' => ['en', 'de'],
|
||||
|
@ -87,7 +90,10 @@ class UserSettingsType extends AbstractType
|
|||
->add('timezone', TimezoneType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
],
|
||||
'placeholder' => 'user_settings.timezone.placeholder',
|
||||
'label' => 'user.timezone.label',
|
||||
'preferred_choices' => ['Europe/Berlin'],
|
||||
|
@ -95,7 +101,9 @@ class UserSettingsType extends AbstractType
|
|||
->add('theme', ChoiceType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'selectpicker'],
|
||||
'attr' => [
|
||||
'class' => 'selectpicker',
|
||||
],
|
||||
'choices' => User::AVAILABLE_THEMES,
|
||||
'choice_label' => function ($entity, $key, $value) {
|
||||
return $value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue