Skip to content
/ web Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 73 additions & 3 deletions components/tournament/TournamentNotifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,64 @@
</div>
</Card>

<Card variant="gradient">
<div class="p-6 space-y-6">
<div>
<h4 class="text-base font-medium">
{{ $t("tournament.voice.title") }}
</h4>
<p class="text-sm text-muted-foreground">
{{ $t("tournament.voice.description") }}
</p>
</div>

<div class="space-y-2">
<div class="flex items-center gap-2">
<Input
:model-value="form.discord_guild_id ?? ''"
:placeholder="$t('tournament.voice.guild_id_placeholder')"
inputmode="numeric"
pattern="[0-9]*"
@update:model-value="
form.discord_guild_id = $event.replace(/[^0-9]/g, '') || null;
dirty = true;
"
/>
</div>
</div>

<div
class="flex items-center justify-between rounded-lg border p-3 cursor-pointer select-none"
role="button"
tabindex="0"
@click="
form.discord_voice_enabled = !form.discord_voice_enabled;
dirty = true;
"
@keydown.enter.prevent="
form.discord_voice_enabled = !form.discord_voice_enabled;
dirty = true;
"
@keydown.space.prevent="
form.discord_voice_enabled = !form.discord_voice_enabled;
dirty = true;
"
>
<span class="text-sm font-medium">{{
$t("tournament.voice.enable_voice")
}}</span>
<Switch
@click.stop
:model-value="form.discord_voice_enabled"
@update:model-value="
form.discord_voice_enabled = $event;
dirty = true;
"
/>
</div>
</div>
</Card>

<Card variant="gradient">
<div class="p-6 space-y-6">
<div>
Expand Down Expand Up @@ -287,6 +345,8 @@ const DISCORD_FIELDS = [
"discord_notifications_enabled",
"discord_webhook",
"discord_role_id",
"discord_guild_id",
"discord_voice_enabled",
"discord_notify_PickingPlayers",
"discord_notify_Scheduled",
"discord_notify_WaitingForCheckIn",
Expand Down Expand Up @@ -367,7 +427,11 @@ export default {
buildForm(tournament: Record<string, any>) {
const form: Record<string, any> = {};
for (const field of DISCORD_FIELDS) {
form[field] = tournament[field] ?? null;
if (field === "discord_voice_enabled") {
form[field] = tournament[field] ?? false;
} else {
form[field] = tournament[field] ?? null;
}
}
return form;
},
Expand Down Expand Up @@ -425,14 +489,20 @@ export default {
for (const field of DISCORD_FIELDS) {
let value = this.form[field];
if (
(field === "discord_webhook" || field === "discord_role_id") &&
(field === "discord_webhook" ||
field === "discord_role_id" ||
field === "discord_guild_id") &&
value === ""
) {
value = null;
}
variables[field] = value;

if (field === "discord_webhook" || field === "discord_role_id") {
if (
field === "discord_webhook" ||
field === "discord_role_id" ||
field === "discord_guild_id"
) {
_set[field] = $(field, "String");
} else {
_set[field] = $(field, "Boolean");
Expand Down
8 changes: 7 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@
}
},
"notifications": {
"title": "Notifications",
"title": "Discord",
"description": "Override global Discord notification settings for this tournament. Leave empty to use global defaults.",
"webhook": "Webhook URL",
"webhook_placeholder": "Leave empty to use global default",
Expand Down Expand Up @@ -1167,6 +1167,12 @@
"Surrendered": "Surrendered"
}
},
"voice": {
"title": "Voice Channels",
"description": "Automatically create Discord voice channels for tournament matches. Players are moved to team channels when matches begin.",
"guild_id_placeholder": "Discord Server ID",
"enable_voice": "Enable Voice Channels"
},
"table": {
"tournament": "Tournament",
"status": "Status",
Expand Down
2 changes: 2 additions & 0 deletions pages/tournaments/[tournamentId]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,9 @@ export default {
description: true,
},
description: true,
discord_guild_id: true,
discord_notifications_enabled: true,
discord_voice_enabled: true,
discord_webhook: true,
discord_role_id: true,
discord_notify_PickingPlayers: true,
Expand Down