Skip to content

Commit ade8183

Browse files
authored
bug: fix match mode redundancy and stage defaults (#261)
Co-authored-by: Flegma <Flegma@users.noreply.github.com>
1 parent 2aa1918 commit ade8183

3 files changed

Lines changed: 75 additions & 3 deletions

File tree

components/MatchOptions.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ import { Card } from "~/components/ui/card";
892892
</FormField>
893893

894894
<FormField
895-
v-if="canSetMatchCancellation"
895+
v-if="canSetMatchCancellation && !hideMatchMode"
896896
v-slot="{ componentField }"
897897
name="match_mode"
898898
>
@@ -1095,6 +1095,11 @@ export default {
10951095
type: Boolean,
10961096
default: false,
10971097
},
1098+
hideMatchMode: {
1099+
required: false,
1100+
type: Boolean,
1101+
default: false,
1102+
},
10981103
},
10991104
apollo: {
11001105
e_match_types: {

components/tournament/TournamentForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import MatchOptions from "~/components/MatchOptions.vue";
1414

1515
<template>
1616
<form @submit.prevent="updateCreateTournament" class="grid gap-4">
17-
<MatchOptions :form="form" :force-veto="true" :hide-best-of="true">
17+
<MatchOptions :form="form" :force-veto="true" :hide-best-of="true" :hide-match-mode="true">
1818
<FormField v-slot="{ componentField }" name="name">
1919
<FormItem>
2020
<FormLabel>{{ $t("tournament.form.name") }}</FormLabel>

components/tournament/TournamentStageForm.vue

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,40 @@ import { $ } from "~/generated/zeus";
612612
<FormMessage />
613613
</FormItem>
614614
</FormField>
615+
616+
<FormField
617+
v-if="canSetMatchMode"
618+
v-slot="{ componentField }"
619+
name="match_mode"
620+
>
621+
<FormItem>
622+
<FormLabel class="text-lg font-semibold">{{
623+
$t("match.options.advanced.match_mode.label")
624+
}}</FormLabel>
625+
<FormDescription>{{
626+
$t("match.options.advanced.match_mode.description")
627+
}}</FormDescription>
628+
<Select v-bind="componentField">
629+
<FormControl>
630+
<SelectTrigger>
631+
<SelectValue />
632+
</SelectTrigger>
633+
</FormControl>
634+
<SelectContent>
635+
<SelectGroup>
636+
<SelectItem
637+
:value="mode.value"
638+
v-for="mode in matchModeSettings"
639+
:key="mode.value"
640+
>
641+
{{ mode.display }}
642+
</SelectItem>
643+
</SelectGroup>
644+
</SelectContent>
645+
</Select>
646+
<FormMessage />
647+
</FormItem>
648+
</FormField>
615649
</div>
616650
</Card>
617651
</div>
@@ -635,6 +669,7 @@ import {
635669
e_timeout_settings_enum,
636670
e_check_in_settings_enum,
637671
e_player_roles_enum,
672+
e_match_mode_enum,
638673
} from "~/generated/zeus";
639674
import { toTypedSchema } from "@vee-validate/zod";
640675
import { useApplicationSettingsStore } from "~/stores/ApplicationSettings";
@@ -729,6 +764,9 @@ export default {
729764
tech_timeout_setting: z
730765
.string()
731766
.default(e_timeout_settings_enum.Admin),
767+
match_mode: z
768+
.string()
769+
.default(e_match_mode_enum.auto),
732770
})
733771
.refine(
734772
(data) => parseInt(data.min_teams) <= parseInt(data.max_teams),
@@ -797,11 +835,16 @@ export default {
797835
stage.options?.tech_timeout_setting ??
798836
this.tournament?.options?.tech_timeout_setting ??
799837
e_timeout_settings_enum.Admin,
838+
match_mode:
839+
stage.options?.match_mode ??
840+
this.tournament?.options?.match_mode ??
841+
e_match_mode_enum.auto,
800842
});
801843
}
802844
} else {
803845
this.form.setValues({
804846
groups: 1,
847+
default_best_of: "1",
805848
});
806849
this.setDefaultAdvancedSettings();
807850
}
@@ -978,6 +1021,23 @@ export default {
9781021
},
9791022
];
9801023
},
1024+
canSetMatchMode() {
1025+
return useAuthStore().isRoleAbove(
1026+
e_player_roles_enum.tournament_organizer,
1027+
);
1028+
},
1029+
matchModeSettings(): EnumSetting[] {
1030+
return [
1031+
{
1032+
display: this.$t("match.options.advanced.match_mode.options.auto"),
1033+
value: e_match_mode_enum.auto,
1034+
},
1035+
{
1036+
display: this.$t("match.options.advanced.match_mode.options.admin"),
1037+
value: e_match_mode_enum.admin,
1038+
},
1039+
];
1040+
},
9811041
},
9821042
methods: {
9831043
setDefaultAdvancedSettings() {
@@ -992,6 +1052,8 @@ export default {
9921052
ready_setting: options.ready_setting ?? e_ready_settings_enum.Players,
9931053
tech_timeout_setting:
9941054
options.tech_timeout_setting ?? e_timeout_settings_enum.Admin,
1055+
match_mode:
1056+
options.match_mode ?? e_match_mode_enum.auto,
9951057
});
9961058
},
9971059
setDefaultRegion() {
@@ -1016,7 +1078,8 @@ export default {
10161078
form.region_veto !== tournamentOptions.region_veto ||
10171079
form.check_in_setting !== tournamentOptions.check_in_setting ||
10181080
form.ready_setting !== tournamentOptions.ready_setting ||
1019-
form.tech_timeout_setting !== tournamentOptions.tech_timeout_setting
1081+
form.tech_timeout_setting !== tournamentOptions.tech_timeout_setting ||
1082+
form.match_mode !== (tournamentOptions.match_mode ?? e_match_mode_enum.auto)
10201083
) {
10211084
return true;
10221085
}
@@ -1049,6 +1112,7 @@ export default {
10491112
check_in_setting: form.check_in_setting,
10501113
ready_setting: form.ready_setting,
10511114
tech_timeout_setting: form.tech_timeout_setting,
1115+
match_mode: form.match_mode,
10521116
// Keep tournament defaults for all other fields
10531117
mr: tournamentOptions.mr,
10541118
type: tournamentOptions.type,
@@ -1080,6 +1144,7 @@ export default {
10801144
"tech_timeout_setting",
10811145
"e_timeout_settings_enum!",
10821146
),
1147+
match_mode: $("match_mode", "e_match_mode_enum!"),
10831148
mr: $("mr", "Int!"),
10841149
type: $("type", "e_match_types_enum!"),
10851150
best_of: $("best_of", "Int!"),
@@ -1115,6 +1180,7 @@ export default {
11151180
check_in_setting: form.check_in_setting,
11161181
ready_setting: form.ready_setting,
11171182
tech_timeout_setting: form.tech_timeout_setting,
1183+
match_mode: form.match_mode,
11181184
// Keep tournament defaults for all other fields
11191185
mr: tournamentOptions.mr,
11201186
type: tournamentOptions.type,
@@ -1143,6 +1209,7 @@ export default {
11431209
"tech_timeout_setting",
11441210
"e_timeout_settings_enum!",
11451211
),
1212+
match_mode: $("match_mode", "e_match_mode_enum!"),
11461213
mr: $("mr", "Int!"),
11471214
type: $("type", "e_match_types_enum!"),
11481215
best_of: $("best_of", "Int!"),

0 commit comments

Comments
 (0)