<h1>{{ "Update calendar"|trans }}</h1>

{{ form_start(form) }}
{{ form_errors(form) }}

<div id="calendar"></div> {# <=== vue component #}

<div id="mainUser"></div> {# <=== vue component: mainUser #}

<h2 class="chill-red">{{ 'Concerned groups calendar'|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>

<div id="schedule"></div>

{%- if form.location is defined -%}
    {{ form_row(form.location) }}
    <div id="location"></div>
{% endif %}

{%- if form.startDate is defined -%}
    {{ form_row(form.startDate) }}
{% endif %}

{%- if form.endDate is defined -%}
    {{ form_row(form.endDate) }}
{% endif %}

{%- if form.calendarRange is defined -%}
    {{ form_row(form.calendarRange) }}
{% endif %}

<div id="fullCalendar"></div>

{%- if form.comment is defined -%}
    {{ form_row(form.comment) }}
{% endif %}

{%- if form.privateComment is defined -%}
    {{ form_row(form.privateComment) }}
{% endif %}

{%- if form.sendSMS is defined -%}
    {{ form_row(form.sendSMS) }}
{% endif %}

{% if context == 'user' %}
    <div id="calendarControls"></div>
{% endif %}


<ul class="record_actions sticky-form-buttons">
  <li class="cancel">
    <a
      class="btn btn-cancel"
      {%- if context == 'user' -%}
      href="{{ chill_return_path_or('chill_calendar_calendar_list', { 'user_id': user.id } )}}"
      {%- elseif context == 'accompanyingCourse' -%}
      href="{{ chill_return_path_or('chill_calendar_calendar_list_by_period', { 'id': accompanyingCourse.id } )}}"
      {%- endif -%}
      >
      {{ 'Cancel'|trans|chill_return_path_label }}
    </a>
  </li>
    {% if templates|length == 0  %}
        <li>
            {{ form_widget(form.save_and_upload_doc, { 'attr' : { 'class' : 'btn btn-create' }, 'label':  'chill_calendar.Create and add a document'|trans }) }}
        </li>
    {% else %}
        <li>
            <div class="dropdown">
                <button class="btn btn-create dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                    {{ 'chill_calendar.Add a document'|trans }}
                </button>

                <ul class="dropdown-menu">
                    <li>
                        {{ form_widget(form.save_and_upload_doc, { 'attr' : { 'class' : 'dropdown-item' }, 'label':  'chill_calendar.Upload a document'|trans }) }}
                    </li>
                    {% for template in templates %}
                        {{ form_widget(form['save_and_generate_doc_' ~ template.id ], {'attr' : { 'class' : 'dropdown-item'}}) }}
                    {% endfor %}
                </ul>
            </div>
        </li>
    {% endif %}
    <li>
        {{ form_widget(form.save, { 'attr' : { 'class' : 'btn btn-create' }, 'label':  'Save'|trans }) }}
    </li>
</ul>
{{ form_end(form) }}

