Skip to content

Commit bf7ea28

Browse files
authored
chore: update to allow sorting by last sign in at (#323)
1 parent 831d812 commit bf7ea28

7 files changed

Lines changed: 48 additions & 18 deletions

File tree

components/PlayerDisplay.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ import FiveStackToolTip from "./FiveStackToolTip.vue";
6363
<div class="mt-2" v-if="$slots['avatar-sub']">
6464
<slot name="avatar-sub"></slot>
6565
</div>
66+
<div
67+
class="absolute -top-1 -right-1 z-10"
68+
v-if="$slots['avatar-badge']"
69+
>
70+
<slot name="avatar-badge"></slot>
71+
</div>
6672
</div>
6773
<div
6874
:class="{

components/match/LineupMember.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import PlayerStatusDisplay from "./PlayerStatusDisplay.vue";
1111
<template v-if="$slots['elo-postfix']" #elo-postfix>
1212
<slot name="elo-postfix"></slot>
1313
</template>
14+
<template v-if="$slots['avatar-badge']" #avatar-badge>
15+
<slot name="avatar-badge"></slot>
16+
</template>
1417
</PlayerStatusDisplay>
1518
</template>
1619
<template v-else>

components/match/LineupOverviewRow.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import PlayerMatchClipsButton from "~/components/match/PlayerMatchClipsButton.vu
88
<TableRow>
99
<TableCell class="overflow-hidden">
1010
<LineupMember :match="match" :member="member">
11-
<template v-if="member.player?.steam_id" #name-postfix>
11+
<template v-if="member.player?.steam_id" #avatar-badge>
1212
<PlayerMatchClipsButton :steam-id="member.player.steam_id" />
1313
</template>
1414
<template v-if="memberEloChange" #elo-postfix>

components/match/PlayerMatchClipsButton.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,23 @@ function pickClip(c: Clip) {
5353
<button
5454
v-if="count === 1 && single"
5555
type="button"
56-
class="ml-1.5 inline-flex h-5 items-center gap-1 rounded-full border border-[hsl(var(--tac-amber)/0.5)] bg-[hsl(var(--tac-amber)/0.12)] px-1.5 text-[hsl(var(--tac-amber))] hover:bg-[hsl(var(--tac-amber)/0.2)] transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--tac-amber)/0.6)]"
56+
class="relative inline-flex h-5 w-5 items-center justify-center rounded-full border-2 border-background bg-[hsl(var(--tac-amber))] text-background shadow-[0_0_0_1px_hsl(var(--tac-amber)),0_0_6px_hsl(var(--tac-amber)/0.6)] hover:brightness-110 transition cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--tac-amber)/0.8)]"
5757
:title="single.title || 'Open highlight'"
5858
@click="onSingleClick"
5959
>
6060
<Film class="h-3 w-3" />
61-
<span class="font-mono text-[0.55rem] uppercase tracking-[0.16em]">
62-
Clip
63-
</span>
6461
</button>
6562

6663
<Popover v-else>
6764
<PopoverTrigger
68-
class="ml-1.5 inline-flex h-5 items-center gap-1 rounded-full border border-[hsl(var(--tac-amber)/0.5)] bg-[hsl(var(--tac-amber)/0.12)] px-1.5 text-[hsl(var(--tac-amber))] hover:bg-[hsl(var(--tac-amber)/0.2)] transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--tac-amber)/0.6)]"
65+
class="relative inline-flex h-5 w-5 items-center justify-center rounded-full border-2 border-background bg-[hsl(var(--tac-amber))] text-background shadow-[0_0_0_1px_hsl(var(--tac-amber)),0_0_6px_hsl(var(--tac-amber)/0.6)] hover:brightness-110 transition cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--tac-amber)/0.8)]"
6966
:title="`${count} highlights for this player`"
7067
@click.stop
7168
>
7269
<Film class="h-3 w-3" />
73-
<span class="font-mono text-[0.55rem] tabular-nums">
70+
<span
71+
class="absolute -top-1 -right-1 inline-flex min-w-[0.875rem] h-3.5 px-1 items-center justify-center rounded-full border border-background bg-red-500 text-[0.55rem] font-mono font-bold tabular-nums text-white"
72+
>
7473
{{ count }}
7574
</span>
7675
</PopoverTrigger>

components/match/PlayerStatusDisplay.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const { isMobile } = useSidebar();
4040
<slot name="elo-postfix"></slot>
4141
</template>
4242

43+
<template v-if="$slots['avatar-badge']" #avatar-badge>
44+
<slot name="avatar-badge"></slot>
45+
</template>
46+
4347
<template v-slot:status v-if="showStatus">
4448
<FiveStackToolTip side="bottom" :delay-duration="300">
4549
<template #trigger>

pages/players/index.vue

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,26 @@ import {
447447
<TableHead v-if="canViewAdditionalDetails">{{
448448
$t("pages.players.table.privilege")
449449
}}</TableHead>
450-
<TableHead v-if="canViewAdditionalDetails">
451-
{{ $t("pages.players.table.last_sign_in_at") }}
450+
<TableHead
451+
v-if="canViewAdditionalDetails"
452+
class="cursor-pointer"
453+
@click="toggleSort('last_sign_in_at')"
454+
>
455+
<div class="flex items-center gap-1">
456+
{{ $t("pages.players.table.last_sign_in_at") }}
457+
<ArrowUpIcon
458+
v-if="
459+
sortField === 'last_sign_in_at' && sortDirection === 'desc'
460+
"
461+
class="w-4 h-4"
462+
/>
463+
<ArrowDownIcon
464+
v-else-if="
465+
sortField === 'last_sign_in_at' && sortDirection === 'asc'
466+
"
467+
class="w-4 h-4"
468+
/>
469+
</div>
452470
</TableHead>
453471
</TableRow>
454472
</TableHeader>
@@ -909,7 +927,7 @@ export default {
909927
this.saveFiltersToStorage();
910928
this.searchPlayers();
911929
},
912-
toggleSort(field: "name" | "elo") {
930+
toggleSort(field: "name" | "elo" | "last_sign_in_at") {
913931
if (this.sortField === field) {
914932
// If clicking the same column, toggle direction
915933
this.sortDirection = this.sortDirection === "asc" ? "desc" : "asc";

server/api/players-search.post.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ export default defineEventHandler(async (event) => {
5757
});
5858
}
5959

60-
if (body.registeredOnly) {
60+
// Use provided sort_by or default to name:asc
61+
let sortBy = body.sort_by || "name:asc";
62+
63+
if (sortBy.includes("elo")) {
64+
sortBy = sortBy.replace("elo", "elo_competitive");
65+
}
66+
67+
if (body.registeredOnly || sortBy.includes("last_sign_in_at")) {
6168
filterBy.push(`last_sign_in_at:!~~`);
6269
}
6370

@@ -129,13 +136,6 @@ export default defineEventHandler(async (event) => {
129136
filterBy.push(`is_muted:=${body.is_muted}`);
130137
}
131138

132-
// Use provided sort_by or default to name:asc
133-
let sortBy = body.sort_by || "name:asc";
134-
135-
if (sortBy.includes("elo")) {
136-
sortBy = sortBy.replace("elo", "elo_competitive");
137-
}
138-
139139
const searchParams: any = {
140140
q: query ?? "*",
141141
query_by: queryBy,

0 commit comments

Comments
 (0)