forked from yvv/decision
v2 : désignation « c'est moi » dans un collectif importé (correctif QA)
- les seeds (Ğ1, Atelier) n'ont aucun isMe : la carte identité propose désormais de se désigner parmi les personnes existantes (chips) ou de s'ajouter (formulaire), au lieu d'un état vide sans issue - vitest 13 fichiers verts, build zéro erreur Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,37 @@ function removeRow(index: number) {
|
|||||||
rows.value.splice(index, 1)
|
rows.value.splice(index, 1)
|
||||||
commitAttributes()
|
commitAttributes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── « C'est moi » — un collectif importé (seed, fichier) n'a aucun isMe :
|
||||||
|
// on se désigne parmi les personnes existantes, ou on s'ajoute.
|
||||||
|
const newMeName = ref('')
|
||||||
|
|
||||||
|
function claimMe(personId: string) {
|
||||||
|
const current = store.current
|
||||||
|
if (!current || store.me) return
|
||||||
|
const person = current.people.find(p => p.id === personId && !p.archivedAt)
|
||||||
|
if (!person) return
|
||||||
|
person.isMe = true
|
||||||
|
store.stamp(person)
|
||||||
|
store.persist()
|
||||||
|
}
|
||||||
|
|
||||||
|
function createMe() {
|
||||||
|
const current = store.current
|
||||||
|
const displayName = newMeName.value.trim()
|
||||||
|
if (!current || store.me || !displayName) return
|
||||||
|
const now = store.now()
|
||||||
|
current.people.push({
|
||||||
|
id: store.newId(),
|
||||||
|
collectiveId: current.collective.id,
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
displayName,
|
||||||
|
isMe: true,
|
||||||
|
})
|
||||||
|
newMeName.value = ''
|
||||||
|
store.persist()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -72,10 +103,42 @@ function removeRow(index: number) {
|
|||||||
<UIcon name="i-lucide-user-round" /> Mon identité
|
<UIcon name="i-lucide-user-round" /> Mon identité
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<p v-if="!store.me" class="data-card__empty">
|
<p v-if="!store.current" class="data-card__empty">
|
||||||
Aucun collectif actif — crée ou importe un collectif pour poser ton identité.
|
Aucun collectif actif — crée ou importe un collectif pour poser ton identité.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<template v-else-if="!store.me">
|
||||||
|
<p class="data-card__text">
|
||||||
|
Personne n'est encore désigné·e comme toi dans ce collectif —
|
||||||
|
retrouve-toi dans la liste, ou ajoute-toi.
|
||||||
|
</p>
|
||||||
|
<div class="claim-chips">
|
||||||
|
<button
|
||||||
|
v-for="person in store.people"
|
||||||
|
:key="person.id"
|
||||||
|
type="button"
|
||||||
|
class="claim-chip"
|
||||||
|
@click="claimMe(person.id)"
|
||||||
|
>
|
||||||
|
<UIcon name="i-lucide-user-round-check" />
|
||||||
|
<span>{{ person.displayName }}</span>
|
||||||
|
<span class="claim-chip__me">c'est moi</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form class="claim-new" @submit.prevent="createMe">
|
||||||
|
<input
|
||||||
|
v-model="newMeName"
|
||||||
|
class="field__input claim-new__input"
|
||||||
|
type="text"
|
||||||
|
placeholder="Ton prénom ici"
|
||||||
|
autocomplete="off"
|
||||||
|
>
|
||||||
|
<button type="submit" class="ld-btn" :disabled="newMeName.trim().length === 0">
|
||||||
|
<UIcon name="i-lucide-plus" /> Je m'ajoute
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field__label">Comment tu t'appelles ici</span>
|
<span class="field__label">Comment tu t'appelles ici</span>
|
||||||
@@ -223,4 +286,44 @@ function removeRow(index: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.attr-add { align-self: flex-start; }
|
.attr-add { align-self: flex-start; }
|
||||||
|
|
||||||
|
/* « C'est moi » — désignation dans un collectif importé */
|
||||||
|
.claim-chips {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.claim-chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.4rem;
|
||||||
|
min-height: 2.25rem;
|
||||||
|
padding: 0.35rem 0.8rem;
|
||||||
|
border-radius: var(--r-pill);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 600;
|
||||||
|
background: var(--mood-input-bg);
|
||||||
|
color: var(--mood-text);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.1s ease, transform 0.1s ease;
|
||||||
|
}
|
||||||
|
.claim-chip:hover {
|
||||||
|
background: var(--mood-accent-soft);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
.claim-chip:active { transform: translateY(0); }
|
||||||
|
|
||||||
|
.claim-chip__me {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--mood-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.claim-new {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
.claim-new__input { flex: 1; min-width: 0; }
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user