mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 20:35:08 +02:00
Added an PHP CS fixer config file and applied it to files.
We now use the same the same style as the symfony project, and it allows us to simply fix the style by executing php_cs_fixer fix in the project root.
This commit is contained in:
parent
89258bc102
commit
e557bdedd5
210 changed files with 2099 additions and 2742 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,18 +17,14 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Services\Attachments\FileTypeFilterTools;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
@ -46,14 +42,14 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$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'),
|
||||
'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')],
|
||||
'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(
|
||||
|
@ -65,4 +61,4 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,24 +17,17 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\FootprintAttachment;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Form\AttachmentFormType;
|
||||
use App\Form\Type\MasterPictureAttachmentType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
@ -45,12 +38,10 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Translation\Reader\TranslationReader;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class BaseEntityAdminForm extends AbstractType
|
||||
{
|
||||
|
||||
protected $security;
|
||||
protected $params;
|
||||
protected $trans;
|
||||
|
@ -72,27 +63,27 @@ class BaseEntityAdminForm extends AbstractType
|
|||
{
|
||||
/** @var StructuralDBElement $entity */
|
||||
$entity = $options['data'];
|
||||
$is_new = $entity->getID() === null;
|
||||
$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')],
|
||||
'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'),
|
||||
->add('parent', StructuralEntityType::class, ['class' => \get_class($entity),
|
||||
'required' => false, 'label' => $this->trans->trans('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' => $this->trans->trans('entity.edit.not_selectable'),
|
||||
'help' => $this->trans->trans('entity.edit.not_selectable.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity) ])
|
||||
'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'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'label' => $this->trans->trans('comment.label'),
|
||||
'attr' => ['rows' => 4], 'help' => $this->trans->trans('bbcode.hint'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$this->additionalFormElements($builder, $options, $entity);
|
||||
|
||||
|
@ -106,27 +97,27 @@ class BaseEntityAdminForm extends AbstractType
|
|||
'entry_options' => [
|
||||
'data_class' => $options['attachment_class'],
|
||||
],
|
||||
'by_reference' => false
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
||||
$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'),
|
||||
'entity' => $entity
|
||||
'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 ? $this->trans->trans('entity.create') : $this->trans->trans('entity.edit.save'),
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : ''],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)])
|
||||
'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)]);
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
//Empty for Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,14 +17,11 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -33,50 +30,50 @@ class CategoryAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$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' => $this->trans->trans('category.edit.disable_footprints'),
|
||||
'help' => $this->trans->trans('category.edit.disable_footprints.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'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_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'label' => $this->trans->trans('category.edit.disable_manufacturers'),
|
||||
'help' => $this->trans->trans('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_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'label' => $this->trans->trans('category.edit.disable_autodatasheets'),
|
||||
'help' => $this->trans->trans('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_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'label' => $this->trans->trans('category.edit.disable_properties'),
|
||||
'help' => $this->trans->trans('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')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'label' => $this->trans->trans('category.edit.partname_hint'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('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'),
|
||||
'attr' => ['placeholder' => 'category.edit.partname_regex.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'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'),
|
||||
'label' => $this->trans->trans('category.edit.default_description'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('category.edit.default_description.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'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'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('category.edit.default_comment.placeholder')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,19 +17,14 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
|
@ -37,13 +32,13 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('address', TextareaType::class, [
|
||||
'label' => $this->trans->trans('company.edit.address'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.address.placeholder')], 'required' => false,
|
||||
'empty_data' => ''
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('phone_number', TelType::class, [
|
||||
|
@ -51,28 +46,28 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.phone_number.placeholder')],
|
||||
'required' => false,
|
||||
'empty_data' => ''
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('fax_number', TelType::class, [
|
||||
'label' => $this->trans->trans('company.edit.fax_number'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
|
||||
'empty_data' => ''
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('email_address', EmailType::class, [
|
||||
'label' => $this->trans->trans('company.edit.email'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.email.placeholder')], 'required' => false,
|
||||
'empty_data' => ''
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('website', UrlType::class, [
|
||||
'label' => $this->trans->trans('company.edit.website'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.website.placeholder')], 'required' => false,
|
||||
'empty_data' => ''
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('auto_product_url', UrlType::class, [
|
||||
|
@ -81,7 +76,7 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => $this->trans->trans('company.edit.auto_product_url.placeholder')],
|
||||
'required' => false,
|
||||
'empty_data' => ''
|
||||
'empty_data' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,14 +17,11 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -33,20 +30,20 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('iso_code', CurrencyType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('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)]);
|
||||
'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'),
|
||||
'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), ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Form\Type\MasterPictureAttachmentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -33,10 +31,10 @@ class FootprintAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
$builder->add('footprint_3d', MasterPictureAttachmentType::class, [
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted($entity->getID() === null ? 'create' : 'edit', $entity),
|
||||
'disabled' => !$this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
|
||||
'label' => $this->trans->trans('footprint.edit.3d_model'),
|
||||
'filter' => '3d_model',
|
||||
'entity' => $entity
|
||||
'entity' => $entity,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Form\Permissions\PermissionsType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -34,7 +32,7 @@ class GroupAdminForm extends BaseEntityAdminForm
|
|||
$builder->add('permissions', PermissionsType::class, [
|
||||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => !$this->security->isGranted('edit_permissions', $entity)
|
||||
'disabled' => !$this->security->isGranted('edit_permissions', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,16 +17,12 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Bundle\MakerBundle\Str;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
@ -39,7 +35,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class ImportType extends AbstractType
|
||||
{
|
||||
|
||||
protected $security;
|
||||
protected $trans;
|
||||
|
||||
|
@ -51,48 +46,47 @@ class ImportType extends AbstractType
|
|||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
$data = $options['data'];
|
||||
|
||||
//Disable import if user is not allowed to create elements.
|
||||
$entity = new $data['entity_class']();
|
||||
$perm_name = "create";
|
||||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
$perm_name = 'create';
|
||||
$disabled = !$this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
|
||||
->add('format', ChoiceType::class, [
|
||||
'choices' => ['JSON' => 'json', 'XML' => 'xml','CSV' => 'csv' ,'YAML' => 'yaml'],
|
||||
'choices' => ['JSON' => 'json', 'XML' => 'xml', 'CSV' => 'csv', 'YAML' => 'yaml'],
|
||||
'label' => $this->trans->trans('export.format'),
|
||||
'disabled' => $disabled])
|
||||
'disabled' => $disabled, ])
|
||||
->add('csv_separator', TextType::class, ['data' => ';',
|
||||
'label' => $this->trans->trans('import.csv_separator'),
|
||||
'disabled' => $disabled]);
|
||||
'disabled' => $disabled, ]);
|
||||
|
||||
if ($entity instanceof StructuralDBElement) {
|
||||
$builder->add('parent', StructuralEntityType::class, [
|
||||
'class' => $data['entity_class'],
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('parent.label'),
|
||||
'disabled' => $disabled
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
}
|
||||
|
||||
$builder->add('file', FileType::class, [
|
||||
'label' => $this->trans->trans('import.file'),
|
||||
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],
|
||||
'disabled' => $disabled
|
||||
'disabled' => $disabled,
|
||||
])
|
||||
|
||||
->add('preserve_children', CheckboxType::class, ['data' => true, 'required' => false,
|
||||
'label' => $this->trans->trans('import.preserve_children'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled])
|
||||
'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_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled])
|
||||
'label_attr' => ['class' => 'checkbox-custom'], 'disabled' => $disabled, ])
|
||||
|
||||
//Buttons
|
||||
->add('import', SubmitType::class, ['label' => 'import.btn', 'disabled' => $disabled]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,22 +17,15 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -50,13 +43,12 @@ class MassCreationForm extends AbstractType
|
|||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
$data = $options['data'];
|
||||
|
||||
//Disable import if user is not allowed to create elements.
|
||||
$entity = new $data['entity_class']();
|
||||
$perm_name = "create";
|
||||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
$perm_name = 'create';
|
||||
$disabled = !$this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
->add('lines', TextareaType::class, ['data' => '',
|
||||
|
@ -64,21 +56,21 @@ class MassCreationForm extends AbstractType
|
|||
'disabled' => $disabled, 'required' => true,
|
||||
'attr' => [
|
||||
'placeholder' => $this->translator->trans('mass_creation.lines.placeholder'),
|
||||
'rows' => 10
|
||||
]
|
||||
'rows' => 10,
|
||||
],
|
||||
]);
|
||||
if ($entity instanceof StructuralDBElement) {
|
||||
$builder->add('parent', StructuralEntityType::class, [
|
||||
'class' => $data['entity_class'],
|
||||
'required' => false,
|
||||
'label' => $this->translator->trans('parent.label'),
|
||||
'disabled' => $disabled]);
|
||||
'disabled' => $disabled, ]);
|
||||
}
|
||||
|
||||
//Buttons
|
||||
$builder->add('create', SubmitType::class, [
|
||||
'label' => $this->translator->trans('entity.mass_creation.btn'),
|
||||
'disabled' => $disabled
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,14 +17,11 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -33,23 +30,23 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('is_integer', CheckboxType::class, ['required' => false,
|
||||
'label' => $this->trans->trans('measurement_unit.edit.is_integer'),
|
||||
'label' => $this->trans->trans('measurement_unit.edit.is_integer'),
|
||||
'help' => $this->trans->trans('measurement_unit.edit.is_integer.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'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_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'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')],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,53 +17,48 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class StorelocationAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$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_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
'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_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
'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_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
'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'),
|
||||
'class' => MeasurementUnit::class, 'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)]);
|
||||
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,34 +17,23 @@
|
|||
* 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\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class SupplierForm extends CompanyForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
parent::additionalFormElements($builder, $options, $entity);
|
||||
parent::additionalFormElements($builder, $options, $entity);
|
||||
|
||||
$builder->add('default_currency', StructuralEntityType::class, [
|
||||
'class' => Currency::class,
|
||||
|
@ -58,7 +47,7 @@ class SupplierForm extends CompanyForm
|
|||
'currency' => $this->params->get('default_currency'),
|
||||
'scale' => 3,
|
||||
'label' => $this->trans->trans('supplier.shipping_costs.label'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity)
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,15 +17,12 @@
|
|||
* 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\Form;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use App\Services\Attachments\AttachmentManager;
|
||||
use App\Validator\Constraints\AllowedFileExtension;
|
||||
|
@ -34,13 +31,11 @@ use Symfony\Component\Form\AbstractType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Validator\Constraints\File;
|
||||
use Symfony\Component\Validator\Constraints\Url;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -64,60 +59,59 @@ class AttachmentFormType extends AbstractType
|
|||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('name', TextType::class, [
|
||||
'label' => $this->trans->trans('attachment.edit.name')
|
||||
'label' => $this->trans->trans('attachment.edit.name'),
|
||||
])
|
||||
->add('attachment_type', StructuralEntityType::class, [
|
||||
'label' => $this->trans->trans('attachment.edit.attachment_type'),
|
||||
'label' => $this->trans->trans('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,
|
||||
'label' => $this->trans->trans('attachment.edit.show_in_table'),
|
||||
'label' => $this->trans->trans('attachment.edit.show_in_table'),
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom']]);
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
|
||||
$builder->add('secureFile', CheckboxType::class, ['required' => false,
|
||||
'label' => $this->trans->trans('attachment.edit.secure_file'),
|
||||
'label' => $this->trans->trans('attachment.edit.secure_file'),
|
||||
'mapped' => false,
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'help' => $this->trans->trans('attachment.edit.secure_file.help'),
|
||||
'label_attr' => ['class' => 'checkbox-custom']]);
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
|
||||
$builder->add('url', TextType::class, [
|
||||
'label' => $this->trans->trans('attachment.edit.url'),
|
||||
'label' => $this->trans->trans('attachment.edit.url'),
|
||||
'required' => false,
|
||||
'attr' => [
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_builtInRessources', ['query' => 'QUERY']),
|
||||
//Disable browser autocomplete
|
||||
'autocomplete' => 'off'
|
||||
'autocomplete' => 'off',
|
||||
],
|
||||
'help' => $this->trans->trans('attachment.edit.url.help'),
|
||||
'constraints' => [
|
||||
$options['allow_builtins'] ? new UrlOrBuiltin() : new Url()
|
||||
]
|
||||
$options['allow_builtins'] ? new UrlOrBuiltin() : new Url(),
|
||||
],
|
||||
]);
|
||||
|
||||
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
|
||||
'label' => $this->trans->trans('attachment.edit.download_url'),
|
||||
'label' => $this->trans->trans('attachment.edit.download_url'),
|
||||
'mapped' => false,
|
||||
'disabled' => !$this->allow_attachments_download,
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom']]);
|
||||
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
|
||||
$builder->add('file', FileType::class, [
|
||||
'label' => $this->trans->trans('attachment.edit.file'),
|
||||
'label' => $this->trans->trans('attachment.edit.file'),
|
||||
'mapped' => false,
|
||||
'required' => false,
|
||||
'attr' => ['class' => 'file', 'data-show-preview' => 'false', 'data-show-upload' => 'false'],
|
||||
'constraints' => [
|
||||
new AllowedFileExtension(),
|
||||
new File([
|
||||
'maxSize' => $options['max_file_size']
|
||||
'maxSize' => $options['max_file_size'],
|
||||
]),
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
//Check the secure file checkbox, if file is in securefile location
|
||||
|
@ -137,8 +131,7 @@ class AttachmentFormType extends AbstractType
|
|||
$resolver->setDefaults([
|
||||
'data_class' => Attachment::class,
|
||||
'max_file_size' => '16M',
|
||||
'allow_builtins' => true
|
||||
'allow_builtins' => true,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* 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\Form\Part;
|
||||
|
@ -38,7 +37,6 @@ use Symfony\Component\Form\FormEvents;
|
|||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function foo\func;
|
||||
|
||||
class OrderdetailType extends AbstractType
|
||||
{
|
||||
|
@ -58,36 +56,35 @@ class OrderdetailType extends AbstractType
|
|||
|
||||
$builder->add('supplierpartnr', TextType::class, [
|
||||
'label' => $this->trans->trans('orderdetails.edit.supplierpartnr'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('orderdetails.edit.supplierpartnr.placeholder')],
|
||||
'attr' => ['placeholder' => $this->trans->trans('orderdetails.edit.supplierpartnr.placeholder')],
|
||||
'required' => false,
|
||||
'empty_data' => ""
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('supplier', StructuralEntityType::class, [
|
||||
'class' => Supplier::class, 'disable_not_selectable' => true,
|
||||
'label' => $this->trans->trans('orderdetails.edit.supplier')
|
||||
'label' => $this->trans->trans('orderdetails.edit.supplier'),
|
||||
]);
|
||||
|
||||
$builder->add('supplier_product_url', UrlType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => "",
|
||||
'label' => $this->trans->trans('orderdetails.edit.url')
|
||||
'empty_data' => '',
|
||||
'label' => $this->trans->trans('orderdetails.edit.url'),
|
||||
]);
|
||||
|
||||
$builder->add('obsolete', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('orderdetails.edit.obsolete')
|
||||
'label' => $this->trans->trans('orderdetails.edit.obsolete'),
|
||||
]);
|
||||
|
||||
|
||||
//Add pricedetails after we know the data, so we can set the default currency
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
||||
/** @var Orderdetail $orderdetail */
|
||||
$orderdetail = $event->getData();
|
||||
|
||||
$dummy_pricedetail = new Pricedetail();
|
||||
if ($orderdetail !== null && $orderdetail->getSupplier() !== null) {
|
||||
if (null !== $orderdetail && null !== $orderdetail->getSupplier()) {
|
||||
$dummy_pricedetail->setCurrency($orderdetail->getSupplier()->getDefaultCurrency());
|
||||
}
|
||||
|
||||
|
@ -101,10 +98,9 @@ class OrderdetailType extends AbstractType
|
|||
'by_reference' => false,
|
||||
'entry_options' => [
|
||||
'disabled' => !$this->security->isGranted('@parts_prices.edit'),
|
||||
'measurement_unit' => $options['measurement_unit']
|
||||
]
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
],
|
||||
]);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -118,4 +114,4 @@ class OrderdetailType extends AbstractType
|
|||
$resolver->setRequired('measurement_unit');
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,7 +17,6 @@
|
|||
* 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\Form\Part;
|
||||
|
@ -29,32 +28,25 @@ use App\Entity\Parts\Footprint;
|
|||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Form\AttachmentFormType;
|
||||
use App\Form\Type\MasterPictureAttachmentType;
|
||||
use App\Form\Type\SIUnitType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Doctrine\DBAL\Types\FloatType;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function foo\func;
|
||||
|
||||
class PartBaseType extends AbstractType
|
||||
{
|
||||
|
@ -75,19 +67,19 @@ class PartBaseType extends AbstractType
|
|||
$part = $builder->getData();
|
||||
|
||||
$status_choices = [
|
||||
$this->trans->trans("m_status.unknown") => '',
|
||||
$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'
|
||||
$this->trans->trans('m_status.discontinued') => 'discontinued',
|
||||
];
|
||||
|
||||
//Common section
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => $this->trans->trans('part.edit.name'),
|
||||
'label' => $this->trans->trans('part.edit.name'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('part.edit.name.placeholder')],
|
||||
'disabled' => !$this->security->isGranted('name.edit', $part),
|
||||
])
|
||||
|
@ -97,7 +89,7 @@ class PartBaseType extends AbstractType
|
|||
'label' => $this->trans->trans('part.edit.description'),
|
||||
'config_name' => 'description_config',
|
||||
'attr' => ['placeholder' => $this->trans->trans('part.edit.description.placeholder'), 'rows' => 2],
|
||||
'disabled' => !$this->security->isGranted('description.edit', $part)
|
||||
'disabled' => !$this->security->isGranted('description.edit', $part),
|
||||
])
|
||||
->add('minAmount', SIUnitType::class, [
|
||||
'attr' => ['min' => 0, 'placeholder' => $this->trans->trans('part.editmininstock.placeholder')],
|
||||
|
@ -121,11 +113,11 @@ class PartBaseType extends AbstractType
|
|||
->add('tags', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('part.edit.tags'),
|
||||
'empty_data' => "",
|
||||
'empty_data' => '',
|
||||
'attr' => [
|
||||
'class' => 'tagsinput',
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']),],
|
||||
'disabled' => !$this->security->isGranted('tags.edit', $part)
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']), ],
|
||||
'disabled' => !$this->security->isGranted('tags.edit', $part),
|
||||
]);
|
||||
|
||||
//Manufacturer section
|
||||
|
@ -134,7 +126,7 @@ class PartBaseType extends AbstractType
|
|||
'required' => false,
|
||||
'label' => $this->trans->trans('part.edit.manufacturer.label'),
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted('manufacturer.edit', $part)
|
||||
'disabled' => !$this->security->isGranted('manufacturer.edit', $part),
|
||||
])
|
||||
->add('manufacturer_product_url', UrlType::class, [
|
||||
'required' => false,
|
||||
|
@ -146,12 +138,12 @@ class PartBaseType extends AbstractType
|
|||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => $this->trans->trans('part.edit.mpn'),
|
||||
'disabled' => !$this->security->isGranted('mpn.edit', $part)])
|
||||
'disabled' => !$this->security->isGranted('mpn.edit', $part), ])
|
||||
->add('manufacturing_status', ChoiceType::class, [
|
||||
'label' => $this->trans->trans('part.edit.manufacturing_status'),
|
||||
'choices' => $status_choices,
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('status.edit', $part)
|
||||
'disabled' => !$this->security->isGranted('status.edit', $part),
|
||||
]);
|
||||
|
||||
//Advanced section
|
||||
|
@ -159,35 +151,34 @@ class PartBaseType extends AbstractType
|
|||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('part.edit.needs_review'),
|
||||
'disabled' => !$this->security->isGranted('edit', $part)
|
||||
'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'),
|
||||
'disabled' => !$this->security->isGranted('change_favorite', $part)
|
||||
'disabled' => !$this->security->isGranted('change_favorite', $part),
|
||||
])
|
||||
->add('mass', SIUnitType::class, [
|
||||
'unit' => 'g',
|
||||
'label' => $this->trans->trans('part.edit.mass'),
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('mass.edit', $part)
|
||||
'disabled' => !$this->security->isGranted('mass.edit', $part),
|
||||
])
|
||||
->add('partUnit', StructuralEntityType::class, [
|
||||
'class' => MeasurementUnit::class,
|
||||
'required' => false,
|
||||
'disable_not_selectable' => true,
|
||||
'label' => $this->trans->trans('part.edit.partUnit'),
|
||||
'disabled' => !$this->security->isGranted('unit.edit', $part)
|
||||
'disabled' => !$this->security->isGranted('unit.edit', $part),
|
||||
]);
|
||||
|
||||
|
||||
//Comment section
|
||||
$builder->add('comment', CKEditorType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('part.edit.comment'),
|
||||
'attr' => ['rows' => 4],
|
||||
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => ''
|
||||
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => '',
|
||||
]);
|
||||
|
||||
//Part Lots section
|
||||
|
@ -200,7 +191,7 @@ class PartBaseType extends AbstractType
|
|||
'measurement_unit' => $part->getPartUnit(),
|
||||
'disabled' => !$this->security->isGranted('lots.edit', $part),
|
||||
],
|
||||
'by_reference' => false
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
||||
//Attachment section
|
||||
|
@ -213,14 +204,14 @@ class PartBaseType extends AbstractType
|
|||
'data_class' => PartAttachment::class,
|
||||
'disabled' => !$this->security->isGranted('attachments.edit', $part),
|
||||
],
|
||||
'by_reference' => false
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
||||
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('attachments.edit', $part),
|
||||
'label' => $this->trans->trans('part.edit.master_attachment'),
|
||||
'entity' => $part
|
||||
'entity' => $part,
|
||||
]);
|
||||
|
||||
//Orderdetails section
|
||||
|
@ -234,7 +225,7 @@ class PartBaseType extends AbstractType
|
|||
'entry_options' => [
|
||||
'measurement_unit' => $part->getPartUnit(),
|
||||
'disabled' => !$this->security->isGranted('orderdetails.edit', $part),
|
||||
]
|
||||
],
|
||||
]);
|
||||
|
||||
$builder
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,34 +17,23 @@
|
|||
* 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\Form\Part;
|
||||
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Form\Type\SIUnitType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\Exception;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function GuzzleHttp\Promise\queue;
|
||||
|
||||
class PartLotType extends AbstractType
|
||||
{
|
||||
|
@ -62,49 +51,47 @@ class PartLotType extends AbstractType
|
|||
$builder->add('description', TextType::class, [
|
||||
'label' => $this->trans->trans('part_lot.edit.description'),
|
||||
'required' => false,
|
||||
'empty_data' => "",
|
||||
'attr' => ['class' => 'form-control-sm']
|
||||
'empty_data' => '',
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
]);
|
||||
|
||||
$builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class,
|
||||
'label' => $this->trans->trans('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' => $this->trans->trans('part_lot.edit.amount'),
|
||||
'attr' => ['class' => 'form-control-sm']
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
]);
|
||||
|
||||
$builder->add('instock_unknown', CheckboxType::class, ['required' => false,
|
||||
'label' => $this->trans->trans('part_lot.edit.instock_unknown'),
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom']
|
||||
'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'),
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'required' => false
|
||||
'required' => false,
|
||||
]);
|
||||
|
||||
$builder->add('expirationDate', DateTimeType::class, [
|
||||
'label' => $this->trans->trans('part_lot.edit.expiration_date'),
|
||||
'attr' => [],
|
||||
'required' => false]);
|
||||
'required' => false, ]);
|
||||
|
||||
$builder->add('comment', TextType::class, [
|
||||
'label' => $this->trans->trans('part_lot.edit.comment'),
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'required' => false, 'empty_data' => ""
|
||||
'required' => false, 'empty_data' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
|
@ -114,4 +101,4 @@ class PartLotType extends AbstractType
|
|||
$resolver->setRequired('measurement_unit');
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,55 +17,48 @@
|
|||
* 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\Form\Part;
|
||||
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\PriceInformations\Pricedetail;
|
||||
use App\Form\Type\CurrencyEntityType;
|
||||
use App\Form\Type\SIUnitType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class PricedetailType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
//No labels needed, we define translation in templates
|
||||
$builder->add("min_discount_quantity", SIUnitType::class, [
|
||||
$builder->add('min_discount_quantity', SIUnitType::class, [
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'attr' => ['class' => 'form-control-sm']
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
]);
|
||||
$builder->add("price_related_quantity", SIUnitType::class, [
|
||||
$builder->add('price_related_quantity', SIUnitType::class, [
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'attr' => ['class' => 'form-control-sm']
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
]);
|
||||
$builder->add("price", NumberType::class, [
|
||||
$builder->add('price', NumberType::class, [
|
||||
'scale' => 5,
|
||||
'html5' => true,
|
||||
'attr' => ['min' => 0, 'step' => "any"]
|
||||
'attr' => ['min' => 0, 'step' => 'any'],
|
||||
]);
|
||||
$builder->add("currency", CurrencyEntityType::class, ['required' => false]);
|
||||
$builder->add('currency', CurrencyEntityType::class, ['required' => false]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Pricedetail::class,
|
||||
'error_bubbling' => false
|
||||
'error_bubbling' => false,
|
||||
]);
|
||||
|
||||
$resolver->setRequired('measurement_unit');
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\Permissions;
|
||||
|
||||
|
||||
use App\Services\PermissionResolver;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -52,7 +50,7 @@ class PermissionGroupType extends AbstractType
|
|||
}
|
||||
} else {
|
||||
//Skip perrmissions without groups unless we have this as blanko group
|
||||
if ($options['group_name'] !== "*") {
|
||||
if ('*' !== $options['group_name']) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +61,7 @@ class PermissionGroupType extends AbstractType
|
|||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => $options['disabled'],
|
||||
'inherit' => $options['inherit']
|
||||
'inherit' => $options['inherit'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -86,4 +84,4 @@ class PermissionGroupType extends AbstractType
|
|||
return $options['name'];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,18 +17,13 @@
|
|||
* 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\Form\Permissions;
|
||||
|
||||
|
||||
use App\Form\Type\TriStateCheckboxType;
|
||||
use App\Services\PermissionResolver;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\Exception;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
|
@ -67,7 +62,7 @@ class PermissionType extends AbstractType
|
|||
});
|
||||
|
||||
$resolver->setDefaults([
|
||||
'inherit' => false
|
||||
'inherit' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -80,7 +75,7 @@ class PermissionType extends AbstractType
|
|||
'required' => false,
|
||||
'mapped' => false,
|
||||
'label' => $operation['label'] ?? null,
|
||||
'disabled' => $options['disabled']
|
||||
'disabled' => $options['disabled'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -91,4 +86,4 @@ class PermissionType extends AbstractType
|
|||
{
|
||||
$view->vars['multi_checkbox'] = $options['multi_checkbox'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\Permissions;
|
||||
|
||||
|
||||
use App\Services\PermissionResolver;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
|
@ -48,9 +46,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)
|
||||
{
|
||||
|
@ -95,10 +92,9 @@ 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
|
||||
* @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)
|
||||
{
|
||||
|
@ -116,4 +112,4 @@ class PermissionsMapper implements DataMapperInterface
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\Permissions;
|
||||
|
||||
|
||||
use App\Services\PermissionResolver;
|
||||
use App\Validator\Constraints\NoLockout;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
@ -43,7 +41,6 @@ class PermissionsType extends AbstractType
|
|||
$this->perm_structure = $resolver->getPermissionStructure();
|
||||
}
|
||||
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
|
@ -52,12 +49,11 @@ class PermissionsType extends AbstractType
|
|||
if (!$options['disabled']) {
|
||||
return [new NoLockout()];
|
||||
}
|
||||
|
||||
return [];
|
||||
},
|
||||
'inherit' => false,
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
|
@ -70,12 +66,12 @@ class PermissionsType extends AbstractType
|
|||
$groups = $this->perm_structure['groups'];
|
||||
|
||||
foreach ($groups as $key => $group) {
|
||||
$builder->add($key,PermissionGroupType::class, [
|
||||
$builder->add($key, PermissionGroupType::class, [
|
||||
'group_name' => $key,
|
||||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => $options['disabled'],
|
||||
'inherit' => $options['inherit']
|
||||
'inherit' => $options['inherit'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -85,7 +81,7 @@ class PermissionsType extends AbstractType
|
|||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => $options['disabled'],
|
||||
'inherit' => $options['inherit']
|
||||
'inherit' => $options['inherit'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,17 +17,14 @@
|
|||
* 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\Form\Type;
|
||||
|
||||
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Services\TreeBuilder;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Intl\Currencies;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
@ -75,25 +72,24 @@ class CurrencyEntityType extends StructuralEntityType
|
|||
/*** @var Currency $choice */
|
||||
$level = $choice->getLevel();
|
||||
//If our base entity is not the root level, we need to change the level, to get zero position
|
||||
if ($this->options['subentities_of'] !== null) {
|
||||
if (null !== $this->options['subentities_of']) {
|
||||
$level -= $parent->getLevel() - 1;
|
||||
}
|
||||
|
||||
|
||||
$tmp = str_repeat(' ', $choice->getLevel()); //Use 3 spaces for intendation
|
||||
if (empty($choice->getIsoCode())) {
|
||||
$tmp .= htmlspecialchars($choice->getName());
|
||||
} else {
|
||||
$tmp .= Currencies::getSymbol($choice->getIsoCode());
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value) : array
|
||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
|
||||
{
|
||||
/** @var Currency $choice */
|
||||
|
||||
$tmp = array();
|
||||
$tmp = [];
|
||||
|
||||
if (!empty($choice->getIsoCode())) {
|
||||
//Show the name of the currency
|
||||
|
@ -104,6 +100,7 @@ class CurrencyEntityType extends StructuralEntityType
|
|||
if ($this->options['disable_not_selectable'] && $choice->isNotSelectable()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\Type;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
@ -33,7 +31,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class MasterPictureAttachmentType extends AbstractType
|
||||
{
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setRequired('entity');
|
||||
|
@ -47,9 +44,9 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
/** @var Attachment $choice */
|
||||
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
||||
|
||||
if ($options['filter'] === 'picture' && !$choice->isPicture()) {
|
||||
if ('picture' === $options['filter'] && !$choice->isPicture()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
} elseif ($options['filter'] === '3d_model' && !$choice->is3DModel()) {
|
||||
} elseif ('3d_model' === $options['filter'] && !$choice->is3DModel()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
}
|
||||
|
||||
|
@ -60,22 +57,23 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
'class' => function (Options $options) {
|
||||
$short_class_name = (new \ReflectionClass($options['entity']))->getShortName();
|
||||
//Category becomes CategoryAttachment
|
||||
return 'App\\Entity\\Attachments\\' . $short_class_name . 'Attachment';
|
||||
return 'App\\Entity\\Attachments\\'.$short_class_name.'Attachment';
|
||||
},
|
||||
'query_builder' => function (Options $options) {
|
||||
return function (EntityRepository $er) use ($options) {
|
||||
$entity = $options['entity'];
|
||||
if ($entity->getID() === null) {
|
||||
if (null === $entity->getID()) {
|
||||
//This query is always false, so we get empty results
|
||||
return $er->createQueryBuilder('u')->where('0 = 2');
|
||||
}
|
||||
|
||||
return $er->createQueryBuilder('u')
|
||||
->where('u.element = ?1')
|
||||
->andWhere("u.path <> ''")
|
||||
->orderBy('u.name', 'ASC')
|
||||
->setParameter(1, $entity);
|
||||
};
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$resolver->setAllowedValues('filter', ['', 'picture', '3d_model']);
|
||||
|
@ -85,4 +83,4 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,12 +17,10 @@
|
|||
* 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\Form\Type;
|
||||
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Services\SIFormatter;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
@ -50,30 +48,36 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$resolver->setDefaults([
|
||||
'measurement_unit' => null,
|
||||
'show_prefix' => function (Options $options) {
|
||||
if ($options['measurement_unit'] !== null) {
|
||||
if (null !== $options['measurement_unit']) {
|
||||
/** @var MeasurementUnit $unit */
|
||||
$unit = $options['measurement_unit'];
|
||||
|
||||
return $unit->isUseSIPrefix();
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
'is_integer' => function (Options $options) {
|
||||
if ($options['measurement_unit'] !== null) {
|
||||
if (null !== $options['measurement_unit']) {
|
||||
/** @var MeasurementUnit $unit */
|
||||
$unit = $options['measurement_unit'];
|
||||
|
||||
return $unit->isInteger();
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
'unit' => function (Options $options) {
|
||||
if ($options['measurement_unit'] !== null) {
|
||||
if (null !== $options['measurement_unit']) {
|
||||
/** @var MeasurementUnit $unit */
|
||||
$unit = $options['measurement_unit'];
|
||||
|
||||
return $unit->getUnit();
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
'error_mapping' => [ '.' => 'value']
|
||||
'error_mapping' => ['.' => 'value'],
|
||||
]);
|
||||
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
|
@ -84,13 +88,13 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
'min' => 0,
|
||||
'max' => '',
|
||||
'step' => function (Options $options) {
|
||||
if ($options['is_integer'] === true) {
|
||||
if (true === $options['is_integer']) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return "any";
|
||||
return 'any';
|
||||
},
|
||||
'html5' => true
|
||||
'html5' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -102,13 +106,13 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
'attr' => [
|
||||
'min' => (string) $options['min'],
|
||||
'max' => (string) $options['max'],
|
||||
'step' => (string) $options['step']
|
||||
]
|
||||
'step' => (string) $options['step'],
|
||||
],
|
||||
]);
|
||||
|
||||
if ($options['show_prefix']) {
|
||||
$builder->add('prefix', ChoiceType::class, [
|
||||
'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3, 'µ' => -6 ]
|
||||
'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3, 'µ' => -6],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -121,7 +125,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
|
||||
//Check if we need to make this thing small
|
||||
if (isset($options['attr']['class'])) {
|
||||
$view->vars['sm'] = (strpos($options['attr']['class'], 'form-control-sm') !== false);
|
||||
$view->vars['sm'] = (false !== strpos($options['attr']['class'], 'form-control-sm'));
|
||||
}
|
||||
|
||||
$view->vars['unit'] = $options['unit'];
|
||||
|
@ -134,8 +138,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
|
||||
*/
|
||||
|
@ -143,7 +147,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
{
|
||||
$forms = iterator_to_array($forms);
|
||||
|
||||
if ($viewData === null) {
|
||||
if (null === $viewData) {
|
||||
if (isset($forms['prefix'])) {
|
||||
$forms['prefix']->setData(0);
|
||||
}
|
||||
|
@ -154,7 +158,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$data = $this->si_formatter->convertValue($viewData);
|
||||
|
||||
if (isset($forms['prefix'])) {
|
||||
$forms['value']->setData($data["value"]);
|
||||
$forms['value']->setData($data['value']);
|
||||
$forms['prefix']->setData($data['prefix_magnitude']);
|
||||
} else {
|
||||
$forms['value']->setData($viewData);
|
||||
|
@ -184,8 +188,8 @@ 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
|
||||
* @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
|
||||
|
@ -203,4 +207,4 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$viewData *= 10 ** $multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,23 +17,18 @@
|
|||
* 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\Form\Type;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Repository\StructuralDBElementRepository;
|
||||
use App\Services\TreeBuilder;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
||||
use Symfony\Component\Form\DataMapperInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
@ -43,18 +38,16 @@ use Symfony\Component\Form\FormView;
|
|||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
use function foo\func;
|
||||
|
||||
/**
|
||||
* This class provides a choice form type similar to EntityType, with the difference, that the tree structure
|
||||
* of the StructuralDBElementRepository will be shown to user
|
||||
* @package App\Form\Type
|
||||
* of the StructuralDBElementRepository will be shown to user.
|
||||
*/
|
||||
class StructuralEntityType extends AbstractType
|
||||
{
|
||||
protected $em;
|
||||
protected $options;
|
||||
/** @var TreeBuilder */
|
||||
/** @var TreeBuilder */
|
||||
protected $builder;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, TreeBuilder $builder)
|
||||
|
@ -66,11 +59,11 @@ class StructuralEntityType extends AbstractType
|
|||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->addModelTransformer(new CallbackTransformer(
|
||||
function ($value) use ($options){
|
||||
function ($value) use ($options) {
|
||||
return $this->transform($value, $options);
|
||||
}, function ($value) use ($options) {
|
||||
return $this->reverseTransform($value, $options);
|
||||
}));
|
||||
return $this->reverseTransform($value, $options);
|
||||
}));
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
|
@ -89,25 +82,26 @@ class StructuralEntityType extends AbstractType
|
|||
return $this->generateChoiceLabels($choice, $key, $value);
|
||||
}, 'choice_attr' => function ($choice, $key, $value) {
|
||||
return $this->generateChoiceAttr($choice, $key, $value);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$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'];
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
});
|
||||
}
|
||||
|
||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value) : array
|
||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
|
||||
{
|
||||
$tmp = array();
|
||||
$tmp = [];
|
||||
|
||||
if ($this->options['show_fullpath_in_subtext'] && $choice->getParent() != null) {
|
||||
if ($this->options['show_fullpath_in_subtext'] && null != $choice->getParent()) {
|
||||
$tmp += ['data-subtext' => $choice->getParent()->getFullPath()];
|
||||
}
|
||||
|
||||
|
@ -123,7 +117,7 @@ class StructuralEntityType extends AbstractType
|
|||
return $tmp;
|
||||
}
|
||||
|
||||
protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value) : string
|
||||
protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string
|
||||
{
|
||||
/** @var StructuralDBElement|null $parent */
|
||||
$parent = $this->options['subentities_of'];
|
||||
|
@ -131,34 +125,33 @@ class StructuralEntityType extends AbstractType
|
|||
/*** @var StructuralDBElement $choice */
|
||||
$level = $choice->getLevel();
|
||||
//If our base entity is not the root level, we need to change the level, to get zero position
|
||||
if ($this->options['subentities_of'] !== null) {
|
||||
if (null !== $this->options['subentities_of']) {
|
||||
$level -= $parent->getLevel() - 1;
|
||||
}
|
||||
|
||||
|
||||
$tmp = str_repeat(' ', $choice->getLevel()); //Use 3 spaces for intendation
|
||||
$tmp .= htmlspecialchars($choice->getName());
|
||||
$tmp .= htmlspecialchars($choice->getName());
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entries from database and return an array of them
|
||||
* @param Options $options
|
||||
* Gets the entries from database and return an array of them.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEntries(Options $options) : array
|
||||
public function getEntries(Options $options): array
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
$choices = $this->builder->typeToNodesList($options['class'], null);
|
||||
|
||||
/** @var StructuralDBElementRepository $repo */
|
||||
/* @var StructuralDBElementRepository $repo */
|
||||
/*$repo = $this->em->getRepository($options['class']);
|
||||
$choices = $repo->toNodesList(null); */
|
||||
return $choices;
|
||||
}
|
||||
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
//Allow HTML in labels. You must override the 'choice_widget_options' block, so that can work
|
||||
|
@ -254,10 +247,10 @@ class StructuralEntityType extends AbstractType
|
|||
The performance impact of this should be very small in comparison of the boost, caused by the caching.
|
||||
*/
|
||||
|
||||
if ($value === null) {
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->em->find($options['class'], $value->getID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,16 +17,13 @@
|
|||
* 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\Form\Type;
|
||||
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
|
@ -34,7 +31,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class TriStateCheckboxType extends AbstractType implements DataTransformerInterface
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options) : void
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->addViewTransformer($this);
|
||||
}
|
||||
|
@ -44,7 +41,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
$resolver->setDefaults([
|
||||
'label_attr' => ['class' => 'checkbox-custom checkbox-inline'],
|
||||
'attr' => ['class' => 'tristate'],
|
||||
'compound' => false
|
||||
'compound' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -61,7 +58,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
$view->vars = array_replace($view->vars, [
|
||||
'value' => $form->getViewData(),
|
||||
'checked' => true === $form->getData(),
|
||||
'indeterminate' => null === $form->getData()
|
||||
'indeterminate' => null === $form->getData(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -106,19 +103,19 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
*/
|
||||
public function transform($value)
|
||||
{
|
||||
if ($value === true) {
|
||||
return "true";
|
||||
if (true === $value) {
|
||||
return 'true';
|
||||
}
|
||||
|
||||
if ($value === false) {
|
||||
return "false";
|
||||
if (false === $value) {
|
||||
return 'false';
|
||||
}
|
||||
|
||||
if ($value === null) {
|
||||
return "indeterminate";
|
||||
if (null === $value) {
|
||||
return 'indeterminate';
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid value encountered!: ' . $value);
|
||||
throw new \InvalidArgumentException('Invalid value encountered!: '.$value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,15 +148,15 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
public function reverseTransform($value)
|
||||
{
|
||||
switch ($value) {
|
||||
case "true":
|
||||
case 'true':
|
||||
return true;
|
||||
case "false":
|
||||
case 'false':
|
||||
case '':
|
||||
return false;
|
||||
case "indeterminate":
|
||||
case 'indeterminate':
|
||||
return null;
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid value encountered!: ' . $value);
|
||||
throw new \InvalidArgumentException('Invalid value encountered!: '.$value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,22 +17,18 @@
|
|||
* 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\Form;
|
||||
|
||||
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Form\Permissions\PermissionsType;
|
||||
use App\Form\Permissions\PermissionType;
|
||||
use App\Form\Type\CurrencyEntityType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
@ -52,7 +48,6 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
|||
|
||||
class UserAdminForm extends AbstractType
|
||||
{
|
||||
|
||||
protected $security;
|
||||
protected $trans;
|
||||
|
||||
|
@ -72,12 +67,12 @@ class UserAdminForm extends AbstractType
|
|||
{
|
||||
/** @var StructuralDBElement $entity */
|
||||
$entity = $options['data'];
|
||||
$is_new = $entity->getID() === null;
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => $this->trans->trans('user.username.label'),
|
||||
'label' => $this->trans->trans('user.username.label'),
|
||||
'attr' => ['placeholder' => $this->trans->trans('user.username.placeholder')],
|
||||
'disabled' => !$this->security->isGranted('edit_username', $entity),
|
||||
])
|
||||
|
@ -111,7 +106,6 @@ class UserAdminForm extends AbstractType
|
|||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $entity), ])
|
||||
|
||||
|
||||
->add('department', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => $this->trans->trans('user.department.label'),
|
||||
|
@ -120,7 +114,6 @@ class UserAdminForm extends AbstractType
|
|||
'disabled' => !$this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
||||
|
||||
//Config section
|
||||
->add('language', LanguageType::class, [
|
||||
'required' => false,
|
||||
|
@ -128,7 +121,7 @@ class UserAdminForm extends AbstractType
|
|||
'placeholder' => $this->trans->trans('user_settings.language.placeholder'),
|
||||
'label' => $this->trans->trans('user.language_select'),
|
||||
'preferred_choices' => ['en', 'de'],
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity)
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
->add('timezone', TimezoneType::class, [
|
||||
'required' => false,
|
||||
|
@ -136,7 +129,7 @@ class UserAdminForm extends AbstractType
|
|||
'placeholder' => $this->trans->trans('user_settings.timezone.placeholder'),
|
||||
'label' => $this->trans->trans('user.timezone.label'),
|
||||
'preferred_choices' => ['Europe/Berlin'],
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity)
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
->add('theme', ChoiceType::class, [
|
||||
'required' => false,
|
||||
|
@ -147,12 +140,12 @@ class UserAdminForm extends AbstractType
|
|||
'attr' => ['class' => 'selectpicker'],
|
||||
'placeholder' => $this->trans->trans('user_settings.theme.placeholder'),
|
||||
'label' => $this->trans->trans('user.theme.label'),
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity)
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
->add('currency', CurrencyEntityType::class, [
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('user.currency.label'),
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity)
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
|
||||
->add('new_password', RepeatedType::class, [
|
||||
|
@ -166,14 +159,14 @@ class UserAdminForm extends AbstractType
|
|||
'constraints' => [new Length([
|
||||
'min' => 6,
|
||||
'max' => 128,
|
||||
])]
|
||||
])],
|
||||
])
|
||||
|
||||
->add('need_pw_change', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('user.edit.needs_pw_change'),
|
||||
'disabled' => !$this->security->isGranted('set_password', $entity)
|
||||
'disabled' => !$this->security->isGranted('set_password', $entity),
|
||||
])
|
||||
|
||||
->add('disabled', CheckboxType::class, [
|
||||
|
@ -181,15 +174,14 @@ class UserAdminForm extends AbstractType
|
|||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label' => $this->trans->trans('user.edit.user_disabled'),
|
||||
'disabled' => !$this->security->isGranted('set_password', $entity)
|
||||
|| $entity === $this->security->getUser()
|
||||
|
||||
|| $entity === $this->security->getUser(),
|
||||
])
|
||||
|
||||
//Permission section
|
||||
->add('permissions', PermissionsType::class, [
|
||||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => !$this->security->isGranted('edit_permissions', $entity)
|
||||
'disabled' => !$this->security->isGranted('edit_permissions', $entity),
|
||||
])
|
||||
;
|
||||
/*->add('comment', CKEditorType::class, ['required' => false,
|
||||
|
@ -213,11 +205,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'),
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : '']
|
||||
'label' => $is_new ? $this->trans->trans('user.create') : $this->trans->trans('user.edit.save'),
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : ''],
|
||||
])
|
||||
->add('reset', ResetType::class, [
|
||||
'label' => $this->trans->trans('entity.edit.reset')
|
||||
'label' => $this->trans->trans('entity.edit.reset'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -225,4 +217,4 @@ class UserAdminForm extends AbstractType
|
|||
{
|
||||
//Empty for Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony)
|
||||
* 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)
|
||||
*
|
||||
|
@ -17,22 +17,16 @@
|
|||
* 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\Form;
|
||||
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Form\Type\CurrencyEntityType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Doctrine\ORM\Query\Parameter;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
@ -90,7 +84,7 @@ class UserSettingsType extends AbstractType
|
|||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'placeholder' => $this->trans->trans('user_settings.language.placeholder'),
|
||||
'label' => $this->trans->trans('user.language_select'),
|
||||
'preferred_choices' => ['en', 'de']
|
||||
'preferred_choices' => ['en', 'de'],
|
||||
])
|
||||
->add('timezone', TimezoneType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
|
@ -98,7 +92,7 @@ class UserSettingsType extends AbstractType
|
|||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'placeholder' => $this->trans->trans('user_settings.timezone.placeholder'),
|
||||
'label' => $this->trans->trans('user.timezone.label'),
|
||||
'preferred_choices' => ['Europe/Berlin']
|
||||
'preferred_choices' => ['Europe/Berlin'],
|
||||
])
|
||||
->add('theme', ChoiceType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
|
@ -114,7 +108,7 @@ class UserSettingsType extends AbstractType
|
|||
->add('currency', CurrencyEntityType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
'label' => $this->trans->trans('user.currency.label')
|
||||
'label' => $this->trans->trans('user.currency.label'),
|
||||
])
|
||||
|
||||
//Buttons
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue