mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
various improvements aside acdtivity
This commit is contained in:
parent
4525f01d5f
commit
e4cfb4804b
@ -12,18 +12,30 @@ use Doctrine\Common\Collections\Criteria;
|
|||||||
|
|
||||||
final class AsideActivityController extends CRUDController
|
final class AsideActivityController extends CRUDController
|
||||||
{
|
{
|
||||||
/**
|
protected function buildQueryEntities(string $action, Request $request)
|
||||||
* @param QueryBuilder $query
|
{
|
||||||
*/
|
$qb = parent::buildQueryEntities($action, $request);
|
||||||
protected function onPostIndexBuildQuery(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, $query) {
|
|
||||||
|
|
||||||
$usr = $this->getUser();
|
|
||||||
$id = $usr->getId();
|
|
||||||
$criteria = Criteria::create()->andWhere(Criteria::expr()->eq('agent', $id));
|
|
||||||
|
|
||||||
$query
|
if ('index' === $action) {
|
||||||
->addCriteria($criteria);
|
$qb->andWhere($qb->expr()->eq('e.agent', ':user'));
|
||||||
|
$qb->setParameter('user', $this->getUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function orderQuery(
|
||||||
|
string $action,
|
||||||
|
$query,
|
||||||
|
Request $request,
|
||||||
|
PaginatorInterface $paginator
|
||||||
|
) {
|
||||||
|
if ('index' === $action) {
|
||||||
|
return $query->orderBy('e.date', 'DESC');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::orderQuery($action, $query, $request, $paginator);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ use Chill\MainBundle\Form\Type\ChillTextareaType;
|
|||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
@ -27,15 +28,18 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
private TranslatableStringHelper $translatableStringHelper;
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
private TokenStorageInterface $storage;
|
private TokenStorageInterface $storage;
|
||||||
|
|
||||||
public function __construct (TranslatableStringHelper $translatableStringHelper, array $timeChoices, TokenStorageInterface $storage){
|
public function __construct (
|
||||||
$this->timeChoices = $timeChoices;
|
TranslatableStringHelper $translatableStringHelper,
|
||||||
|
ParameterBagInterface $parameterBag,
|
||||||
|
TokenStorageInterface $storage
|
||||||
|
){
|
||||||
|
$this->timeChoices = $parameterBag->get('chill_activity.form.time_duration');
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
$this->storage = $storage;
|
$this->storage = $storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
dump($options);
|
|
||||||
$timeChoices = [];
|
$timeChoices = [];
|
||||||
|
|
||||||
foreach ($this->timeChoices as $e) {
|
foreach ($this->timeChoices as $e) {
|
||||||
@ -49,7 +53,7 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
];
|
];
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('agent', EntityType::class,
|
->add('agent', EntityType::class,
|
||||||
[
|
[
|
||||||
'label' => 'Agent',
|
'label' => 'Agent',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@ -90,7 +94,7 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
'required' => false,
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach (['duration'] as $fieldName)
|
foreach (['duration'] as $fieldName)
|
||||||
{
|
{
|
||||||
$builder->get($fieldName)
|
$builder->get($fieldName)
|
||||||
->addModelTransformer($durationTimeTransformer);
|
->addModelTransformer($durationTimeTransformer);
|
||||||
@ -135,7 +139,7 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => AsideActivity::class,
|
'data_class' => AsideActivity::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,4 +147,4 @@ final class AsideActivityFormType extends AbstractType
|
|||||||
{
|
{
|
||||||
return 'chill_asideactivitybundle_asideactivity';
|
return 'chill_asideactivitybundle_asideactivity';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $menuId
|
* @param $menuId
|
||||||
* @param MenuItem $menu
|
* @param MenuItem $menu
|
||||||
@ -27,7 +27,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||||
{
|
{
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Create an aside activity'), [
|
$menu->addChild($this->translator->trans('Create an aside activity'), [
|
||||||
'route' => 'chill_crud_aside_activity_new'
|
'route' => 'chill_crud_aside_activity_new'
|
||||||
])
|
])
|
||||||
@ -36,7 +35,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'icons' => [ 'plus' ]
|
'icons' => [ 'plus' ]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -44,4 +43,4 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
{
|
{
|
||||||
return [ 'section' ];
|
return [ 'section' ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content_form_actions_before %}{% endblock %}
|
{% block content_form_actions_before %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
{% block content_form_actions_confirm_delete %}
|
{% block content_form_actions_confirm_delete %}
|
||||||
<li>
|
<li>
|
||||||
<button type="submit" class="btn btn-delete" value="delete-and-close">{{ ('crud.'~crud_name~'.button_delete')|trans }}</button>
|
<button type="submit" class="btn btn-delete" value="delete-and-close">{{ ('crud.'~crud_name~'.button_delete')|trans }}</button>
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
{# {% block title %}{{ ('crud.' ~ crud_name ~ '.delete.title')|trans({'%crud_name%': crud_name}) }}{% endblock %} #}
|
{# {% block title %}{{ ('crud.' ~ crud_name ~ '.delete.title')|trans({'%crud_name%': crud_name}) }}{% endblock %} #}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% embed '@ChillAsideActivity/AsideActivity/_delete.html.twig' %}
|
{% embed '@ChillAsideActivity/asideActivity/_delete.html.twig' %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||||
{# we do not have "view" page. We empty the corresponding block #}
|
{# we do not have "view" page. We empty the corresponding block #}
|
||||||
{% block content_form_actions_view %}{% endblock %}
|
{% block content_form_actions_view %}{% endblock %}
|
||||||
|
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||||
{% endembed %}
|
{% endembed %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<div
|
<div
|
||||||
class="flex-table my-4 list-records">
|
class="flex-table my-4 list-records">
|
||||||
{# Sort activities according to date in descending order #}
|
{# Sort activities according to date in descending order #}
|
||||||
{% for entity in entities|sort ((a, b) => b.date <=> a.date) %}
|
{% for entity in entities %}
|
||||||
{% set t = entity.type %}
|
{% set t = entity.type %}
|
||||||
|
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
@ -62,30 +62,18 @@
|
|||||||
{{ entity.note|chill_markdown_to_html }}
|
{{ entity.note|chill_markdown_to_html }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endif %} #}
|
{% endif %} #}
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
<ul class="list-content">
|
<ul class="list-content">
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
{# <li>
|
<li>
|
||||||
<a href="{{ path('chill_crud_aside_activity_view', { 'id': entity.id} ) }}" class="btn btn-show "></a>
|
<a href="{{ chill_path_add_return_path('chill_crud_aside_activity_edit', { 'id': entity.id }) }}" class="btn btn-update btn-mini "></a>
|
||||||
</li> #}
|
</li>
|
||||||
{# TOOD
|
|
||||||
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
|
||||||
#}
|
|
||||||
<li><a href="{{ path('chill_crud_aside_activity_edit', { 'id': entity.id }) }}" class="btn btn-update "> </a>
|
|
||||||
</li>
|
|
||||||
{# TOOD
|
|
||||||
{% endif %}
|
|
||||||
{% if is_granted('CHILL_ACTIVITY_DELETE', activity) %}
|
|
||||||
#}
|
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_crud_aside_activity_delete', { 'id': entity.id } ) }}" class="btn btn-delete "></a>
|
<a href="{{ chill_path_add_return_path('chill_crud_aside_activity_delete', { 'id': entity.id } ) }}" class="btn btn-delete btn-mini"></a>
|
||||||
</li>
|
</li>
|
||||||
{#
|
|
||||||
{% endif %}
|
|
||||||
#}
|
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -93,10 +81,13 @@
|
|||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{ chill_pagination(paginator) }}
|
||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_crud_aside_activity_new') }}" class="btn btn-create">
|
<a href="{{ chill_path_add_return_path('chill_crud_aside_activity_new') }}" class="btn btn-create">
|
||||||
{{ 'Add a new aside activity' | trans }}
|
{{ 'Create' | trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
---
|
---
|
||||||
services:
|
services:
|
||||||
chill.asideactivity.form.type.asideactivity:
|
Chill\AsideActivityBundle\Form\:
|
||||||
class: Chill\AsideActivityBundle\Form\AsideActivityFormType
|
resource: './../../Form'
|
||||||
arguments:
|
autowire: true
|
||||||
- "@chill.main.helper.translatable_string"
|
autoconfigure: true
|
||||||
- "%chill_activity.form.time_duration%"
|
|
||||||
- "@security.token_storage"
|
|
||||||
tags:
|
|
||||||
- { name: form.type, alias: chill_asideactivitybundle_asideactivity }
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
services:
|
services:
|
||||||
Chill\AsideActivityBundle\Menu\SectionMenuBuilder:
|
Chill\AsideActivityBundle\Menu\:
|
||||||
arguments:
|
resource: './../../Menu'
|
||||||
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
autowire: true
|
||||||
tags:
|
autoconfigure: true
|
||||||
- { name: "chill.menu_builder" }
|
|
||||||
|
@ -34,10 +34,10 @@ crud:
|
|||||||
aside_activity:
|
aside_activity:
|
||||||
title_view: Détail de l'activité annexe
|
title_view: Détail de l'activité annexe
|
||||||
title_new: Nouvelle activité annexe
|
title_new: Nouvelle activité annexe
|
||||||
title_edit: Edition d'une activité annexe
|
title_edit: Édition d'une activité annexe
|
||||||
title_delete: Supprimation d'une activité annexe
|
title_delete: Supprimer une activité annexe
|
||||||
button_delete: Supprimer
|
button_delete: Supprimer
|
||||||
confirm_message_delete: Êtes-vous sûr de vouloir supprimer cet activité annexe?
|
confirm_message_delete: Êtes-vous sûr de vouloir supprimer cette activité annexe?
|
||||||
aside_activity_category:
|
aside_activity_category:
|
||||||
title_new: Nouvelle catégorie d'activité annexe
|
title_new: Nouvelle catégorie d'activité annexe
|
||||||
title_edit: Edition d'une catégorie de type d'activité
|
title_edit: Edition d'une catégorie de type d'activité
|
||||||
@ -58,18 +58,6 @@ Agent: Utilisateur
|
|||||||
date: Date
|
date: Date
|
||||||
Duration: Durée
|
Duration: Durée
|
||||||
Note: Note
|
Note: Note
|
||||||
5 minutes: 5 minutes
|
|
||||||
10 minutes: 10 minutes
|
|
||||||
15 minutes: 15 minutes
|
|
||||||
20 minutes: 20 minutes
|
|
||||||
25 minutes: 25 minutes
|
|
||||||
30 minutes: 30 minutes
|
|
||||||
45 minutes: 45 minutes
|
|
||||||
1 hour: 1 heure
|
|
||||||
1 hour 15: 1 heure 15
|
|
||||||
1 hour 30: 1 heure 30
|
|
||||||
1 hour 45: 1 heure 45
|
|
||||||
2 hours: 2 heures
|
|
||||||
|
|
||||||
#list
|
#list
|
||||||
My aside activities: Mes activités annexes
|
My aside activities: Mes activités annexes
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Chill\MainBundle;
|
namespace Chill\MainBundle;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Chill\MainBundle\DependencyInjection\CompilerPass\SearchableServicesCompilerPass;
|
use Chill\MainBundle\DependencyInjection\CompilerPass\SearchableServicesCompilerPass;
|
||||||
@ -23,6 +24,10 @@ class ChillMainBundle extends Bundle
|
|||||||
public function build(ContainerBuilder $container)
|
public function build(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
parent::build($container);
|
parent::build($container);
|
||||||
|
|
||||||
|
$container->registerForAutoconfiguration(LocalMenuBuilderInterface::class)
|
||||||
|
->addTag('chill.menu_builder');
|
||||||
|
|
||||||
$container->addCompilerPass(new SearchableServicesCompilerPass());
|
$container->addCompilerPass(new SearchableServicesCompilerPass());
|
||||||
$container->addCompilerPass(new ConfigConsistencyCompilerPass());
|
$container->addCompilerPass(new ConfigConsistencyCompilerPass());
|
||||||
$container->addCompilerPass(new TimelineCompilerClass());
|
$container->addCompilerPass(new TimelineCompilerClass());
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 8839b431f296733b792c788f2ef58e5ecd6419d3
|
Subproject commit bd95d3c96a437757b7e8f35cdfd30da9aeac1a01
|
Loading…
x
Reference in New Issue
Block a user