Dont call translator inside the form classes.

Translation is already done in the templates, so translator calls in form classes, are bad for performance and readability.
This commit is contained in:
Jan Böhmer 2019-12-26 14:53:13 +01:00
parent e7b920c4fe
commit 89acfff857
28 changed files with 1875 additions and 2259 deletions

View file

@ -107,13 +107,13 @@ abstract class BaseAdminController extends AbstractController
$em->persist($entity);
$em->flush();
$this->addFlash('success', $this->translator->trans('entity.edit_flash'));
$this->addFlash('success', 'entity.edit_flash');
//Rebuild form, so it is based on the updated data. Important for the parent field!
//We can not use dynamic form events here, because the parent entity list is build from database!
$form = $this->createForm($this->form_class, $entity, ['attachment_class' => $this->attachment_class]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('error', $this->translator->trans('entity.edit_flash.invalid'));
$this->addFlash('error', 'entity.edit_flash.invalid');
}
return $this->render($this->twig_template, [
@ -163,13 +163,13 @@ abstract class BaseAdminController extends AbstractController
$em->persist($new_entity);
$em->flush();
$this->addFlash('success', $this->translator->trans('entity.created_flash'));
$this->addFlash('success', 'entity.created_flash');
return $this->redirectToRoute($this->route_base.'_edit', ['id' => $new_entity->getID()]);
}
if ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('error', $this->translator->trans('entity.created_flash.invalid'));
$this->addFlash('error', 'entity.created_flash.invalid');
}
//Import form

View file

@ -1,82 +0,0 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Class DebugController.
*/
class DebugController extends AbstractController
{
/**
* @Route("/debug/flash_test")
*/
public function flashTest()
{
$this->addFlash('success', 'Success Flash Message!');
$this->addFlash('error', 'Error Flash Message!');
$this->addFlash('warning', 'Warning Flash Message!');
$this->addFlash('notice', 'Notice Flash Message!');
$this->addFlash('info', 'Info Flash Message! <b>Test</b>');
$this->addFlash('testkjfd', 'Blabla. This message type should be not know to template!');
return $this->render('base.html.twig');
}
/**
* @Route("/debug/dummy")
*/
public function dummy(TranslatorInterface $translator)
{
//Here we collect translation keys automatically created, so they can be extracted easily
//Validators:
$translator->trans('validator.noneofitschild.self');
$translator->trans('validator.noneofitschild.children');
$translator->trans('validator.isSelectable');
$translator->trans('validator.part_lot.location_full.no_increasment');
$translator->trans('validator.part_lot.location_full');
$translator->trans('validator.part_lot.only_existing');
$translator->trans('validator.part_lot.single_part');
//Manufacturer status
$translator->trans('m_status.active.help');
$translator->trans('m_status.announced.help');
$translator->trans('m_status.discontinued.help');
$translator->trans('m_status.eol.help');
$translator->trans('m_status.nrfnd.help');
$translator->trans('m_status.unknown.help');
//Flash titles
$translator->trans('flash.success');
$translator->trans('flash.error');
$translator->trans('flash.warning');
$translator->trans('flash.notice');
$translator->trans('flash.info');
$translator->trans('validator.noLockout');
}
}

View file

@ -97,11 +97,11 @@ class PartController extends AbstractController
$em->persist($part);
$em->flush();
$this->addFlash('info', $translator->trans('part.edited_flash'));
$this->addFlash('info', 'part.edited_flash');
//Reload form, so the SIUnitType entries use the new part unit
$form = $this->createForm(PartBaseType::class, $part);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('error', $translator->trans('part.edited_flash.invalid'));
$this->addFlash('error', 'part.edited_flash.invalid');
}
return $this->render('Parts/edit/edit_part_info.html.twig',
@ -180,13 +180,13 @@ class PartController extends AbstractController
$em->persist($new_part);
$em->flush();
$this->addFlash('success', $translator->trans('part.created_flash'));
$this->addFlash('success', 'part.created_flash');
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}
if ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('error', $translator->trans('part.created_flash.invalid'));
$this->addFlash('error', 'part.created_flash.invalid');
}
return $this->render('Parts/edit/new_part.html.twig',
@ -216,7 +216,7 @@ class PartController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$em->persist($new_part);
$em->flush();
$this->addFlash('success', $translator->trans('part.created_flash'));
$this->addFlash('success', 'part.created_flash');
return $this->redirectToRoute('part_edit', ['id' => $new_part->getID()]);
}

View file

@ -99,7 +99,7 @@ class SecurityController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$passwordReset->request($form->getData()['user']);
$this->addFlash('success', $this->translator->trans('pw_reset.request.success'));
$this->addFlash('success', 'pw_reset.request.success');
return $this->redirectToRoute('login');
}
@ -152,9 +152,9 @@ class SecurityController extends AbstractController
//Try to set the new password
$success = $passwordReset->setNewPassword($data['username'], $data['token'], $data['new_password']);
if (!$success) {
$this->addFlash('error', $this->translator->trans('pw_reset.new_pw.error'));
$this->addFlash('error', 'pw_reset.new_pw.error');
} else {
$this->addFlash('success', $this->translator->trans('pw_reset.new_pw.success'));
$this->addFlash('success', 'pw_reset.new_pw.success');
return $this->redirectToRoute('login');
}
}

