return $rounds->toArray();
}
+ public function settings(Request $request, Tournament $tournament) {
+ $this->authorize('update', $tournament);
+ $validatedData = $request->validate([
+ 'show_numbers' => 'boolean|nullable',
+ ]);
+ if (array_key_exists('show_numbers', $validatedData)) {
+ $tournament->show_numbers = $validatedData['show_numbers'];
+ }
+ $tournament->save();
+ if ($tournament->wasChanged()) {
+ TournamentChanged::dispatch($tournament);
+ Protocol::tournamentSettings($tournament, $request->user());
+ }
+ return $tournament->toJson();
+ }
+
public function open(Request $request, Tournament $tournament) {
$this->authorize('update', $tournament);
$tournament->accept_applications = true;
ProtocolAdded::dispatch($protocol);
}
+ public static function tournamentSettings(Tournament $tournament, User $user = null) {
+ $protocol = static::create([
+ 'tournament_id' => $tournament->id,
+ 'user_id' => $user ? $user->id : null,
+ 'type' => 'tournament.settings',
+ 'details' => [
+ 'tournament' => static::tournamentMemo($tournament),
+ ],
+ ]);
+ ProtocolAdded::dispatch($protocol);
+ }
+
public static function tournamentUnlocked(Tournament $tournament, User $user = null) {
$protocol = static::create([
'tournament_id' => $tournament->id,
'accept_applications' => 'boolean',
'locked' => 'boolean',
'no_record' => 'boolean',
+ 'show_numbers' => 'boolean',
];
}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('tournaments', function(Blueprint $table) {
+ $table->boolean('show_numbers')->default(true);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('tournaments', function(Blueprint $table) {
+ $table->dropColumn('show_numbers');
+ });
+ }
+};
case 'tournament.discord':
case 'tournament.lock':
case 'tournament.open':
+ case 'tournament.settings':
case 'tournament.unlock':
return i18n.t(
`protocol.description.${entry.type}`,
<div className="d-flex">
<div className="info">
<p className="date">
- {round.number ? `#${round.number} ` : '#?'}
+ {tournament.show_numbers && round.number ? `#${round.number} ` : ''}
{t('rounds.date', { date: new Date(round.created_at) })}
</p>
<p className="seed">
tournament: PropTypes.shape({
participants: PropTypes.arrayOf(PropTypes.shape({
})),
+ show_numbers: PropTypes.bool,
type: PropTypes.string,
}),
};
}
};
+const settings = async (tournament, params) => {
+ try {
+ await axios.post(`/api/tournaments/${tournament.id}/settings`, params);
+ toastr.success(i18n.t('tournaments.settingsSuccess'));
+ } catch (e) {
+ toastr.error(i18n.t('tournaments.settingsError'));
+ }
+};
+
const inviteUrl = 'https://discordapp.com/oauth2/authorize?client_id=951113702839549982&scope=bot';
const SettingsDialog = ({
value={tournament.locked}
/>
</div>
+ <div className="d-flex align-items-center justify-content-between mb-3">
+ <span>{i18n.t('tournaments.showNumbers')}</span>
+ <ToggleSwitch
+ onChange={({ target: { value } }) =>
+ settings(tournament, { show_numbers: value })}
+ value={tournament.show_numbers}
+ />
+ </div>
<div className="d-flex align-items-center justify-content-between">
<div>
<p>{i18n.t('tournaments.discord')}</p>
accept_applications: PropTypes.bool,
discord: PropTypes.string,
locked: PropTypes.bool,
+ show_numbers: PropTypes.bool,
}),
};
discord: 'Discord Server verknüpft',
lock: 'Turnier gesperrt',
open: 'Anmeldung geöffnet',
+ settings: 'Einstellungen geändert',
unlock: 'Turnier entsperrt',
},
unknown: 'Unbekannter Protokolleintrag vom Typ {{type}}.',
scoreboard: 'Scoreboard',
scoreChart: 'Turnierverlauf',
settings: 'Einstellungen',
+ settingsError: 'Fehler beim Speichern',
+ settingsSuccess: 'Einstellungen gespeichert',
+ showNumbers: 'Nummern einblenden',
unlockError: 'Fehler beim Entsperren',
unlockSuccess: 'Turnier entsperrt',
},
discord: 'Discord server connected',
lock: 'Tournament locked',
open: 'Registration opened',
+ settings: 'Modified settings',
unlock: 'Tournament unlocked',
},
unknown: 'Unknown protocol entry of type {{type}}.',
scoreboard: 'Scoreboard',
scoreChart: 'Score chart',
settings: 'Settings',
+ settingsError: 'Error saving settings',
+ settingsSuccess: 'Settings saved successfully',
+ showNumbers: 'Show numbers',
unlockError: 'Error unlocking tournaments',
unlockSuccess: 'Tournament unlocked',
},
Route::post('tournaments/{tournament}/discord-settings', 'App\Http\Controllers\TournamentController@discordSettings');
Route::post('tournaments/{tournament}/lock', 'App\Http\Controllers\TournamentController@lock');
Route::post('tournaments/{tournament}/open', 'App\Http\Controllers\TournamentController@open');
+Route::post('tournaments/{tournament}/settings', 'App\Http\Controllers\TournamentController@settings');
Route::post('tournaments/{tournament}/unlock', 'App\Http\Controllers\TournamentController@unlock');
Route::get('users', 'App\Http\Controllers\UserController@search');