mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Added a basic possibility to create/edit/delete specifications for parts.
This commit is contained in:
parent
502febb008
commit
a6e0f1738b
15 changed files with 1359 additions and 765 deletions
|
@ -13,6 +13,7 @@
|
||||||
"beberlei/doctrineextensions": "^1.2",
|
"beberlei/doctrineextensions": "^1.2",
|
||||||
"doctrine/annotations": "^1.6",
|
"doctrine/annotations": "^1.6",
|
||||||
"doctrine/doctrine-bundle": "^2.0",
|
"doctrine/doctrine-bundle": "^2.0",
|
||||||
|
"dunglas/doctrine-json-odm": "^1.0",
|
||||||
"florianv/swap": "^4.0",
|
"florianv/swap": "^4.0",
|
||||||
"friendsofsymfony/ckeditor-bundle": "^2.0",
|
"friendsofsymfony/ckeditor-bundle": "^2.0",
|
||||||
"gregwar/captcha-bundle": "^2.1.0",
|
"gregwar/captcha-bundle": "^2.1.0",
|
||||||
|
|
68
composer.lock
generated
68
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "6ebc8e9705e901be6f00f9f6418cf900",
|
"content-hash": "ec3095adecf24f5680e7c904c5f0731f",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "beberlei/assert",
|
"name": "beberlei/assert",
|
||||||
|
@ -1265,6 +1265,72 @@
|
||||||
],
|
],
|
||||||
"time": "2020-01-08T19:53:19+00:00"
|
"time": "2020-01-08T19:53:19+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "dunglas/doctrine-json-odm",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/dunglas/doctrine-json-odm.git",
|
||||||
|
"reference": "70afdc23e68a31c7cbf8417f2dbb285ec929e14e"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/dunglas/doctrine-json-odm/zipball/70afdc23e68a31c7cbf8417f2dbb285ec929e14e",
|
||||||
|
"reference": "70afdc23e68a31c7cbf8417f2dbb285ec929e14e",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"doctrine/orm": "^2.6.3",
|
||||||
|
"php": "^7.1",
|
||||||
|
"symfony/property-access": "^3.4 || ^4.1 || ^5.0",
|
||||||
|
"symfony/property-info": "^3.4 || ^4.1 || ^5.0",
|
||||||
|
"symfony/serializer": "^3.4 || ^4.1 || ^5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"doctrine/doctrine-bundle": "^1.8",
|
||||||
|
"symfony/finder": "^3.4 || ^4.1 || ^5.0",
|
||||||
|
"symfony/framework-bundle": "^3.4 || ^4.1 || ^5.0",
|
||||||
|
"symfony/phpunit-bridge": "^5.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"scienta/doctrine-json-functions": "To add support for JSON functions in DQL.",
|
||||||
|
"symfony/framework-bundle": "To use the provided bundle."
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.0.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Dunglas\\DoctrineJsonOdm\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Kévin Dunglas",
|
||||||
|
"email": "dunglas@gmail.com",
|
||||||
|
"homepage": "https://dunglas.fr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "An object document mapper for Doctrine ORM using JSON types of modern RDBMS.",
|
||||||
|
"homepage": "https://dunglas.fr",
|
||||||
|
"keywords": [
|
||||||
|
"database",
|
||||||
|
"json",
|
||||||
|
"mysql",
|
||||||
|
"odm",
|
||||||
|
"orm",
|
||||||
|
"postgresql",
|
||||||
|
"rdbms"
|
||||||
|
],
|
||||||
|
"time": "2019-12-23T09:48:22+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "egulias/email-validator",
|
"name": "egulias/email-validator",
|
||||||
"version": "2.1.17",
|
"version": "2.1.17",
|
||||||
|
|
|
@ -23,4 +23,5 @@ return [
|
||||||
Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true],
|
Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true],
|
||||||
R\U2FTwoFactorBundle\RU2FTwoFactorBundle::class => ['all' => true],
|
R\U2FTwoFactorBundle\RU2FTwoFactorBundle::class => ['all' => true],
|
||||||
Translation\Bundle\TranslationBundle::class => ['all' => true],
|
Translation\Bundle\TranslationBundle::class => ['all' => true],
|
||||||
|
\Dunglas\DoctrineJsonOdm\Bundle\DunglasDoctrineJsonOdmBundle::class => ['all' => true],
|
||||||
];
|
];
|
||||||
|
|
|
@ -50,6 +50,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
*/
|
*/
|
||||||
abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
abstract class AbstractStructuralDBElement extends AttachmentContainingDBElement
|
||||||
{
|
{
|
||||||
|
use SpecificationsTrait;
|
||||||
|
|
||||||
public const ID_ROOT_ELEMENT = 0;
|
public const ID_ROOT_ELEMENT = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
54
src/Entity/Base/SpecificationsTrait.php
Normal file
54
src/Entity/Base/SpecificationsTrait.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?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\Entity\Base;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Entity\Specifications\Specification;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
trait SpecificationsTrait
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Specification[]
|
||||||
|
* @ORM\Column(type="json_document")
|
||||||
|
* @Assert\Valid()
|
||||||
|
*/
|
||||||
|
protected $specifications = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all associated specifications
|
||||||
|
* @return Specification[]
|
||||||
|
*/
|
||||||
|
public function getSpecifications(): array
|
||||||
|
{
|
||||||
|
return $this->specifications ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $specifications
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSpecifications(array $specifications): self
|
||||||
|
{
|
||||||
|
$this->specifications = $specifications;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -52,6 +52,7 @@ namespace App\Entity\Parts;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||||
|
use App\Entity\Base\SpecificationsTrait;
|
||||||
use App\Entity\Devices\Device;
|
use App\Entity\Devices\Device;
|
||||||
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
|
use App\Entity\Parts\PartTraits\AdvancedPropertyTrait;
|
||||||
use App\Entity\Parts\PartTraits\BasicPropertyTrait;
|
use App\Entity\Parts\PartTraits\BasicPropertyTrait;
|
||||||
|
@ -81,6 +82,7 @@ class Part extends AttachmentContainingDBElement
|
||||||
use InstockTrait;
|
use InstockTrait;
|
||||||
use ManufacturerTrait;
|
use ManufacturerTrait;
|
||||||
use OrderTrait;
|
use OrderTrait;
|
||||||
|
use SpecificationsTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO.
|
* TODO.
|
||||||
|
|
214
src/Entity/Specifications/Specification.php
Normal file
214
src/Entity/Specifications/Specification.php
Normal file
|
@ -0,0 +1,214 @@
|
||||||
|
<?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\Entity\Specifications;
|
||||||
|
|
||||||
|
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class Specification
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string The name of the specification (e.g. "Collector-Base Voltage"). Required!
|
||||||
|
* @Assert\NotBlank()
|
||||||
|
*/
|
||||||
|
protected $name = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The mathematical symbol for this specification. Can be rendered pretty later. Should be short
|
||||||
|
* @Assert\Length(max=10)
|
||||||
|
*/
|
||||||
|
protected $symbol = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float|null The guaranteed minimum value of this property.
|
||||||
|
* @Assert\Type({"float","null"})
|
||||||
|
* @Assert\LessThanOrEqual(propertyPath="value_typical")
|
||||||
|
* @Assert\LessThan(propertyPath="value_max")
|
||||||
|
*/
|
||||||
|
protected $value_min;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float|null The typical value of this property.
|
||||||
|
* @Assert\Type({"null", "float"})
|
||||||
|
*/
|
||||||
|
protected $value_typical;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float|null The maximum value of this property.
|
||||||
|
* @Assert\Type({"float", "null"})
|
||||||
|
* @Assert\GreaterThanOrEqual(propertyPath="value_typical")
|
||||||
|
*/
|
||||||
|
protected $value_max;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The unit in which the value values are given (e.g. V)
|
||||||
|
* @Assert\Length(max=5)
|
||||||
|
*/
|
||||||
|
protected $unit = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string A text value for the given property.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected $value_text = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the specification (e.g. "Collector-Base Voltage").
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the specification. This value is required.
|
||||||
|
* @param string $name
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setName(string $name): Specification
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the mathematical symbol for this specification (e.g. "V_CB")
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getSymbol(): string
|
||||||
|
{
|
||||||
|
return $this->symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the mathematical symbol for this specification (e.g. "V_CB")
|
||||||
|
* @param string $symbol
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSymbol(string $symbol): Specification
|
||||||
|
{
|
||||||
|
$this->symbol = $symbol;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns The guaranteed minimum value of this property.
|
||||||
|
* @return float|null
|
||||||
|
*/
|
||||||
|
public function getValueMin(): ?float
|
||||||
|
{
|
||||||
|
return $this->value_min;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the minimum value of this property.
|
||||||
|
* @param float|null $value_min
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setValueMin(?float $value_min): Specification
|
||||||
|
{
|
||||||
|
$this->value_min = $value_min;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the typical value of this property.
|
||||||
|
* @return float|null
|
||||||
|
*/
|
||||||
|
public function getValueTypical(): ?float
|
||||||
|
{
|
||||||
|
return $this->value_typical;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the typical value of this property
|
||||||
|
* @param float $value_typical
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setValueTypical(?float $value_typical): Specification
|
||||||
|
{
|
||||||
|
$this->value_typical = $value_typical;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the guaranteed maximum value
|
||||||
|
* @return float|null
|
||||||
|
*/
|
||||||
|
public function getValueMax(): ?float
|
||||||
|
{
|
||||||
|
return $this->value_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the guaranteed maximum value
|
||||||
|
* @param float|null $value_max
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setValueMax(?float $value_max): Specification
|
||||||
|
{
|
||||||
|
$this->value_max = $value_max;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unit used by the value (e.g. "V")
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getUnit(): string
|
||||||
|
{
|
||||||
|
return $this->unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the unit used by the value.
|
||||||
|
* @param string $unit
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setUnit(string $unit): Specification
|
||||||
|
{
|
||||||
|
$this->unit = $unit;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the text value.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getValueText(): string
|
||||||
|
{
|
||||||
|
return $this->value_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the text value.
|
||||||
|
* @param string $value_text
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setValueText(string $value_text): Specification
|
||||||
|
{
|
||||||
|
$this->value_text = $value_text;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -50,7 +50,9 @@ use App\Entity\Parts\Manufacturer;
|
||||||
use App\Entity\Parts\MeasurementUnit;
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
|
use App\Entity\Specifications\Specification;
|
||||||
use App\Form\AttachmentFormType;
|
use App\Form\AttachmentFormType;
|
||||||
|
use App\Form\SpecificationType;
|
||||||
use App\Form\Type\MasterPictureAttachmentType;
|
use App\Form\Type\MasterPictureAttachmentType;
|
||||||
use App\Form\Type\SIUnitType;
|
use App\Form\Type\SIUnitType;
|
||||||
use App\Form\Type\StructuralEntityType;
|
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, [
|
$builder->add('log_comment', TextType::class, [
|
||||||
'label' => 'edit.log_comment',
|
'label' => 'edit.log_comment',
|
||||||
'mapped' => false,
|
'mapped' => false,
|
||||||
|
@ -280,7 +291,7 @@ class PartBaseType extends AbstractType
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => Part::class,
|
'data_class' => Part::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
67
src/Form/SpecificationType.php
Normal file
67
src/Form/SpecificationType.php
Normal 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
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
57
src/Migrations/Version20200308204758.php
Normal file
57
src/Migrations/Version20200308204758.php
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20200308204758 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription() : string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE attachment_types ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE categories ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE currencies ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE devices ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE footprints ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE manufacturers ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE measurement_units ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE storelocations ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE suppliers ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE groups ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE parts ADD specifications JSON NOT NULL COMMENT \'(DC2Type:json_document)\'');
|
||||||
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema) : void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE `attachment_types` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `categories` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE currencies DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `devices` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `footprints` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `groups` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT(1) DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE `manufacturers` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `measurement_units` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `parts` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `storelocations` DROP specifications');
|
||||||
|
$this->addSql('ALTER TABLE `suppliers` DROP specifications');
|
||||||
|
}
|
||||||
|
}
|
53
templates/Parts/edit/_specifications.html.twig
Normal file
53
templates/Parts/edit/_specifications.html.twig
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{% form_theme form with ['Parts/edit/edit_form_styles.html.twig', "bootstrap_4_layout.html.twig"] %}
|
||||||
|
|
||||||
|
<table class="table table-striped table-sm table-responsive-md" id="specifications_table" data-prototype="{% if form.specifications.vars.prototype is defined %}{{ form_widget(form.specifications.vars.prototype)|e('html_attr') }}{% endif %}">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>{% trans %}specifications.property{% endtrans %}</th>
|
||||||
|
<th>{% trans %}specifications.symbol{% endtrans %}</th>
|
||||||
|
<th>{% trans %}specifications.value_min{% endtrans %}</th>
|
||||||
|
<th>{% trans %}specifications.value_typ{% endtrans %}</th>
|
||||||
|
<th>{% trans %}specifications.value_max{% endtrans %}</th>
|
||||||
|
<th>{% trans %}specifications.unit{% endtrans %}</th>
|
||||||
|
<th>{% trans %}specifications.text{% endtrans %}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for spec in form.specifications %}
|
||||||
|
{{ form_widget(spec) }}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-success" onclick="create_specification_entry(this)" {% if not is_granted('orderdetails.create', part) %}disabled{% endif %}>
|
||||||
|
<i class="fas fa-plus-square fa-fw"></i>
|
||||||
|
{% trans %}specification.create{% endtrans %}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function delete_specification_entry(btn) {
|
||||||
|
window.bootbox.confirm('{% trans %}pricedetails.edit.delete.confirm{% endtrans %}', function (result) {
|
||||||
|
if(result) {
|
||||||
|
$(btn).closest("tr").remove();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_specification_entry(btn) {
|
||||||
|
//Determine the table, so we can determine, how many entries there are already.
|
||||||
|
$holder = $(btn).siblings("table");
|
||||||
|
|
||||||
|
var index = $holder.find(":input").length;
|
||||||
|
var newForm = $holder.data("prototype");
|
||||||
|
|
||||||
|
//Increase the index
|
||||||
|
newForm = newForm.replace(/__name__/g, index);
|
||||||
|
|
||||||
|
$holder.children("tbody").append(newForm);
|
||||||
|
|
||||||
|
//Reinit the selectpickers
|
||||||
|
//$(".selectpicker").selectpicker();
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -62,4 +62,22 @@
|
||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block specification_widget %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ form_widget(form.name) }}{{ form_errors(form.name) }}</td>
|
||||||
|
<td>{{ form_widget(form.symbol) }}{{ form_errors(form.symbol) }}</td>
|
||||||
|
<td>{{ form_widget(form.value_min) }}{{ form_errors(form.value_min) }}</td>
|
||||||
|
<td>{{ form_widget(form.value_typical) }}{{ form_errors(form.value_typical) }}</td>
|
||||||
|
<td>{{ form_widget(form.value_max) }}{{ form_errors(form.value_max) }}</td>
|
||||||
|
<td>{{ form_widget(form.unit) }}{{ form_errors(form.unit) }}</td>
|
||||||
|
<td>{{ form_widget(form.value_text) }}{{ form_errors(form.value_text) }}</td>
|
||||||
|
<td>
|
||||||
|
<button type="button" class="btn btn-danger order_btn_delete" onclick="delete_specification_entry(this);" title="{% trans %}orderdetail.delete{% endtrans %}">
|
||||||
|
<i class="fas fa-trash-alt fa-fw"></i>
|
||||||
|
</button>
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -52,6 +52,12 @@
|
||||||
{% trans %}part.edit.tab.orderdetails{% endtrans %}
|
{% trans %}part.edit.tab.orderdetails{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" data-toggle="tab" role="tab" href="#specifications">
|
||||||
|
<i class="fas fa-atlas fa-fw"></i>
|
||||||
|
{% trans %}part.edit.tab.specifications{% endtrans %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" data-toggle="tab" role="tab" href="#comment">
|
<a class="nav-link" data-toggle="tab" role="tab" href="#comment">
|
||||||
<i class="fas fa-sticky-note fa-fw"></i>
|
<i class="fas fa-sticky-note fa-fw"></i>
|
||||||
|
@ -81,6 +87,9 @@
|
||||||
<div class="tab-pane fade p-2" id="orderdetails" role="tabpanel">
|
<div class="tab-pane fade p-2" id="orderdetails" role="tabpanel">
|
||||||
{% include "Parts/edit/_orderdetails.html.twig" %}
|
{% include "Parts/edit/_orderdetails.html.twig" %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tab-pane fade p-2" id="specifications" role="tabpanel">
|
||||||
|
{% include "Parts/edit/_specifications.html.twig" %}
|
||||||
|
</div>
|
||||||
<div class="tab-pane fade p-2" id="comment" role="tabpanel">
|
<div class="tab-pane fade p-2" id="comment" role="tabpanel">
|
||||||
{{ form_widget(form.comment)}}
|
{{ form_widget(form.comment)}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
|
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en" trgLang="de">
|
||||||
<file source-language="en" target-language="de" datatype="plaintext" original="file.ext">
|
<file id="SchebTwoFactorBundle.de">
|
||||||
<header>
|
<unit id="QoghNQ6" name="login">
|
||||||
<tool tool-id="symfony" tool-name="Symfony"/>
|
<segment>
|
||||||
</header>
|
|
||||||
<body>
|
|
||||||
<trans-unit id="QoghNQ6" resname="login">
|
|
||||||
<source>login</source>
|
<source>login</source>
|
||||||
<target>Login</target>
|
<target>Login</target>
|
||||||
</trans-unit>
|
</segment>
|
||||||
</body>
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue