Selaa lähdekoodia

Address dans Merchant

feature/ticket
Fab 3 vuotta sitten
vanhempi
commit
ae2ca516df
4 muutettua tiedostoa jossa 151 lisäystä ja 0 poistoa
  1. +5
    -0
      Controller/Merchant/MerchantAdminController.php
  2. +26
    -0
      Field/Address/AddressField.php
  3. +103
    -0
      Form/Address/AddressType.php
  4. +17
    -0
      Resources/translations/admin.fr.yaml

+ 5
- 0
Controller/Merchant/MerchantAdminController.php Näytä tiedosto

use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Controller\AdminControllerTrait; use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\SovBundle\Controller\AbstractAdminController; use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\CKEditorField; use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField; use Lc\SovBundle\Field\StatusField;
->setRequired(true) ->setRequired(true)
->hideOnIndex(), ->hideOnIndex(),
StatusField::new('status'), StatusField::new('status'),

FormField::addPanel('address'),
AddressField::new('address')

], ],
$panel $panel
); );

+ 26
- 0
Field/Address/AddressField.php Näytä tiedosto

<?php

namespace Lc\CaracoleBundle\Field\Address;

use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
use Lc\CaracoleBundle\Form\Address\AddressType;

/**
* @author La clic ! <contact@laclic.fr>
*/
final class AddressField implements FieldInterface
{
use FieldTrait;

public static function new(string $propertyName, ?string $label = null): self
{
return (new self())
->hideOnIndex()
->setProperty($propertyName)
->setLabel($label)
//->setTemplatePath('@LcSov/adminlte/crud/field/toggle.html.twig')
->setFormType(AddressType::class);
}

}

+ 103
- 0
Form/Address/AddressType.php Näytä tiedosto

<?php

namespace Lc\CaracoleBundle\Form\Address;

use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Address\AddressModel;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AddressType extends AbstractType
{
protected $em;
protected $translatorAdmin;

public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin)
{
$this->em = $entityManager;
$this->translatorAdmin = $translatorAdmin;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', TextType::class, ['label' => 'Titre'])
->add(
'type',
ChoiceType::class,
[
'label' => 'Type',
'choices' => [
$this->translatorAdmin->transField(
'typeOptions.'.AddressModel::TYPE_INDIVIDUAL,
'Address'
) => AddressModel::TYPE_INDIVIDUAL,
$this->translatorAdmin->transField(
'typeOptions.'.AddressModel::TYPE_LEGAL_PERSON,
'Address'
) => AddressModel::TYPE_LEGAL_PERSON,
],
]
)
->add(
'civility',
ChoiceType::class,
[
'label' => 'Civilité',
'required' => false,
'choices' => [
'--' => '',
'Femme' => 1,
'Homme' => 0,
],
]
)
->add('lastname', TextType::class, ['required' => false])
->add('firstname', TextType::class, ['required' => false])
->add('zip', TextType::class)
->add('city', TextType::class)
->add('address', TextType::class)
->add(
'phone',
CollectionType::class,
[
'allow_add' => true,
'allow_delete' => true,
'entry_options' => [
'label' => false,
],
'required' => false,
'row_attr' => array(
'data-reindex-key' => true,
'class' => 'field-collection',

),
'attr' => array(
'class' => 'field-collection-group',
),
]
)
->add('company', TextType::class, ['required' => false])
->add('siret', TextType::class, ['required' => false])
->add('tva', TextType::class, ['required' => false])
->add('country', HiddenType::class, ['data' => 'France'])
->add('status', HiddenType::class, ['data' => '1']);
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'label' => false,
'data_class' => $this->em->getEntityName(AddressInterface::class),
]
);
}
}

+ 17
- 0
Resources/translations/admin.fr.yaml Näytä tiedosto



entity: entity:
default: default:
panels:
address: Adresse
fields: fields:
address: Adresse
merchant: Marchand merchant: Marchand
taxRate: Règle de taxe taxRate: Règle de taxe
Address:
fields:
type: Type
typeOptions:
legal-person: Professionnel
individual: Particulier
civility: Civilité
zip: Code postal
city: Ville
address: Adresse
phone: Téléphone
company: Entreprise
siret: SIRET
tva: Numero de TVA
Merchant: Merchant:
label: Marchand label: Marchand
label_plurial: Marchands label_plurial: Marchands

Loading…
Peruuta
Tallenna