feat : add project archiving feature

Allow projects to be archived/unarchived from the ProjectDrawer, with a
toggle filter on the projects page to show/hide archived projects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-14 08:58:29 +01:00
parent c0b16ef6dc
commit 0733ac16cd
7 changed files with 157 additions and 15 deletions

View File

@@ -53,6 +53,17 @@
</button>
</div>
</form>
<div v-if="isEditing && project" class="mt-6 border-t border-neutral-200 pt-4">
<button
class="flex items-center gap-2 text-sm text-neutral-500 hover:text-amber-600"
:disabled="isSubmitting"
@click="handleArchiveToggle"
>
<Icon :name="project.archived ? 'mdi:archive-arrow-up-outline' : 'mdi:archive-arrow-down-outline'" size="18" />
{{ project.archived ? 'Désarchiver' : 'Archiver' }}
</button>
</div>
</AppDrawer>
</template>
@@ -171,6 +182,21 @@ async function handleSubmit() {
}
}
async function handleArchiveToggle() {
if (!props.project) return
isSubmitting.value = true
try {
const newArchived = !props.project.archived
await update(props.project.id, { archived: newArchived }, {
toastSuccessKey: newArchived ? 'projects.archived' : 'projects.unarchived',
})
emit('saved')
isOpen.value = false
} finally {
isSubmitting.value = false
}
}
onMounted(async () => {
try {
giteaRepos.value = await listRepositories()

View File

@@ -27,7 +27,11 @@
"projects": {
"created": "Projet créé avec succès.",
"updated": "Projet mis à jour avec succès.",
"deleted": "Projet supprimé avec succès."
"deleted": "Projet supprimé avec succès.",
"archived": "Projet archivé avec succès.",
"unarchived": "Projet désarchivé avec succès.",
"showArchived": "Voir les projets archivés",
"hideArchived": "Masquer les projets archivés"
},
"taskStatuses": {
"created": "Statut créé avec succès.",
@@ -99,6 +103,40 @@
"noTasks": "Aucune tâche",
"backlog": "Backlog"
},
"dashboard": {
"title": "Tableau de bord",
"noData": "Aucune donnée",
"noPriority": "Sans priorité",
"noProject": "Sans projet",
"hoursWorked": "Heures travaillées",
"inProgress": "En cours",
"done": "Terminé",
"stats": {
"hoursThisWeek": "Heures cette semaine",
"myActiveTasks": "Mes tâches actives",
"completed": "terminée(s)",
"totalTasks": "Tâches totales",
"unassigned": "non assignée(s)",
"projects": "Projets",
"users": "utilisateur(s)"
},
"charts": {
"hoursByDay": "Heures par jour (semaine en cours)",
"hoursByProject": "Temps par projet (semaine en cours)",
"tasksByStatus": "Tâches par statut",
"tasksByPriority": "Tâches par priorité",
"tasksByProject": "Tâches par projet"
},
"days": {
"mon": "Lun",
"tue": "Mar",
"wed": "Mer",
"thu": "Jeu",
"fri": "Ven",
"sat": "Sam",
"sun": "Dim"
}
},
"sidebar": {
"myTasks": "Mes tâches"
},

View File

@@ -2,12 +2,24 @@
<div>
<div class="flex items-center justify-between">
<h1 class="text-2xl font-bold text-primary-500">Projets</h1>
<button
class="rounded-md bg-primary-500 px-4 py-2 text-sm font-semibold text-white hover:bg-secondary-500"
@click="openCreate"
>
+ Ajouter un projet
</button>
<div class="flex items-center gap-3">
<button
class="flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition"
:class="showArchived
? 'bg-amber-100 text-amber-700 hover:bg-amber-200'
: 'text-neutral-500 hover:bg-neutral-100 hover:text-neutral-700'"
@click="toggleArchived"
>
<Icon :name="showArchived ? 'mdi:archive-arrow-up-outline' : 'mdi:archive-outline'" size="18" />
{{ showArchived ? $t('projects.hideArchived') : $t('projects.showArchived') }}
</button>
<button
class="rounded-md bg-primary-500 px-4 py-2 text-sm font-semibold text-white hover:bg-secondary-500"
@click="openCreate"
>
+ Ajouter un projet
</button>
</div>
</div>
<div class="mt-6 grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
@@ -15,11 +27,18 @@
v-for="project in projects"
:key="project.id"
class="cursor-pointer rounded-[6px] border border-neutral-200 bg-tertiary-500 p-4 shadow-sm transition hover:shadow-md"
:class="{ 'opacity-60': project.archived }"
@click="navigateTo(`/projects/${project.id}`)"
>
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<h3 class="text-md font-bold" :style="{ color: project.color }">{{ project.name }}</h3>
<span
v-if="project.archived"
class="rounded bg-amber-100 px-1.5 py-0.5 text-xs font-medium text-amber-700"
>
Archivé
</span>
</div>
<button
class="p-1 text-neutral-400 hover:text-primary-500"
@@ -37,7 +56,7 @@
v-if="projects.length === 0 && !isLoading"
class="col-span-full py-12 text-center text-neutral-400"
>
Aucun projet trouvé.
{{ showArchived ? 'Aucun projet archivé.' : 'Aucun projet trouvé.' }}
</div>
</div>
@@ -66,12 +85,13 @@ const clients = ref<Client[]>([])
const isLoading = ref(true)
const drawerOpen = ref(false)
const selectedProject = ref<Project | null>(null)
const showArchived = ref(false)
async function loadData() {
isLoading.value = true
try {
const [p, c] = await Promise.all([
projectService.getAll(),
projectService.getAll({ archived: showArchived.value }),
clientService.getAll(),
])
projects.value = p
@@ -81,6 +101,11 @@ async function loadData() {
}
}
function toggleArchived() {
showArchived.value = !showArchived.value
loadData()
}
function openCreate() {
selectedProject.value = null
drawerOpen.value = true

View File

@@ -10,6 +10,7 @@ export type Project = {
client: Client | null
giteaOwner: string | null
giteaRepo: string | null
archived: boolean
}
export type ProjectWrite = {
@@ -20,4 +21,5 @@ export type ProjectWrite = {
client: string | null // IRI : "/api/clients/1" ou null
giteaOwner?: string | null
giteaRepo?: string | null
archived?: boolean
}

View File

@@ -5,8 +5,9 @@ import { extractHydraMembers } from '~/utils/api'
export function useProjectService() {
const api = useApi()
async function getAll(): Promise<Project[]> {
const data = await api.get<HydraCollection<Project>>('/projects')
async function getAll(params?: { archived?: boolean }): Promise<Project[]> {
const query = params?.archived !== undefined ? `?archived=${params.archived}` : ''
const data = await api.get<HydraCollection<Project>>(`/projects${query}`)
return extractHydraMembers(data)
}
@@ -20,9 +21,9 @@ export function useProjectService() {
})
}
async function update(id: number, payload: Partial<ProjectWrite>): Promise<Project> {
async function update(id: number, payload: Partial<ProjectWrite>, options?: { toastSuccessKey?: string }): Promise<Project> {
return api.patch<Project>(`/projects/${id}`, payload as Record<string, unknown>, {
toastSuccessKey: 'projects.updated',
toastSuccessKey: options?.toastSuccessKey ?? 'projects.updated',
})
}

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260314075537 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE project ADD archived BOOLEAN DEFAULT false NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE project DROP archived');
}
}

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
@@ -31,6 +33,7 @@ use Symfony\Component\Validator\Constraints as Assert;
denormalizationContext: ['groups' => ['project:write']],
order: ['name' => 'ASC'],
)]
#[ApiFilter(BooleanFilter::class, properties: ['archived'])]
#[ORM\Entity(repositoryClass: ProjectRepository::class)]
#[UniqueEntity(fields: ['code'], message: 'Ce code de projet est déjà utilisé.')]
class Project
@@ -48,7 +51,7 @@ class Project
private ?string $code = null;
#[ORM\Column(length: 255)]
#[Groups(['project:read', 'project:write', 'time_entry:read'])]
#[Groups(['project:read', 'project:write', 'time_entry:read', 'task:read'])]
private ?string $name = null;
#[ORM\Column(type: 'text', nullable: true)]
@@ -56,7 +59,7 @@ class Project
private ?string $description = null;
#[ORM\Column(length: 7)]
#[Groups(['project:read', 'project:write', 'time_entry:read'])]
#[Groups(['project:read', 'project:write', 'time_entry:read', 'task:read'])]
private ?string $color = '#222783';
#[ORM\ManyToOne(targetEntity: Client::class, inversedBy: 'projects')]
@@ -72,6 +75,10 @@ class Project
#[Groups(['project:read', 'project:write', 'task:read'])]
private ?string $giteaRepo = null;
#[ORM\Column]
#[Groups(['project:read', 'project:write'])]
private bool $archived = false;
public function getId(): ?int
{
return $this->id;
@@ -165,4 +172,16 @@ class Project
{
return null !== $this->giteaOwner && null !== $this->giteaRepo;
}
public function isArchived(): bool
{
return $this->archived;
}
public function setArchived(bool $archived): static
{
$this->archived = $archived;
return $this;
}
}