Added a basic possibility to create/edit/delete specifications for parts.

This commit is contained in:
Jan Böhmer 2020-03-08 22:46:29 +01:00
parent 502febb008
commit a6e0f1738b
15 changed files with 1359 additions and 765 deletions

View file

@ -50,7 +50,9 @@ use App\Entity\Parts\Manufacturer;
use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\Part;
use App\Entity\PriceInformations\Orderdetail;
use App\Entity\Specifications\Specification;
use App\Form\AttachmentFormType;
use App\Form\SpecificationType;
use App\Form\Type\MasterPictureAttachmentType;
use App\Form\Type\SIUnitType;
use App\Form\Type\StructuralEntityType;
@ -264,6 +266,15 @@ class PartBaseType extends AbstractType
],
]);
$builder->add('specifications', CollectionType::class, [
'entry_type' => SpecificationType::class,
'allow_add' => true,
'allow_delete' => true,
'label' => false,
'by_reference' => false,
'prototype_data' => new Specification(),
]);
$builder->add('log_comment', TextType::class, [
'label' => 'edit.log_comment',
'mapped' => false,
@ -280,7 +291,7 @@ class PartBaseType extends AbstractType
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Part::class,
]);
'data_class' => Part::class,
]);
}
}

View file

@ -0,0 +1,67 @@
<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Form;
use App\Entity\Specifications\Specification;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class SpecificationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', TextType::class,[
'empty_data' => '',
]);
$builder->add('symbol', TextType::class, [
'required' => false,
'empty_data' => '',
]);
$builder->add('value_text', TextType::class, [
'required' => false,
'empty_data' => '',
]);
$builder->add('value_max', NumberType::class, [
'required' => false,
]);
$builder->add('value_min', NumberType::class, [
'required' => false,
]);
$builder->add('value_typical', NumberType::class, [
'required' => false
]);
$builder->add('unit', TextType::class, [
'required' => false,
'empty_data' => '',
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Specification::class
]);
}
}