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 <noreply@anthropic.com>
This commit is contained in:
@@ -134,7 +134,7 @@ import { Block0Date, getDays, getRatio, dateToString, fr, type Friend, type Tabl
|
|||||||
const todayDate = dateToString(new Date());
|
const todayDate = dateToString(new Date());
|
||||||
const baseFriends: Friend[] = [
|
const baseFriends: Friend[] = [
|
||||||
{ name: 'Bloc 0', date: Block0Date },
|
{ name: 'Bloc 0', date: Block0Date },
|
||||||
{ name: 'Newbie', date: todayDate },
|
{ name: 'Arrivant juste', date: todayDate },
|
||||||
];
|
];
|
||||||
|
|
||||||
const price = useLocalStorage('price', '1');
|
const price = useLocalStorage('price', '1');
|
||||||
|
|||||||
@@ -101,11 +101,19 @@ function toggleSort(key: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sortedItems = computed(() => {
|
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 key = sortKey.value;
|
||||||
const dir = sortAsc.value ? 1 : -1;
|
const dir = sortAsc.value ? 1 : -1;
|
||||||
|
|
||||||
return items.sort((a, b) => {
|
others.sort((a, b) => {
|
||||||
const first = a[key];
|
const first = a[key];
|
||||||
const second = b[key];
|
const second = b[key];
|
||||||
let cmp = 0;
|
let cmp = 0;
|
||||||
@@ -123,6 +131,8 @@ const sortedItems = computed(() => {
|
|||||||
}
|
}
|
||||||
return cmp * dir;
|
return cmp * dir;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return [...bases, ...others];
|
||||||
});
|
});
|
||||||
|
|
||||||
function isBaseFriend(friend: TableFriend): boolean {
|
function isBaseFriend(friend: TableFriend): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user