mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
rdv: others pages: edit, list
This commit is contained in:
parent
d4ec5d137e
commit
7e02b284ca
@ -100,45 +100,6 @@ class CalendarController extends AbstractController
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function selectTypeAction(Request $request): Response
|
|
||||||
// {
|
|
||||||
// $em = $this->getDoctrine()->getManager();
|
|
||||||
// $view = null;
|
|
||||||
|
|
||||||
// [$person, $accompanyingPeriod] = $this->getEntity($request);
|
|
||||||
|
|
||||||
// if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
|
||||||
// $view = 'ChillCalendarBundle:Calendar:selectTypeAccompanyingCourse.html.twig';
|
|
||||||
// } elseif ($person instanceof Person) {
|
|
||||||
// $view = 'ChillCalendarBundle:Calendar:selectTypePerson.html.twig';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $data = [];
|
|
||||||
|
|
||||||
// $activityTypeCategories = $em->getRepository(\Chill\CalendarBundle\Entity\ActivityTypeCategory::class)
|
|
||||||
// ->findBy(['active' => true], ['ordering' => 'ASC']);
|
|
||||||
|
|
||||||
// foreach ($activityTypeCategories as $activityTypeCategory) {
|
|
||||||
// $activityTypes = $em->getRepository(\Chill\ActivityBundle\Entity\ActivityType::class)
|
|
||||||
// ->findBy(['active' => true, 'category' => $activityTypeCategory], ['ordering' => 'ASC']);
|
|
||||||
|
|
||||||
// $data[] = [
|
|
||||||
// 'activityTypeCategory' => $activityTypeCategory,
|
|
||||||
// 'activityTypes' => $activityTypes,
|
|
||||||
// ];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if ($view === null) {
|
|
||||||
// throw $this->createNotFoundException('Template not found');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return $this->render($view, [
|
|
||||||
// 'person' => $person,
|
|
||||||
// 'accompanyingCourse' => $accompanyingPeriod,
|
|
||||||
// 'data' => $data,
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new calendar item
|
* Create a new calendar item
|
||||||
* @Route("/{_locale}/calendar/new", name="chill_calendar_calendar_new")
|
* @Route("/{_locale}/calendar/new", name="chill_calendar_calendar_new")
|
||||||
@ -251,7 +212,7 @@ class CalendarController extends AbstractController
|
|||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
[$person, $accompanyingPeriod] = $this->getEntity($request);
|
[$user, $accompanyingPeriod] = $this->getEntity($request);
|
||||||
|
|
||||||
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
if ($accompanyingPeriod instanceof AccompanyingPeriod) {
|
||||||
$view = 'ChillCalendarBundle:Calendar:editAccompanyingCourse.html.twig';
|
$view = 'ChillCalendarBundle:Calendar:editAccompanyingCourse.html.twig';
|
||||||
@ -267,9 +228,6 @@ class CalendarController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm(CalendarType::class, $entity, [
|
$form = $this->createForm(CalendarType::class, $entity, [
|
||||||
'center' => $entity->getCenter(),
|
|
||||||
'role' => new Role('CHILL_ACTIVITY_UPDATE'),
|
|
||||||
'activityType' => $entity->getType(),
|
|
||||||
'accompanyingPeriod' => $accompanyingPeriod,
|
'accompanyingPeriod' => $accompanyingPeriod,
|
||||||
])->handleRequest($request);
|
])->handleRequest($request);
|
||||||
|
|
||||||
@ -279,25 +237,25 @@ class CalendarController extends AbstractController
|
|||||||
|
|
||||||
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
|
$this->addFlash('success', $this->get('translator')->trans('Success : activity updated!'));
|
||||||
|
|
||||||
$params = $this->buildParamsToUrl($person, $accompanyingPeriod);
|
$params = $this->buildParamsToUrl($user, $accompanyingPeriod);
|
||||||
$params['id'] = $id;
|
$params['id'] = $id;
|
||||||
return $this->redirectToRoute('chill_activity_activity_show', $params);
|
return $this->redirectToRoute('chill_activity_activity_show', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$deleteForm = $this->createDeleteForm($id, $person, $accompanyingPeriod);
|
$deleteForm = $this->createDeleteForm($id, $user, $accompanyingPeriod);
|
||||||
|
|
||||||
if ($view === null) {
|
if ($view === null) {
|
||||||
throw $this->createNotFoundException('Template not found');
|
throw $this->createNotFoundException('Template not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
$entity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||||
|
|
||||||
return $this->render($view, array(
|
return $this->render($view, array(
|
||||||
'entity' => $entity,
|
'entity' => $entity,
|
||||||
'edit_form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'delete_form' => $deleteForm->createView(),
|
'delete_form' => $deleteForm->createView(),
|
||||||
'accompanyingCourse' => $accompanyingPeriod,
|
'accompanyingCourse' => $accompanyingPeriod,
|
||||||
'activity_json' => $activity_array
|
'entity_json' => $entity_array
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ use Chill\CalendarBundle\Entity\CalendarRange;
|
|||||||
use Chill\CalendarBundle\Entity\Invite;
|
use Chill\CalendarBundle\Entity\Invite;
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||||
|
use DateInterval;
|
||||||
|
use DateTimeImmutable;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||||
@ -51,7 +53,7 @@ class Calendar
|
|||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
*/
|
*/
|
||||||
private User $mainUser;
|
private ?User $mainUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -416,7 +418,6 @@ class Calendar
|
|||||||
return $this->getInvites(); //TODO get users of the invite
|
return $this->getInvites(); //TODO get users of the invite
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
public static function loadValidatorMetadata(ClassMetadata $metadata): void
|
||||||
{
|
{
|
||||||
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
$metadata->addPropertyConstraint('startDate', new NotBlank());
|
||||||
|
@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\CommentType;
|
|||||||
use Chill\CalendarBundle\Entity\Calendar;
|
use Chill\CalendarBundle\Entity\Calendar;
|
||||||
use Chill\CalendarBundle\Entity\CancelReason;
|
use Chill\CalendarBundle\Entity\CancelReason;
|
||||||
use Chill\CalendarBundle\Entity\Invite;
|
use Chill\CalendarBundle\Entity\Invite;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
@ -43,6 +44,14 @@ class CalendarType extends AbstractType
|
|||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
|
->add('mainUser', EntityType::class, array(
|
||||||
|
'required' => true,
|
||||||
|
'class' => User::class,
|
||||||
|
'choice_label' => function (User $entity) {
|
||||||
|
return $entity->getUsernameCanonical();
|
||||||
|
},
|
||||||
|
// TODO 'empty_data' =>
|
||||||
|
))
|
||||||
->add('comment', CommentType::class, array(
|
->add('comment', CommentType::class, array(
|
||||||
'required' => false
|
'required' => false
|
||||||
))
|
))
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
<h1>{{ "Update calendar"|trans }}</h1>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
|
{%- if form.mainUser is defined -%}
|
||||||
|
{{ form_row(form.mainUser) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if form.persons is defined -%}
|
||||||
|
{{ form_widget(form.persons) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.professionals is defined -%}
|
||||||
|
{{ form_widget(form.professionals) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.nonProfessionals is defined -%}
|
||||||
|
{{ form_widget(form.nonProfessionals) }}
|
||||||
|
{% endif %}
|
||||||
|
{%- if form.users is defined -%}
|
||||||
|
{{ form_widget(form.users) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="add-persons"></div>
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Calendar data'|trans }}</h2>
|
||||||
|
|
||||||
|
{%- if form.startDate is defined -%}
|
||||||
|
{{ form_row(form.startDate) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.endDate is defined -%}
|
||||||
|
{{ form_row(form.endDate) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
.. location
|
||||||
|
|
||||||
|
{%- if form.cancelReason is defined -%}
|
||||||
|
{{ form_row(form.cancelReason) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.comment is defined -%}
|
||||||
|
{{ form_row(form.comment) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if form.sendSMS is defined -%}
|
||||||
|
{{ form_row(form.sendSMS) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
..calendarRange
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ul class="record_actions sticky-form-buttons">
|
||||||
|
<li class="cancel">
|
||||||
|
<a
|
||||||
|
class="btn btn-cancel"
|
||||||
|
{%- if context == 'person' -%}
|
||||||
|
href="{{ chill_return_path_or('chill_calendar_calendar', { 'person_id': person.id } )}}"
|
||||||
|
{%- else -%}
|
||||||
|
href="{{ chill_return_path_or('chill_calendar_calendar', { 'accompanying_period_id': accompanyingCourse.id } )}}"
|
||||||
|
{%- endif -%}
|
||||||
|
>
|
||||||
|
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="btn btn-create" type="submit">
|
||||||
|
{{ 'Create'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
{{ form_end(form) }}
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_calendar_calendar_list' %}
|
||||||
|
|
||||||
|
{% block title 'Update calendar'|trans %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="calendar-edit">
|
||||||
|
<div class="row justify-content-center">
|
||||||
|
<div class="col-md-10 col-xxl">
|
||||||
|
|
||||||
|
<div id="calendar"></div> {# <=== vue component #}
|
||||||
|
{% include 'ChillCalendarBundle:Calendar:edit.html.twig' with {'context': 'accompanyingCourse'} %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.addEventListener('DOMContentLoaded', function (e) {
|
||||||
|
chill.displayAlertWhenLeavingModifiedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
||||||
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
|
});
|
||||||
|
window.calendar = {{ entity_json|json_encode|raw }};
|
||||||
|
</script>
|
||||||
|
{{ encore_entry_script_tags('vue_calendar') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{{ parent() }}
|
||||||
|
{{ encore_entry_link_tags('async_upload') }}
|
||||||
|
{{ encore_entry_link_tags('vue_calendar') }}
|
||||||
|
{% endblock %}
|
@ -21,31 +21,22 @@
|
|||||||
|
|
||||||
{% for calendar in calendarItems %}
|
{% for calendar in calendarItems %}
|
||||||
|
|
||||||
|
|
||||||
{% set t = calendar.type %}
|
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
<div class="item-row main">
|
<div class="item-row main">
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
|
|
||||||
{% if calendar.date %}
|
{% if calendar.startDate %}
|
||||||
<h3>{{ calendar.date|format_date('long') }}</h3>
|
<h3>{{ calendar.startDate|format_date('long') }} </h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="duration">
|
{% if calendar.endDate %}
|
||||||
{% if t.durationTimeVisible > 0 %}
|
<h3>{{ calendar.endDate|format_date('long') }}</h3>
|
||||||
<p>
|
{% endif %}
|
||||||
<i class="fa fa-fw fa-hourglass-end"></i>
|
|
||||||
{{ calendar.durationTime|date('H:i') }}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
<h3>{{ calendar.endDate.diff(calendar.startDate)|date("%i'%s''") }}</h3>
|
||||||
|
|
||||||
{% if calendar.travelTime and t.travelTimeVisible %}
|
|
||||||
<p>
|
|
||||||
<i class="fa fa-fw fa-car"></i>
|
|
||||||
{{ calendar.travelTime|date('H:i') }}
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if context == 'user' and calendar.accompanyingPeriod is not empty %}
|
{% if context == 'user' and calendar.accompanyingPeriod is not empty %}
|
||||||
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
<div class="accompanyingPeriodLink" style="margin-top: 1rem">
|
||||||
@ -64,68 +55,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
<ul class="list-content">
|
<ul class="list-content">
|
||||||
{% if calendar.user and t.userVisible %}
|
{% if calendar.user %}
|
||||||
<li>
|
<li>
|
||||||
<b>{{ 'by'|trans }}{{ calendar.user.usernameCanonical }}</b>
|
<b>{{ 'by'|trans }}{{ calendar.user.usernameCanonical }}</b>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if calendar.mainUser is not empty %}
|
||||||
<li>
|
<li>
|
||||||
<b>{{ calendar.type.name | localize_translatable_string }}</b>
|
<b>{{ 'main user concerned'|trans }}{{ calendar.mainUser.usernameCanonical }}</b>
|
||||||
|
|
||||||
{% if calendar.attendee is not null and t.attendeeVisible %}
|
|
||||||
{% if calendar.attendee %}
|
|
||||||
{{ '→ ' ~ 'present'|trans|capitalize }}
|
|
||||||
{% else %}
|
|
||||||
{{ '→ ' ~ 'not present'|trans|capitalize }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<b>{{ 'location'|trans ~ ': ' }}</b>
|
{%- if calendar.comment.isEmpty -%}
|
||||||
Domicile de l'usager
|
<span class="chill-no-data-statement">{{ 'No comments'|trans }}</span>
|
||||||
{#
|
|
||||||
{% if calendar.location %}{{ calendar.location }}{% endif %}
|
|
||||||
#}
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{%- if t.reasonsVisible -%}
|
|
||||||
<li>
|
|
||||||
{%- if calendar.reasons is empty -%}
|
|
||||||
<span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span>
|
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{% for r in calendar.reasons %}
|
{{ calendar.comment|chill_entity_render_box }}
|
||||||
{{ r|chill_entity_render_box }}
|
|
||||||
{% endfor %}
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- if t.socialIssuesVisible %}
|
|
||||||
<li class="social-issues">
|
|
||||||
{%- if calendar.socialIssues is empty -%}
|
|
||||||
<span class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</span>
|
|
||||||
{%- else -%}
|
|
||||||
{% for r in calendar.socialIssues %}
|
|
||||||
{{ r|chill_entity_render_box }}
|
|
||||||
{% endfor %}
|
|
||||||
{%- endif -%}
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- if t.socialActionsVisible -%}
|
|
||||||
<li class="social-actions">
|
|
||||||
{%- if calendar.socialActions is empty -%}
|
|
||||||
<span class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</span>
|
|
||||||
{%- else -%}
|
|
||||||
{% for r in calendar.socialActions %}
|
|
||||||
<span class="badge bg-primary">{{ r.title|localize_translatable_string }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
{%- endif -%}
|
|
||||||
</li>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
@ -161,7 +111,7 @@
|
|||||||
<div class="item-row details">
|
<div class="item-row details">
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
|
|
||||||
{% include 'ChillCalendarBundle:Calendar:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': calendar } %}
|
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'row', 'entity': calendar } %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if calendar.comment.comment is not empty %}
|
{% if calendar.comment.comment is not empty %}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{ form_errors(form) }}
|
{{ form_errors(form) }}
|
||||||
|
|
||||||
{%- if form.mainUser is defined -%}
|
{%- if form.mainUser is defined -%}
|
||||||
{{ form_widget(form.mainUser) }}
|
{{ form_row(form.mainUser) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<h1>{{ "Calendar"|trans }}</h1>
|
<h1>{{ "Calendar"|trans }}</h1>
|
||||||
|
|
||||||
<dl class="chill_view_data">
|
<dl class="chill_view_data">
|
||||||
|
<dt class="inline">{{ 'main user'|trans }}</dt>
|
||||||
|
<dd>{{ entity.mainUser }}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
@ -19,7 +20,7 @@
|
|||||||
<dt class="inline">{{ 'cancel reason'|trans }}</dt>
|
<dt class="inline">{{ 'cancel reason'|trans }}</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{% if entity.cancelReason is not null %}
|
{% if entity.cancelReason is not null %}
|
||||||
{{ entity.cancelReason }}
|
{{ entity.cancelReason.canceledBy|localize_translatable_string }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="chill-no-data-statement">{{ 'Unknown'|trans }}</span>
|
<span class="chill-no-data-statement">{{ 'Unknown'|trans }}</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user