View file

@ -34,10 +34,10 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
{
protected $filterTools;
public function __construct(Security $security, ParameterBagInterface $params, TranslatorInterface $trans, FileTypeFilterTools $filterTools)
public function __construct(Security $security, ParameterBagInterface $params, FileTypeFilterTools $filterTools)
{
$this->filterTools = $filterTools;
parent::__construct($security, $params, $trans);
parent::__construct($security, $params);
}
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
@ -45,9 +45,9 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
$is_new = null === $entity->getID();
$builder->add('filetype_filter', TextType::class, ['required' => false,
'label' => $this->trans->trans('attachment_type.edit.filetype_filter'),
'help' => $this->trans->trans('attachment_type.edit.filetype_filter.help'),
'attr' => ['placeholder' => $this->trans->trans('attachment_type.edit.filetype_filter.placeholder')],
'label' => 'attachment_type.edit.filetype_filter',
'help' => 'attachment_type.edit.filetype_filter.help',
'attr' => ['placeholder' => 'attachment_type.edit.filetype_filter.placeholder'],
'empty_data' => '',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);

View file

@ -44,13 +44,11 @@ class BaseEntityAdminForm extends AbstractType
{
protected $security;
protected $params;
protected $trans;
public function __construct(Security $security, ParameterBagInterface $params, TranslatorInterface $trans)
public function __construct(Security $security, ParameterBagInterface $params)
{
$this->security = $security;
$this->params = $params;
$this->trans = $trans;
}
public function configureOptions(OptionsResolver $resolver)
@ -66,23 +64,23 @@ class BaseEntityAdminForm extends AbstractType
$is_new = null === $entity->getID();
$builder
->add('name', TextType::class, ['empty_data' => '', 'label' => $this->trans->trans('name.label'),
'attr' => ['placeholder' => $this->trans->trans('part.name.placeholder')],
->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' => $this->trans->trans('parent.label'),
'required' => false, 'label' => 'parent.label',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
->add('not_selectable', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('entity.edit.not_selectable'),
'help' => $this->trans->trans('entity.edit.not_selectable.help'),
'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), ])
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
'label' => $this->trans->trans('comment.label'),
'attr' => ['rows' => 4], 'help' => $this->trans->trans('bbcode.hint'),
'label' => 'comment.label',
'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
$this->additionalFormElements($builder, $options, $entity);
@ -103,13 +101,13 @@ class BaseEntityAdminForm extends AbstractType
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'label' => $this->trans->trans('part.edit.master_attachment'),
'label' => 'part.edit.master_attachment',
'entity' => $entity,
]);
//Buttons
$builder->add('save', SubmitType::class, [
'label' => $is_new ? $this->trans->trans('entity.create') : $this->trans->trans('entity.edit.save'),
'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',

View file

@ -33,46 +33,46 @@ class CategoryAdminForm extends BaseEntityAdminForm
$is_new = null === $entity->getID();
$builder->add('disable_footprints', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('category.edit.disable_footprints'),
'help' => $this->trans->trans('category.edit.disable_footprints.help'),
'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), ]);
$builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('category.edit.disable_manufacturers'),
'help' => $this->trans->trans('category.edit.disable_manufacturers.help'),
'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), ]);
$builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('category.edit.disable_autodatasheets'),
'help' => $this->trans->trans('category.edit.disable_autodatasheets.help'),
'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), ]);
$builder->add('disable_properties', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('category.edit.disable_properties'),
'help' => $this->trans->trans('category.edit.disable_properties.help'),
'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), ]);
$builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
'label' => $this->trans->trans('category.edit.partname_hint'),
'attr' => ['placeholder' => $this->trans->trans('category.edit.partname_hint.placeholder')],
'label' => 'category.edit.partname_hint',
'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' => '',
'label' => $this->trans->trans('category.edit.partname_regex'),
'label' => 'category.edit.partname_regex',
'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' => '',
'label' => $this->trans->trans('category.edit.default_description'),
'attr' => ['placeholder' => $this->trans->trans('category.edit.default_description.placeholder')],
'label' => 'category.edit.default_description',
'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' => '',
'label' => $this->trans->trans('category.edit.default_comment'),
'label' => 'category.edit.default_comment',
'attr' => ['placeholder' => $this->trans->trans('category.edit.default_comment.placeholder')],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}

View file

@ -35,46 +35,46 @@ class CompanyForm extends BaseEntityAdminForm
$is_new = null === $entity->getID();
$builder->add('address', TextareaType::class, [
'label' => $this->trans->trans('company.edit.address'),
'label' => 'company.edit.address',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => $this->trans->trans('company.edit.address.placeholder')], 'required' => false,
'attr' => ['placeholder' => 'company.edit.address.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('phone_number', TelType::class, [
'label' => $this->trans->trans('company.edit.phone_number'),
'label' => 'company.edit.phone_number',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => $this->trans->trans('company.edit.phone_number.placeholder')],
'attr' => ['placeholder' => 'company.edit.phone_number.placeholder'],
'required' => false,
'empty_data' => '',
]);
$builder->add('fax_number', TelType::class, [
'label' => $this->trans->trans('company.edit.fax_number'),
'label' => 'company.edit.fax_number',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('email_address', EmailType::class, [
'label' => $this->trans->trans('company.edit.email'),
'label' => 'company.edit.email',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => $this->trans->trans('company.edit.email.placeholder')], 'required' => false,
'attr' => ['placeholder' => 'company.edit.email.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('website', UrlType::class, [
'label' => $this->trans->trans('company.edit.website'),
'label' => 'company.edit.website',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => $this->trans->trans('company.edit.website.placeholder')], 'required' => false,
'attr' => ['placeholder' => 'company.edit.website.placeholder'], 'required' => false,
'empty_data' => '',
]);
$builder->add('auto_product_url', UrlType::class, [
'label' => $this->trans->trans('company.edit.auto_product_url'),
'help' => $this->trans->trans('company.edit.auto_product_url.help'),
'label' => 'company.edit.auto_product_url',
'help' => 'company.edit.auto_product_url.help',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
'attr' => ['placeholder' => $this->trans->trans('company.edit.auto_product_url.placeholder')],
'attr' => ['placeholder' => 'company.edit.auto_product_url.placeholder'],
'required' => false,
'empty_data' => '',
]);

View file

@ -34,14 +34,14 @@ class CurrencyAdminForm extends BaseEntityAdminForm
$builder->add('iso_code', CurrencyType::class, [
'required' => false,
'label' => $this->trans->trans('currency.edit.iso_code'),
'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), ]);
$builder->add('exchange_rate', MoneyType::class, [
'required' => false,
'label' => $this->trans->trans('currency.edit.exchange_rate'),
'label' => 'currency.edit.exchange_rate',
'currency' => $this->params->get('default_currency'),
'scale' => 6,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);

View file

@ -32,7 +32,7 @@ class FootprintAdminForm extends BaseEntityAdminForm
$builder->add('footprint_3d', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
'label' => $this->trans->trans('footprint.edit.3d_model'),
'label' => 'footprint.edit.3d_model',
'filter' => '3d_model',
'entity' => $entity,
]);

View file

@ -36,12 +36,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class ImportType extends AbstractType
{
protected $security;
protected $trans;
public function __construct(Security $security, TranslatorInterface $trans)
public function __construct(Security $security)
{
$this->security = $security;
$this->trans = $trans;
}
public function buildForm(FormBuilderInterface $builder, array $options)
@ -57,33 +55,33 @@ class ImportType extends AbstractType
->add('format', ChoiceType::class, [
'choices' => ['JSON' => 'json', 'XML' => 'xml', 'CSV' => 'csv', 'YAML' => 'yaml'],
'label' => $this->trans->trans('export.format'),
'label' => 'export.format',
'disabled' => $disabled, ])
->add('csv_separator', TextType::class, ['data' => ';',
'label' => $this->trans->trans('import.csv_separator'),
'label' => 'import.csv_separator',
'disabled' => $disabled, ]);
if ($entity instanceof StructuralDBElement) {
$builder->add('parent', StructuralEntityType::class, [
'class' => $data['entity_class'],
'required' => false,
'label' => $this->trans->trans('parent.label'),
'label' => 'parent.label',
'disabled' => $disabled,
]);
}
$builder->add('file', FileType::class, [
'label' => $this->trans->trans('import.file'),
'label' => 'import.file',
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],
'disabled' => $disabled,
])
->add('preserve_children', CheckboxType::class, ['data' => true, 'required' => false,
'label' => $this->trans->trans('import.preserve_children'),
'label' => 'import.preserve_children',
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled, ])
->add('abort_on_validation_error', CheckboxType::class, ['data' => true, 'required' => false,
'label' => $this->trans->trans('import.abort_on_validation'),
'help' => $this->trans->trans('import.abort_on_validation.help'),
'label' => 'import.abort_on_validation',
'help' => 'import.abort_on_validation.help',
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled, ])
//Buttons

View file

@ -33,12 +33,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class MassCreationForm extends AbstractType
{
protected $security;
protected $translator;
public function __construct(Security $security, TranslatorInterface $translator)
public function __construct(Security $security)
{
$this->security = $security;
$this->translator = $translator;
}
public function buildForm(FormBuilderInterface $builder, array $options)
@ -52,10 +50,10 @@ class MassCreationForm extends AbstractType
$builder
->add('lines', TextareaType::class, ['data' => '',
'label' => $this->translator->trans('mass_creation.lines'),
'label' => 'mass_creation.lines',
'disabled' => $disabled, 'required' => true,
'attr' => [
'placeholder' => $this->translator->trans('mass_creation.lines.placeholder'),
'placeholder' => 'mass_creation.lines.placeholder',
'rows' => 10,
],
]);
@ -63,13 +61,13 @@ class MassCreationForm extends AbstractType
$builder->add('parent', StructuralEntityType::class, [
'class' => $data['entity_class'],
'required' => false,
'label' => $this->translator->trans('parent.label'),
'label' => 'parent.label',
'disabled' => $disabled, ]);
}
//Buttons
$builder->add('create', SubmitType::class, [
'label' => $this->translator->trans('entity.mass_creation.btn'),
'label' => 'entity.mass_creation.btn',
'disabled' => $disabled,
]);
}

View file

@ -33,20 +33,20 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
$is_new = null === $entity->getID();
$builder->add('is_integer', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('measurement_unit.edit.is_integer'),
'help' => $this->trans->trans('measurement_unit.edit.is_integer.help'),
'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), ]);
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('measurement_unit.edit.use_si_prefix'),
'help' => $this->trans->trans('measurement_unit.edit.use_si_prefix.help'),
'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), ]);
$builder->add('unit', TextType::class, ['required' => false,
'label' => $this->trans->trans('measurement_unit.edit.unit_symbol'),
'attr' => ['placeholder' => $this->trans->trans('measurement_unit.edit.unit_symbol.placeholder')],
'label' => 'measurement_unit.edit.unit_symbol',
'attr' => ['placeholder' => 'measurement_unit.edit.unit_symbol.placeholder'],
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
}
}

View file

@ -35,29 +35,29 @@ class StorelocationAdminForm extends BaseEntityAdminForm
$builder->add('is_full', CheckboxType::class, [
'required' => false,
'label' => $this->trans->trans('storelocation.edit.is_full.label'),
'help' => $this->trans->trans('storelocation.edit.is_full.help'),
'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), ]);
$builder->add('limit_to_existing_parts', CheckboxType::class, [
'required' => false,
'label' => $this->trans->trans('storelocation.limit_to_existing.label'),
'help' => $this->trans->trans('storelocation.limit_to_existing.help'),
'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), ]);
$builder->add('only_single_part', CheckboxType::class, [
'required' => false,
'label' => $this->trans->trans('storelocation.only_single_part.label'),
'help' => $this->trans->trans('storelocation.only_single_part.help'),
'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), ]);
$builder->add('storage_type', StructuralEntityType::class, [
'required' => false,
'label' => $this->trans->trans('storelocation.storage_type.label'),
'help' => $this->trans->trans('storelocation.storage_type.help'),
'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), ]);
}

View file

@ -38,7 +38,7 @@ class SupplierForm extends CompanyForm
$builder->add('default_currency', StructuralEntityType::class, [
'class' => Currency::class,
'required' => false,
'label' => $this->trans->trans('supplier.edit.default_currency'),
'label' => 'supplier.edit.default_currency',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
@ -46,7 +46,7 @@ class SupplierForm extends CompanyForm
'required' => false,
'currency' => $this->params->get('default_currency'),
'scale' => 3,
'label' => $this->trans->trans('supplier.shipping_costs.label'),
'label' => 'supplier.shipping_costs.label',
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity),
]);
}

View file

@ -43,15 +43,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class AttachmentFormType extends AbstractType
{
protected $attachment_helper;
protected $trans;
protected $urlGenerator;
protected $allow_attachments_download;
public function __construct(AttachmentManager $attachmentHelper, TranslatorInterface $trans,
public function __construct(AttachmentManager $attachmentHelper,
UrlGeneratorInterface $urlGenerator, bool $allow_attachments_downloads)
{
$this->attachment_helper = $attachmentHelper;
$this->trans = $trans;
$this->urlGenerator = $urlGenerator;
$this->allow_attachments_download = $allow_attachments_downloads;
}
@ -59,50 +57,50 @@ class AttachmentFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', TextType::class, [
'label' => $this->trans->trans('attachment.edit.name'),
'label' => 'attachment.edit.name',
])
->add('attachment_type', StructuralEntityType::class, [
'label' => $this->trans->trans('attachment.edit.attachment_type'),
'label' => 'attachment.edit.attachment_type',
'class' => AttachmentType::class,
'disable_not_selectable' => true,
'attr' => ['class' => 'attachment_type_selector'],
]);
$builder->add('showInTable', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('attachment.edit.show_in_table'),
'label' => 'attachment.edit.show_in_table',
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom'], ]);
$builder->add('secureFile', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('attachment.edit.secure_file'),
'label' => 'attachment.edit.secure_file',
'mapped' => false,
'attr' => ['class' => 'form-control-sm'],
'help' => $this->trans->trans('attachment.edit.secure_file.help'),
'help' => 'attachment.edit.secure_file.help',
'label_attr' => ['class' => 'checkbox-custom'], ]);
$builder->add('url', TextType::class, [
'label' => $this->trans->trans('attachment.edit.url'),
'label' => 'attachment.edit.url',
'required' => false,
'attr' => [
'data-autocomplete' => $this->urlGenerator->generate('typeahead_builtInRessources', ['query' => 'QUERY']),
//Disable browser autocomplete
'autocomplete' => 'off',
],
'help' => $this->trans->trans('attachment.edit.url.help'),
'help' => 'attachment.edit.url.help',
'constraints' => [
$options['allow_builtins'] ? new UrlOrBuiltin() : new Url(),
],
]);
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('attachment.edit.download_url'),
'label' => 'attachment.edit.download_url',
'mapped' => false,
'disabled' => !$this->allow_attachments_download,
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom'], ]);
$builder->add('file', FileType::class, [
'label' => $this->trans->trans('attachment.edit.file'),
'label' => 'attachment.edit.file',
'mapped' => false,
'required' => false,
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],

View file

@ -40,12 +40,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class OrderdetailType extends AbstractType
{
protected $trans;
protected $security;
public function __construct(TranslatorInterface $trans, Security $security)
public function __construct( Security $security)
{
$this->trans = $trans;
$this->security = $security;
}
@ -55,27 +53,27 @@ class OrderdetailType extends AbstractType
$orderdetail = $builder->getData();
$builder->add('supplierpartnr', TextType::class, [
'label' => $this->trans->trans('orderdetails.edit.supplierpartnr'),
'attr' => ['placeholder' => $this->trans->trans('orderdetails.edit.supplierpartnr.placeholder')],
'label' => 'orderdetails.edit.supplierpartnr',
'attr' => ['placeholder' => 'orderdetails.edit.supplierpartnr.placeholder'],
'required' => false,
'empty_data' => '',
]);
$builder->add('supplier', StructuralEntityType::class, [
'class' => Supplier::class, 'disable_not_selectable' => true,
'label' => $this->trans->trans('orderdetails.edit.supplier'),
'label' => 'orderdetails.edit.supplier',
]);
$builder->add('supplier_product_url', UrlType::class, [
'required' => false,
'empty_data' => '',
'label' => $this->trans->trans('orderdetails.edit.url'),
'label' => 'orderdetails.edit.url',
]);
$builder->add('obsolete', CheckboxType::class, [
'required' => false,
'label_attr' => ['class' => 'checkbox-custom'],
'label' => $this->trans->trans('orderdetails.edit.obsolete'),
'label' => 'orderdetails.edit.obsolete',
]);
//Add pricedetails after we know the data, so we can set the default currency

View file

@ -54,10 +54,9 @@ class PartBaseType extends AbstractType
protected $trans;
protected $urlGenerator;
public function __construct(Security $security, TranslatorInterface $trans, UrlGeneratorInterface $urlGenerator)
public function __construct(Security $security, UrlGeneratorInterface $urlGenerator)
{
$this->security = $security;
$this->trans = $trans;
$this->urlGenerator = $urlGenerator;
}
@ -67,52 +66,52 @@ class PartBaseType extends AbstractType
$part = $builder->getData();
$status_choices = [
$this->trans->trans('m_status.unknown') => '',
$this->trans->trans('m_status.announced') => 'announced',
$this->trans->trans('m_status.active') => 'active',
$this->trans->trans('m_status.nrfnd') => 'nrfnd',
$this->trans->trans('m_status.eol') => 'eol',
$this->trans->trans('m_status.discontinued') => 'discontinued',
'm_status.unknown' => '',
'm_status.announced' => 'announced',
'm_status.active' => 'active',
'm_status.nrfnd' => 'nrfnd',
'm_status.eol' => 'eol',
'm_status.discontinued' => 'discontinued',
];
//Common section
$builder
->add('name', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('part.edit.name'),
'attr' => ['placeholder' => $this->trans->trans('part.edit.name.placeholder')],
'label' => 'part.edit.name',
'attr' => ['placeholder' => 'part.edit.name.placeholder'],
'disabled' => !$this->security->isGranted('name.edit', $part),
])
->add('description', CKEditorType::class, [
'required' => false,
'empty_data' => '',
'label' => $this->trans->trans('part.edit.description'),
'label' => 'part.edit.description',
'config_name' => 'description_config',
'attr' => ['placeholder' => $this->trans->trans('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' => $this->trans->trans('part.editmininstock.placeholder')],
'label' => $this->trans->trans('part.edit.mininstock'),
'attr' => ['min' => 0, 'placeholder' => 'part.editmininstock.placeholder'],
'label' => 'part.edit.mininstock',
'measurement_unit' => $part->getPartUnit(),
'disabled' => !$this->security->isGranted('minamount.edit', $part),
])
->add('category', StructuralEntityType::class, [
'class' => Category::class,
'label' => $this->trans->trans('part.edit.category'),
'label' => 'part.edit.category',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('category.edit', $part),
])
->add('footprint', StructuralEntityType::class, [
'class' => Footprint::class,
'required' => false,
'label' => $this->trans->trans('part.edit.footprint'),
'label' => 'part.edit.footprint',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('footprint.edit', $part),
])
->add('tags', TextType::class, [
'required' => false,
'label' => $this->trans->trans('part.edit.tags'),
'label' => 'part.edit.tags',
'empty_data' => '',
'attr' => [
'class' => 'tagsinput',
@ -124,23 +123,23 @@ class PartBaseType extends AbstractType
$builder->add('manufacturer', StructuralEntityType::class, [
'class' => Manufacturer::class,
'required' => false,
'label' => $this->trans->trans('part.edit.manufacturer.label'),
'label' => 'part.edit.manufacturer.label',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('manufacturer.edit', $part),
])
->add('manufacturer_product_url', UrlType::class, [
'required' => false,
'empty_data' => '',
'label' => $this->trans->trans('part.edit.manufacturer_url.label'),
'label' => 'part.edit.manufacturer_url.label',
'disabled' => !$this->security->isGranted('mpn.edit', $part),
])
->add('manufacturer_product_number', TextType::class, [
'required' => false,
'empty_data' => '',
'label' => $this->trans->trans('part.edit.mpn'),
'label' => 'part.edit.mpn',
'disabled' => !$this->security->isGranted('mpn.edit', $part), ])
->add('manufacturing_status', ChoiceType::class, [
'label' => $this->trans->trans('part.edit.manufacturing_status'),
'label' => 'part.edit.manufacturing_status',
'choices' => $status_choices,
'required' => false,
'disabled' => !$this->security->isGranted('status.edit', $part),
@ -150,18 +149,18 @@ class PartBaseType extends AbstractType
$builder->add('needsReview', CheckboxType::class, [
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => $this->trans->trans('part.edit.needs_review'),
'label' => 'part.edit.needs_review',
'disabled' => !$this->security->isGranted('edit', $part),
])
->add('favorite', CheckboxType::class, [
'label_attr' => ['class' => 'checkbox-custom'],
'required' => false,
'label' => $this->trans->trans('part.edit.is_favorite'),
'label' => 'part.edit.is_favorite',
'disabled' => !$this->security->isGranted('change_favorite', $part),
])
->add('mass', SIUnitType::class, [
'unit' => 'g',
'label' => $this->trans->trans('part.edit.mass'),
'label' => 'part.edit.mass',
'required' => false,
'disabled' => !$this->security->isGranted('mass.edit', $part),
])
@ -169,14 +168,14 @@ class PartBaseType extends AbstractType
'class' => MeasurementUnit::class,
'required' => false,
'disable_not_selectable' => true,
'label' => $this->trans->trans('part.edit.partUnit'),
'label' => 'part.edit.partUnit',
'disabled' => !$this->security->isGranted('unit.edit', $part),
]);
//Comment section
$builder->add('comment', CKEditorType::class, [
'required' => false,
'label' => $this->trans->trans('part.edit.comment'),
'label' => 'part.edit.comment',
'attr' => ['rows' => 4],
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => '',
]);
@ -210,7 +209,7 @@ class PartBaseType extends AbstractType
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
'required' => false,
'disabled' => !$this->security->isGranted('attachments.edit', $part),
'label' => $this->trans->trans('part.edit.master_attachment'),
'label' => 'part.edit.master_attachment',
'entity' => $part,
]);
@ -230,8 +229,8 @@ class PartBaseType extends AbstractType
$builder
//Buttons
->add('save', SubmitType::class, ['label' => $this->trans->trans('part.edit.save')])
->add('reset', ResetType::class, ['label' => $this->trans->trans('part.edit.reset')]);
->add('save', SubmitType::class, ['label' => 'part.edit.save'])
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
}
public function configureOptions(OptionsResolver $resolver)

View file

@ -37,26 +37,24 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class PartLotType extends AbstractType
{
protected $trans;
protected $security;
public function __construct(TranslatorInterface $trans, Security $security)
public function __construct(Security $security)
{
$this->trans = $trans;
$this->security = $security;
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('description', TextType::class, [
'label' => $this->trans->trans('part_lot.edit.description'),
'label' => 'part_lot.edit.description',
'required' => false,
'empty_data' => '',
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class,
'label' => $this->trans->trans('part_lot.edit.location'),
'label' => 'part_lot.edit.location',
'required' => false,
'disable_not_selectable' => true,
'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true],
@ -64,29 +62,29 @@ class PartLotType extends AbstractType
$builder->add('amount', SIUnitType::class, [
'measurement_unit' => $options['measurement_unit'],
'label' => $this->trans->trans('part_lot.edit.amount'),
'label' => 'part_lot.edit.amount',
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add('instock_unknown', CheckboxType::class, ['required' => false,
'label' => $this->trans->trans('part_lot.edit.instock_unknown'),
'label' => 'part_lot.edit.instock_unknown',
'attr' => ['class' => 'form-control-sm'],
'label_attr' => ['class' => 'checkbox-custom'],
]);
$builder->add('needs_refill', CheckboxType::class, ['label_attr' => ['class' => 'checkbox-custom'],
'label' => $this->trans->trans('part_lot.edit.needs_refill'),
'label' => 'part_lot.edit.needs_refill',
'attr' => ['class' => 'form-control-sm'],
'required' => false,
]);
$builder->add('expirationDate', DateTimeType::class, [
'label' => $this->trans->trans('part_lot.edit.expiration_date'),
'label' => 'part_lot.edit.expiration_date',
'attr' => [],
'required' => false, ]);
$builder->add('comment', TextType::class, [
'label' => $this->trans->trans('part_lot.edit.comment'),
'label' => 'part_lot.edit.comment',
'attr' => ['class' => 'form-control-sm'],
'required' => false, 'empty_data' => '',
]);

View file

@ -36,14 +36,17 @@ class PricedetailType extends AbstractType
{
//No labels needed, we define translation in templates
$builder->add('min_discount_quantity', SIUnitType::class, [
'label' => false,
'measurement_unit' => $options['measurement_unit'],
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add('price_related_quantity', SIUnitType::class, [
'label' => false,
'measurement_unit' => $options['measurement_unit'],
'attr' => ['class' => 'form-control-sm'],
]);
$builder->add('price', NumberType::class, [
'label' => false,
'scale' => 5,
'html5' => true,
'attr' => ['min' => 0, 'step' => 'any'],

View file

@ -102,6 +102,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
{
$builder
->add('value', NumberType::class, [
'label' => false,
'html5' => $options['html5'],
'attr' => [
'min' => (string) $options['min'],
@ -112,6 +113,7 @@ 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],
]);
}

View file

@ -49,12 +49,10 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class UserAdminForm extends AbstractType
{
protected $security;
protected $trans;
public function __construct(Security $security, TranslatorInterface $trans)
public function __construct(Security $security)
{
$this->security = $security;
$this->trans = $trans;
}
public function configureOptions(OptionsResolver $resolver)
@ -72,44 +70,44 @@ class UserAdminForm extends AbstractType
$builder
->add('name', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('user.username.label'),
'attr' => ['placeholder' => $this->trans->trans('user.username.placeholder')],
'label' => 'user.username.label',
'attr' => ['placeholder' => 'user.username.placeholder'],
'disabled' => !$this->security->isGranted('edit_username', $entity),
])
->add('group', StructuralEntityType::class, [
'class' => Group::class,
'required' => false,
'label' => $this->trans->trans('group.label'),
'label' => 'group.label',
'disable_not_selectable' => true,
'disabled' => !$this->security->isGranted('change_group', $entity), ])
->add('first_name', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('user.firstName.label'),
'attr' => ['placeholder' => $this->trans->trans('user.firstName.placeholder')], 'required' => false,
'label' => 'user.firstName.label',
'attr' => ['placeholder' => 'user.firstName.placeholder'], 'required' => false,
'disabled' => !$this->security->isGranted('edit_infos', $entity),
])
->add('last_name', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('user.lastName.label'),
'attr' => ['placeholder' => $this->trans->trans('user.lastName.placeholder')],
'label' => 'user.lastName.label',
'attr' => ['placeholder' => 'user.lastName.placeholder'],
'required' => false,
'disabled' => !$this->security->isGranted('edit_infos', $entity),
])
->add('email', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('user.email.label'),
'attr' => ['placeholder' => $this->trans->trans('user.email.placeholder')],
'label' => 'user.email.label',
'attr' => ['placeholder' => 'user.email.placeholder'],
'required' => false,
'disabled' => !$this->security->isGranted('edit_infos', $entity), ])
->add('department', TextType::class, [
'empty_data' => '',
'label' => $this->trans->trans('user.department.label'),
'attr' => ['placeholder' => $this->trans->trans('user.department.placeholder')],
'label' => 'user.department.label',
'attr' => ['placeholder' => 'user.department.placeholder'],
'required' => false,
'disabled' => !$this->security->isGranted('edit_infos', $entity),
])
@ -118,16 +116,16 @@ class UserAdminForm extends AbstractType
->add('language', LanguageType::class, [
'required' => false,
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
'placeholder' => $this->trans->trans('user_settings.language.placeholder'),
'label' => $this->trans->trans('user.language_select'),
'placeholder' => 'user_settings.language.placeholder',
'label' => 'user.language_select',
'preferred_choices' => ['en', 'de'],
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
])
->add('timezone', TimezoneType::class, [
'required' => false,
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
'placeholder' => $this->trans->trans('user_settings.timezone.placeholder'),
'label' => $this->trans->trans('user.timezone.label'),
'placeholder' => 'user_settings.timezone.placeholder',
'label' => 'user.timezone.label',
'preferred_choices' => ['Europe/Berlin'],
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
])
@ -138,20 +136,20 @@ class UserAdminForm extends AbstractType
return $value;
},
'attr' => ['class' => 'selectpicker'],
'placeholder' => $this->trans->trans('user_settings.theme.placeholder'),
'label' => $this->trans->trans('user.theme.label'),
'placeholder' => 'user_settings.theme.placeholder',
'label' => 'user.theme.label',
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
])
->add('currency', CurrencyEntityType::class, [
'required' => false,
'label' => $this->trans->trans('user.currency.label'),
'label' => 'user.currency.label',
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
])
->add('new_password', RepeatedType::class, [
'type' => PasswordType::class,
'first_options' => ['label' => $this->trans->trans('user.settings.pw_new.label')],
'second_options' => ['label' => $this->trans->trans('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,
@ -165,14 +163,14 @@ class UserAdminForm extends AbstractType
->add('need_pw_change', CheckboxType::class, [
'required' => false,
'label_attr' => ['class' => 'checkbox-custom'],
'label' => $this->trans->trans('user.edit.needs_pw_change'),
'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' => $this->trans->trans('user.edit.user_disabled'),
'label' => 'user.edit.user_disabled',
'disabled' => !$this->security->isGranted('set_password', $entity)
|| $entity === $this->security->getUser(),
])
@ -205,11 +203,11 @@ class UserAdminForm extends AbstractType
//Buttons
$builder->add('save', SubmitType::class, [
'label' => $is_new ? $this->trans->trans('user.create') : $this->trans->trans('user.edit.save'),
'label' => $is_new ? 'user.create' : 'user.edit.save',
'attr' => ['class' => $is_new ? 'btn-success' : ''],
])
->add('reset', ResetType::class, [
'label' => $this->trans->trans('entity.edit.reset'),
'label' => 'entity.edit.reset',
]);
}

View file

@ -39,15 +39,11 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class UserSettingsType extends AbstractType
{
protected $security;
protected $trans;
protected $demo_mode;
public function __construct(Security $security, TranslatorInterface $trans, bool $demo_mode)
public function __construct(Security $security, bool $demo_mode)
{
$this->security = $security;
$this->trans = $trans;
$this->demo_mode = $demo_mode;
}
@ -55,43 +51,43 @@ class UserSettingsType extends AbstractType
{
$builder
->add('name', TextType::class, [
'label' => $this->trans->trans('user.username.label'),
'label' => 'user.username.label',
'disabled' => !$this->security->isGranted('edit_username', $options['data']) || $this->demo_mode,
])
->add('first_name', TextType::class, [
'required' => false,
'label' => $this->trans->trans('user.firstName.label'),
'label' => 'user.firstName.label',
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('last_name', TextType::class, [
'required' => false,
'label' => $this->trans->trans('user.lastName.label'),
'label' => 'user.lastName.label',
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('department', TextType::class, [
'required' => false,
'label' => $this->trans->trans('user.department.label'),
'label' => 'user.department.label',
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('email', EmailType::class, [
'required' => false,
'label' => $this->trans->trans('user.email.label'),
'label' => 'user.email.label',
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
])
->add('language', LanguageType::class, [
'disabled' => $this->demo_mode,
'required' => false,
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
'placeholder' => $this->trans->trans('user_settings.language.placeholder'),
'label' => $this->trans->trans('user.language_select'),
'placeholder' => 'user_settings.language.placeholder',
'label' => 'user.language_select',
'preferred_choices' => ['en', 'de'],
])
->add('timezone', TimezoneType::class, [
'disabled' => $this->demo_mode,
'required' => false,
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
'placeholder' => $this->trans->trans('user_settings.timezone.placeholder'),
'label' => $this->trans->trans('user.timezone.label'),
'placeholder' => 'user_settings.timezone.placeholder',
'label' => 'user.timezone.label',
'preferred_choices' => ['Europe/Berlin'],
])
->add('theme', ChoiceType::class, [
@ -102,13 +98,13 @@ class UserSettingsType extends AbstractType
'choice_label' => function ($entity, $key, $value) {
return $value;
},
'placeholder' => $this->trans->trans('user_settings.theme.placeholder'),
'label' => $this->trans->trans('user.theme.label'),
'placeholder' => 'user_settings.theme.placeholder',
'label' => 'user.theme.label',
])
->add('currency', CurrencyEntityType::class, [
'disabled' => $this->demo_mode,
'required' => false,
'label' => $this->trans->trans('user.currency.label'),
'label' => 'user.currency.label',
])
//Buttons

View file

@ -52,7 +52,7 @@ class GitVersionInfo
/**
* Get hash of the last git commit (on remote "origin"!).
*
* @note If this method does not work, try to make a "git pull" first!
* If this method does not work, try to make a "git pull" first!
*
* @param int $length if this is smaller than 40, only the first $length characters will be returned
*

View file

@ -23,7 +23,7 @@
</button>
</div>
<div class="toast-body {{ flash_bg }}">
{{ message}}
{{ message | trans}}
</div>
</div>
{% endfor %}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,6 @@
<note category="file-source" priority="1">src\Entity\PriceInformations\Currency.php:0</note>
<note category="file-source" priority="1">src\Entity\UserSystem\Group.php:0</note>
<note category="file-source" priority="1">src\Entity\UserSystem\User.php:0</note>
<note category="state" priority="1">new</note>
</notes>
<segment>
<source>part.master_attachment.must_be_picture</source>
@ -62,7 +61,6 @@
<unit id="isXL.ie" name="validator.user.username_already_used">
<notes>
<note category="file-source" priority="1">src\Entity\UserSystem\User.php:0</note>
<note category="state" priority="1">new</note>
</notes>
<segment>
<source>validator.user.username_already_used</source>