From 554602ad52818ad2ef28a4e0772a61d7da813ebc Mon Sep 17 00:00:00 2001 From: Yvv Date: Sat, 21 Feb 2026 15:50:31 +0100 Subject: [PATCH] Pin Bloc 0 and Arrivant juste at top of relations list, sort others alphabetically - Rename "Newbie" to "Arrivant juste" - Base friends (Bloc 0, Arrivant juste) always stay at the top - User-added relations are sorted below them Co-Authored-By: Claude Opus 4.6 --- app/components/gratewizard/GwCRA.vue | 2 +- app/components/gratewizard/GwRelations.vue | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/components/gratewizard/GwCRA.vue b/app/components/gratewizard/GwCRA.vue index 7966e8f..3937d6c 100644 --- a/app/components/gratewizard/GwCRA.vue +++ b/app/components/gratewizard/GwCRA.vue @@ -134,7 +134,7 @@ import { Block0Date, getDays, getRatio, dateToString, fr, type Friend, type Tabl const todayDate = dateToString(new Date()); const baseFriends: Friend[] = [ { name: 'Bloc 0', date: Block0Date }, - { name: 'Newbie', date: todayDate }, + { name: 'Arrivant juste', date: todayDate }, ]; const price = useLocalStorage('price', '1'); diff --git a/app/components/gratewizard/GwRelations.vue b/app/components/gratewizard/GwRelations.vue index 994069d..138b7c0 100644 --- a/app/components/gratewizard/GwRelations.vue +++ b/app/components/gratewizard/GwRelations.vue @@ -101,11 +101,19 @@ function toggleSort(key: string) { } const sortedItems = computed(() => { - const items = [...props.items]; + const baseNames = new Set(props.baseFriends.map((f) => f.name)); + const bases: TableFriend[] = []; + const others: TableFriend[] = []; + + for (const item of props.items) { + if (baseNames.has(item.name)) bases.push(item); + else others.push(item); + } + const key = sortKey.value; const dir = sortAsc.value ? 1 : -1; - return items.sort((a, b) => { + others.sort((a, b) => { const first = a[key]; const second = b[key]; let cmp = 0; @@ -123,6 +131,8 @@ const sortedItems = computed(() => { } return cmp * dir; }); + + return [...bases, ...others]; }); function isBaseFriend(friend: TableFriend): boolean {