location admin: improve admin crud for location

This commit is contained in:
nobohan 2021-10-22 10:01:24 +02:00
parent e9322e61d4
commit e24fd8aff0
6 changed files with 54 additions and 19 deletions

View File

@ -9,11 +9,17 @@ class LocationController extends CRUDController
{ {
public function customizeQuery(string $action, Request $request, $query): void public function customizeQuery(string $action, Request $request, $query): void
{ {
$query->where('e.availableForUsers', "'TRUE'"); //$query->where('e.availableforusers', "'TRUE'"); // not working
$query->where('e.availableForUsers = true'); //TODO not working
} }
// public function createEntity(string $action, Request $request): object
// { public function createEntity(string $action, Request $request): object
{
// } $entity = parent::createEntity($action, $request);
}
$entity->setAvailableForUsers(true);
return $entity;
}
}

View File

@ -49,7 +49,7 @@ use Chill\MainBundle\Doctrine\Type\PointType;
use Chill\MainBundle\Entity\Location; use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\LocationType; use Chill\MainBundle\Entity\LocationType;
use Chill\MainBundle\Form\LocationTypeType; use Chill\MainBundle\Form\LocationTypeType;
use Chill\MainBundle\Form\LocationType as LocationFormType; use Chill\MainBundle\Form\LocationFormType;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
/** /**

View File

@ -2,7 +2,6 @@
namespace Chill\MainBundle\Form; namespace Chill\MainBundle\Form;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\LocationType as EntityLocationType; use Chill\MainBundle\Entity\LocationType as EntityLocationType;
use Chill\MainBundle\Form\Type\PickAddressType; use Chill\MainBundle\Form\Type\PickAddressType;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
@ -10,15 +9,18 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
final class LocationType extends AbstractType final class LocationFormType extends AbstractType
{ {
// private TranslatableStringHelper $translatableStringHelper; // private TranslatableStringHelper $translatableStringHelper;
// public function __construct( // /**
// TranslatableStringHelper $translatableStringHelper // * @param TranslatableStringHelper $translatableStringHelper
// ) { // */
// public function __construct(TranslatableStringHelper $translatableStringHelper)
// {
// $this->translatableStringHelper = $translatableStringHelper; // $this->translatableStringHelper = $translatableStringHelper;
// } // }
@ -33,7 +35,7 @@ final class LocationType extends AbstractType
->add('locationType', EntityType::class, [ ->add('locationType', EntityType::class, [
'class' => EntityLocationType::class, 'class' => EntityLocationType::class,
'choice_label' => function (EntityLocationType $entity) { 'choice_label' => function (EntityLocationType $entity) {
//return $this->translatableStringHelper->localize($entity->getTitle()); //return $this->translatableStringHelper->localize($entity->getTitle()); //TODO not working. Cannot pass smthg in the constructor
return $entity->getTitle()['fr']; return $entity->getTitle()['fr'];
}, },
]) ])
@ -44,4 +46,24 @@ final class LocationType extends AbstractType
'mapped' => false, 'mapped' => false,
]); ]);
} }
/**
* @param OptionsResolverInterface $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Chill\MainBundle\Entity\Location'
));
}
/**
* @return string
*/
public function getBlockPrefix()
{
return 'chill_mainbundle_location';
}
} }

View File

@ -7,10 +7,10 @@
<thead> <thead>
<tr> <tr>
<th>{{ 'Name'|trans }}</th> <th>{{ 'Name'|trans }}</th>
<th>{{ 'phonenumber1'|trans }}</th> <th>{{ 'Phonenumber1'|trans }}</th>
<th>{{ 'phonenumber2'|trans }}</th> <th>{{ 'Phonenumber2'|trans }}</th>
<th>{{ 'email'|trans }}</th> <th>{{ 'Email'|trans }}</th>
<th>{{ 'address'|trans }}</th> <th>{{ 'Address'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View File

@ -138,6 +138,10 @@ services:
autoconfigure: true autoconfigure: true
autowire: true autowire: true
Chill\MainBundle\Form\Type\LocationType: Chill\MainBundle\Form\Type\LocationFormType:
autowire: true autowire: true
autoconfigure: true autoconfigure: true
arguments:
- "@chill.main.helper.translatable_string"
tags:
- { name: form.type }

View File

@ -191,6 +191,9 @@ required: requis
never: jamais never: jamais
Create a new location: Créer une nouvelle localisation Create a new location: Créer une nouvelle localisation
Location list: Liste des localisations Location list: Liste des localisations
Location type: Type de localisation
Phonenumber1: Numéro de téléphone
Phonenumber2: Autre numéro de téléphone
# circles / scopes # circles / scopes
Choose the circle: Choisir le cercle Choose the circle: Choisir le cercle