{% extends 'base.html.twig' %} {% block title %}Mes prompts — Promptly{% endblock %} {% block body %} {% set ptColor = tool_color_details['promptly'] %} {% set isRootView = currentFolder is null %} {% set folderParam = currentFolder ? (currentFolder.id ~ '') : '' %} {% set foldersToShow = isRootView ? rootFolders : subfolders %} {% set hasFolders = foldersToShow is not empty %} {% set hasPrompts = prompts is not empty %}
{# ================================================================ HEADER — fil d'ariane + CTAs ================================================================ #}
{% include '_atoms/button/button.html.twig' with { label: 'Nouveau dossier', outlineHex: ptColor.primary, size: 'md', icon: 'folder', mobileIconOnly: true, mobileBreakpoint: 'sm', type: 'button', attr: { 'data-action': 'click->promptly--mes-prompts#createFolder', 'data-parent-id': not isRootView ? (currentFolder.id ~ '') : '' } } only %} {% include '_atoms/button/button.html.twig' with { label: 'Nouveau prompt', variant: 'primary', size: 'md', icon: 'plus', gradientFrom: ptColor.primary, gradientTo: ptColor.secondary, mobileIconOnly: true, mobileBreakpoint: 'sm', href: path('app_promptly_create_page') } only %}
{# ================================================================ LISTE UNIFIÉE (dossiers en haut, prompts en dessous) ================================================================ #}
{# En-tête de colonnes — toujours visible #}
Nom
{# État vide — cible JS (affiché si le dernier élément est glissé hors de la liste) #}
{% include '_atoms/icon/icon.html.twig' with { name: 'folder', size: 'xl', color: 'current' } only %}

Ce dossier est vide

Créez un prompt ou un dossier pour commencer

{% if hasFolders or hasPrompts %}
{# Dossiers (toujours en premier) #} {% for folder in foldersToShow %} {% include 'promptly/_folder_card.html.twig' with { folder: folder, promptCount: folderPromptCounts[folder.id] ?? 0, isLast: (loop.last and not hasPrompts) } only %} {% endfor %} {# Séparateur dossiers / prompts #} {% if hasFolders and hasPrompts %}
{% endif %} {# Prompts #} {% for prompt in prompts %} {% set category = prompt.categoryData %} {% set cardColor = category ? category.colorHex : '#6366F1' %} {% set cardIcon = category ? category.icon : 'magic-stick' %} {% set lastDate = prompt.updatedAt ?? prompt.createdAt %} {# Date relative #} {% set nowTs = 'now'|date('U') %} {% set thenTs = lastDate|date('U') %} {% set diffSec = nowTs - thenTs %} {% if diffSec < 3600 %} {% set relDate = 'À l\'instant' %} {% elseif diffSec < 7200 %} {% set relDate = 'Il y a 1 h' %} {% elseif diffSec < 86400 %} {% set relDate = 'Il y a ' ~ (diffSec / 3600)|round ~ ' h' %} {% elseif diffSec < 172800 %} {% set relDate = 'Hier' %} {% elseif diffSec < 604800 %} {% set relDate = 'Il y a ' ~ (diffSec / 86400)|round ~ ' j' %} {% elseif diffSec < 2592000 %} {% set relDate = 'Il y a ' ~ (diffSec / 604800)|round ~ ' sem.' %} {% else %} {% set relDate = lastDate|date('d/m/y') %} {% endif %}
{# Icône catégorie #}
{% include '_atoms/icon/icon.html.twig' with { name: cardIcon, size: 'sm', color: 'current' } only %}
{# Titre + description + badges #}
{{ prompt.title }} {% if prompt.isDraft %} {% include '_atoms/badge/badge.html.twig' with { label: 'Brouillon', variant: 'warning', size: 'xs' } only %} {% elseif prompt.visibility == 'public' %} {% include '_atoms/badge/badge.html.twig' with { label: 'Public', variant: 'primary', size: 'xs' } only %} {% else %} {% include '_atoms/icon/icon.html.twig' with { name: 'lock', size: 'xs', color: 'current' } only %} Privé {% endif %}

{{ prompt.description ?: prompt.cleanPreview(80) }}

{# Catégorie #} {# Favoris #} {# Utilisations #} {# Date modifiée #} {# ⋮ Actions #}
{% include '_molecules/action-menu/action-menu.html.twig' with { withTrigger: true, position: 'right-0 top-full mt-1', items: [ {label: 'Ouvrir', icon: 'arrow-right', href: path('app_promptly_show', { id: prompt.id, from: 'mes-prompts', folder: currentFolder ? currentFolder.id : null })}, {label: 'Éditer le prompt', icon: 'edit', href: path('app_promptly_edit_page', { id: prompt.id })}, {label: 'Déplacer', icon: 'folder', attr: {'data-action': 'click->promptly--mes-prompts#openMovePrompt', 'data-prompt-id': prompt.id}} ], dangerItems: [ {label: 'Supprimer', icon: 'trash', attr: {'data-action': 'click->promptly--mes-prompts#openDeletePrompt', 'data-prompt-id': prompt.id, 'data-prompt-title': prompt.title}} ], accentHex: tool_color_details['promptly'].primary } only %}
{% endfor %}
{# /scrollable rows #} {% endif %}
{# /listContainer #}
{# /homeView #} {# ── Cibles Stimulus compatibilité promptly--library ── #}
{# MODALS BIBLIOTHÈQUE #} {% include 'promptly/_modals.html.twig' with { categories: categories, aiModels: aiModels } only %} {# MODAL CRÉER UN DOSSIER #} {# MODAL RENOMMER UN DOSSIER #} {# MODAL SUPPRIMER UN DOSSIER #} {% embed '_organisms/delete-modal/delete-modal.html.twig' with { modalAttr: {'data-promptly--mes-prompts-target': 'deleteModal'}, cancelAttr: {'data-action': 'click->promptly--mes-prompts#closeModal'}, confirmAttr: {'data-action': 'click->promptly--mes-prompts#confirmDelete'} } only %} {% block titleBlock %}

Supprimer « » ?

{% endblock %} {% block description %}

Cette action est irréversible. Tous les prompts et sous-dossiers seront supprimés.

{% endblock %} {% endembed %} {# MODAL DÉPLACER UN PROMPT #} {# MODAL SUPPRIMER UN PROMPT #} {% embed '_organisms/delete-modal/delete-modal.html.twig' with { modalAttr: {'data-promptly--mes-prompts-target': 'deletePromptModal'}, cancelAttr: {'data-action': 'click->promptly--mes-prompts#closeModal'}, confirmAttr: {'data-action': 'click->promptly--mes-prompts#confirmDeletePrompt'} } only %} {% block titleBlock %}

Supprimer « » ?

{% endblock %} {% block description %}

Cette action est irréversible.

{% endblock %} {% endembed %}
{% endblock %}