{% extends 'sam/layout.html.twig' %} {% block title %}Cohortes - SAM{% endblock %} {% block sam_body %}
{# ══════════════════════════════════════════════════════════════ BREADCRUMB ══════════════════════════════════════════════════════════════ #} {% include '_molecules/breadcrumb/breadcrumb.html.twig' with { showHome: false, items: [ { label: 'Dashboard', href: path('app_sam_index') }, { label: 'Cohortes' } ], class: 'mb-6' } %} {# ══════════════════════════════════════════════════════════════ PAGE HEADER ══════════════════════════════════════════════════════════════ #}
{% include '_atoms/icon/icon.html.twig' with { name: 'users-group', size: 'xl', color: 'cohorts' } only %}

Gestion des cohortes

Consultez, modifiez et gérez vos {{ total }} cohorte{{ total > 1 ? 's' : '' }} Moodle

{# Sync button — keeps custom SVG for spin animation via Stimulus target #} {# Create cohort button #} {% include '_atoms/button/button.html.twig' with { label: 'Créer une cohorte', variant: 'cohorts', size: 'md', icon: 'plus', iconPosition: 'left', attr: { 'data-action': 'click->sam--cohort-crud#openAddModal' } } only %}
{# ══════════════════════════════════════════════════════════════ FILTRES ══════════════════════════════════════════════════════════════ #} {% if cohorts|length > 0 %} {# Collecter toutes les formations uniques #} {% set allCourses = [] %} {% set seenShortnames = [] %} {% for cohort in cohorts %} {% for course in cohortCourses[cohort.id] ?? [] %} {% if course.shortname not in seenShortnames %} {% set allCourses = allCourses|merge([course]) %} {% set seenShortnames = seenShortnames|merge([course.shortname]) %} {% endif %} {% endfor %} {% endfor %}
{# ── Recherche texte ── #}
{% include '_atoms/icon/icon.html.twig' with { name: 'search', size: 'md', color: 'muted' } only %}
{# ── Dropdown Formations ── #} {% if allCourses|length > 0 %}
{% endif %} {# ── Dropdown Membres ── #}
{# ── Réinitialiser ── #}
{% endif %} {# ══════════════════════════════════════════════════════════════ CONTENT — DATA TABLE ══════════════════════════════════════════════════════════════ #} {% if cohorts|length == 0 %}
{% include '_molecules/empty-state/empty-state.html.twig' with { title: 'Aucune cohorte trouvée', description: 'Synchronisez les données depuis Moodle ou créez une nouvelle cohorte.', icon: 'users-group' } %}
{% else %} {# No results message (hidden by default, shown by JS filter) #} {# Data table #}
{# Table header #}
Cohorte Membres Formations Actions
{# Table body #} {% for cohort in cohorts %} {% set enrolledCourses = cohortCourses[cohort.id] ?? [] %}
{# Cohorte : avatar + nom #}
{% include '_atoms/avatar/avatar.html.twig' with { initials: cohort.name|slice(0, 2)|upper, size: 'sm', rounded: 'lg', variant: 'cohorts' } only %}
{{ cohort.name }}
{% if cohort.idnumber %} {{ cohort.idnumber }} {% elseif cohort.description %}

{{ cohort.description|slice(0, 50) }}{{ cohort.description|length > 50 ? '…' : '' }}

{% endif %}
{# Membres #}
{% include '_atoms/icon/icon.html.twig' with { name: 'users', size: 'sm', color: 'cohorts' } only %} {{ cohort.membersCount }} membre{{ cohort.membersCount != 1 ? 's' : '' }}
{# Formations (tags) #}
{% if enrolledCourses|length > 0 %} {% for course in enrolledCourses|slice(0, 3) %} {% include '_atoms/badge/badge.html.twig' with { label: course.fullname|slice(0, 18) ~ (course.fullname|length > 18 ? '…' : ''), variant: 'cohorts', size: 'xs' } %} {% endfor %} {% if enrolledCourses|length > 3 %} {% include '_atoms/badge/badge.html.twig' with { label: '+' ~ (enrolledCourses|length - 3), variant: 'neutral', size: 'xs' } %} {% endif %} {% else %} Aucun cours {% endif %}
{# Row actions — stopPropagation pour éviter la navigation #}
{# Edit #} {% include '_atoms/button/button.html.twig' with { variant: 'ghost', size: 'sm', icon: 'edit', iconOnly: true, class: 'text-gray-400 hover:text-primary hover:bg-primary/10 shrink-0', attr: { 'data-action': 'click->sam--cohort-crud#openEditModal:stop', 'data-cohort-id': cohort.moodleId, 'data-name': cohort.name, 'data-idnumber': cohort.idnumber, 'data-description': cohort.description } } %} {# Delete #} {% include '_atoms/button/button.html.twig' with { variant: 'ghost', size: 'sm', icon: 'trash', iconOnly: true, class: 'text-gray-400 hover:text-error hover:bg-error/10 shrink-0', attr: { 'data-action': 'click->sam--cohort-crud#confirmDelete:stop', 'data-cohort-id': cohort.moodleId, 'data-name': cohort.name } } %}
{% endfor %} {# Table footer — pagination #}
{{ total }} cohorte{{ total > 1 ? 's' : '' }} {% if totalPages > 1 %} {% include '_molecules/pagination/pagination.html.twig' with { currentPage: page, totalPages: totalPages, baseUrl: path('app_sam_cohorts'), size: 'sm', showFirstLast: false } %} {% endif %}
{% endif %} {# Footer #}

© Bubul {{ "now"|date("Y") }} {% if lastSyncedAt is defined and lastSyncedAt %} · Synchronisé le {{ lastSyncedAt|date('d/m/Y à H:i') }} {% else %} · Non synchronisé {% endif %}

{# ══════════════════════════════════════════════════════════════ MODAL CRÉATION/ÉDITION ══════════════════════════════════════════════════════════════ #} {# ══════════════════════════════════════════════════════════════ MODAL MEMBRES ══════════════════════════════════════════════════════════════ #} {# ══════════════════════════════════════════════════════════════ MODAL SUPPRESSION ══════════════════════════════════════════════════════════════ #}
{% endblock %}