mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-20 10:57:40 +02:00
Added basic admin page for Label profiles.
This commit is contained in:
parent
b23dec0262
commit
a8a92b9c5d
20 changed files with 1688 additions and 857 deletions
|
@ -45,6 +45,8 @@ namespace App\Form\AdminPages;
|
|||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\LabelSystem\LabelOptions;
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use App\Form\AttachmentFormType;
|
||||
use App\Form\ParameterType;
|
||||
use App\Form\Type\MasterPictureAttachmentType;
|
||||
|
@ -94,36 +96,50 @@ class BaseEntityAdminForm extends AbstractType
|
|||
'placeholder' => 'part.name.placeholder',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
])
|
||||
|
||||
->add('parent', StructuralEntityType::class, [
|
||||
'class' => get_class($entity),
|
||||
'required' => false,
|
||||
'label' => 'parent.label',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
])
|
||||
|
||||
->add('not_selectable', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'entity.edit.not_selectable',
|
||||
'help' => 'entity.edit.not_selectable.help',
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
])
|
||||
|
||||
->add('comment', CKEditorType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'comment.label',
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
'help' => 'bbcode.hint',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
if ($entity instanceof AbstractStructuralDBElement) {
|
||||
$builder->add(
|
||||
'parent',
|
||||
StructuralEntityType::class,
|
||||
[
|
||||
'class' => get_class($entity),
|
||||
'required' => false,
|
||||
'label' => 'parent.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'not_selectable',
|
||||
CheckboxType::class,
|
||||
[
|
||||
'required' => false,
|
||||
'label' => 'entity.edit.not_selectable',
|
||||
'help' => 'entity.edit.not_selectable.help',
|
||||
'label_attr' => [
|
||||
'class' => 'checkbox-custom',
|
||||
],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]
|
||||
);
|
||||
}
|
||||
if ($entity instanceof AbstractStructuralDBElement || $entity instanceof LabelProfile) {
|
||||
$builder->add(
|
||||
'comment',
|
||||
CKEditorType::class,
|
||||
[
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'comment.label',
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
'help' => 'bbcode.hint',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$this->additionalFormElements($builder, $options, $entity);
|
||||
|
||||
//Attachment section
|
||||
|
@ -154,19 +170,25 @@ class BaseEntityAdminForm extends AbstractType
|
|||
'empty_data' => null,
|
||||
]);
|
||||
|
||||
$builder->add('parameters', CollectionType::class, [
|
||||
'entry_type' => ParameterType::class,
|
||||
'allow_add' => $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'allow_delete' => $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'reindex_enable' => true,
|
||||
'label' => false,
|
||||
'by_reference' => false,
|
||||
'prototype_data' => new $options['parameter_class'](),
|
||||
'entry_options' => [
|
||||
'data_class' => $options['parameter_class'],
|
||||
],
|
||||
]);
|
||||
if ($entity instanceof StructuralEntityType) {
|
||||
$builder->add(
|
||||
'parameters',
|
||||
CollectionType::class,
|
||||
[
|
||||
'entry_type' => ParameterType::class,
|
||||
'allow_add' => $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'allow_delete' => $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'reindex_enable' => true,
|
||||
'label' => false,
|
||||
'by_reference' => false,
|
||||
'prototype_data' => new $options['parameter_class'](),
|
||||
'entry_options' => [
|
||||
'data_class' => $options['parameter_class'],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
//Buttons
|
||||
$builder->add('save', SubmitType::class, [
|
||||
|
|
42
src/Form/AdminPages/LabelProfileAdminForm.php
Normal file
42
src/Form/AdminPages/LabelProfileAdminForm.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?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\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
use App\Form\LabelOptionsType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class LabelProfileAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void
|
||||
{
|
||||
$builder->add('options', LabelOptionsType::class);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
$resolver->setDefault('data_class', LabelProfile::class);
|
||||
}
|
||||
}
|
78
src/Form/LabelOptionsType.php
Normal file
78
src/Form/LabelOptionsType.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?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\LabelSystem\LabelOptions;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class LabelOptionsType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('width', NumberType::class, [
|
||||
'label' => 'label_options.page_size.label',
|
||||
'html5' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'label_options.width.placeholder',
|
||||
'min' => 0,
|
||||
'step' => 'any',
|
||||
]
|
||||
]);
|
||||
$builder->add('height', NumberType::class, [
|
||||
'label' => false,
|
||||
'html5' => true,
|
||||
'attr' => [
|
||||
'placeholder' => 'label_options.height.placeholder',
|
||||
'min' => 0,
|
||||
'step' => 'any',
|
||||
]
|
||||
]);
|
||||
|
||||
$builder->add('barcode_type', ChoiceType::class, [
|
||||
'label' => 'label_options.barcode_type.label',
|
||||
'empty_data' => 'none',
|
||||
'choices' => [
|
||||
'label_options.barcode_type.none' => 'none',
|
||||
'label_options.barcode_type.qr' => 'qr',
|
||||
'label_options.barcode_type.code39' => 'code39',
|
||||
]
|
||||
]);
|
||||
|
||||
$builder->add('lines', CKEditorType::class, [
|
||||
'label' => 'label_profile.lines.label',
|
||||
'attr' => [
|
||||
'rows' => 4,
|
||||
],
|
||||
'config_name' => 'label_config',
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefault('data_class', LabelOptions::class);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue