mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-21 19:34:54 +02:00
Added an admin page for currencies.
This commit is contained in:
parent
87e6f641c3
commit
2468409212
15 changed files with 374 additions and 9 deletions
|
@ -36,6 +36,8 @@ use App\Entity\Base\NamedDBElement;
|
|||
use App\Entity\Base\StructuralDBElement;
|
||||
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;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||
|
@ -48,10 +50,12 @@ class BaseEntityAdminForm extends AbstractType
|
|||
{
|
||||
|
||||
protected $security;
|
||||
protected $params;
|
||||
|
||||
public function __construct(Security $security)
|
||||
public function __construct(Security $security, ParameterBagInterface $params)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,7 +78,7 @@ class BaseEntityAdminForm extends AbstractType
|
|||
'label' => 'not_selectable.label', 'help' => 'not_selectable.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity) ])
|
||||
|
||||
->add('comment', CKEditorType::class, ['required' => false,
|
||||
->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)]);
|
||||
|
||||
|
|
57
src/Form/AdminPages/CurrencyAdminForm.php
Normal file
57
src/Form/AdminPages/CurrencyAdminForm.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* part-db version 0.1
|
||||
* Copyright (C) 2005 Christoph Lechner
|
||||
* http://www.cl-projects.de/
|
||||
*
|
||||
* part-db version 0.2+
|
||||
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
|
||||
* http://code.google.com/p/part-db/
|
||||
*
|
||||
* Part-DB Version 0.4+
|
||||
* Copyright (C) 2016 - 2019 Jan Böhmer
|
||||
* https://github.com/jbtronics
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\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;
|
||||
|
||||
class CurrencyAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('iso_code', CurrencyType::class , ['required' => true,
|
||||
'label' => 'currency.iso_code.label',
|
||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('exchange_rate', MoneyType::class, ['required' => false,
|
||||
'label' => 'currency.exchange_rate.label', 'currency' => $this->params->get('default_currency'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue