From 138fe67baa0464f459b10850e0739dbad1e53417 Mon Sep 17 00:00:00 2001 From: sto Date: Wed, 14 May 2025 15:17:42 +0200 Subject: [PATCH] Improve show contest buttons --- app/controllers/contests_controller.rb | 2 ++ app/views/contests/show.html.slim | 26 +++++++++++------------ app/views/layouts/authenticated.html.slim | 6 +++++- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 5955bc8..3f44330 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -13,6 +13,8 @@ class ContestsController < ApplicationController authorize @contest @title = I18n.t("contests.show.title", name: @contest.name) + @action_name = "Edit" + @action_path = edit_contest_path(@contest) @contestants = @contest.contestants.order(:name) @puzzles = @contest.puzzles.order(:id) @messages = @contest.messages.order(:id) diff --git a/app/views/contests/show.html.slim b/app/views/contests/show.html.slim index 1d1fc64..45f7208 100644 --- a/app/views/contests/show.html.slim +++ b/app/views/contests/show.html.slim @@ -9,9 +9,6 @@ .row.mb-4 .col - .float-end - a.btn.btn-primary href=edit_contest_path(@contest) - | Edit contest p = t("contests.show.public_scoreboard") = link_to root_url + "public/#{@contest.slug}", root_url + "public/#{@contest.slug}" @@ -20,7 +17,10 @@ .col-6 .row .col - h4 = t("puzzles.plural").capitalize + h4 + = t("puzzles.plural").capitalize + a.ms-3.btn.btn-primary href=new_contest_puzzle_path(@contest) style="margin-top: -3px" + = t("contests.show.add_puzzle") table.table.table-striped.table-hover thead tr @@ -42,10 +42,6 @@ td a.btn.btn-sm.btn-secondary href=edit_contest_puzzle_path(@contest, puzzle) | Edit - .row - .col - a.btn.btn-primary href=new_contest_puzzle_path(@contest) - = t("contests.show.add_puzzle") - if @messages .row.mt-5 .col @@ -64,13 +60,19 @@ = message.time_seconds td = message.text + td + a.btn.btn-sm.btn-secondary href="" style="white-space: nowrap;" + | Add completion td a.btn.btn-sm.btn-danger href="" | Delete .col-6 .row .col - h4 = t("contestants.plural").capitalize + h4 + = t("contestants.plural").capitalize + a.ms-3.btn.btn-primary href=new_contest_contestant_path(@contest) style="margin-top: -3px" + = t("contests.show.add_participant") table.table.table-striped.table-hover thead tr @@ -88,9 +90,5 @@ td a.btn.btn-sm.btn-secondary href=edit_contest_contestant_path(@contest, contestant) | Open - a.btn.btn-sm.btn-secondary.ms-2 href=new_contest_completion_path(@contest, contestant_id: contestant.id) + a.btn.btn-sm.btn-secondary.ms-3 href=new_contest_completion_path(@contest, contestant_id: contestant.id) | Add completion - .row.mt-4 - .col - a.btn.btn-primary href=new_contest_contestant_path(@contest) - = t("contests.show.add_participant") diff --git a/app/views/layouts/authenticated.html.slim b/app/views/layouts/authenticated.html.slim index 0f970f6..02a7bd2 100644 --- a/app/views/layouts/authenticated.html.slim +++ b/app/views/layouts/authenticated.html.slim @@ -16,6 +16,10 @@ html = t("nav.settings") = button_to t("nav.log_out"), session_path, method: :delete - h1.mb-4 = @title + h1.mb-4 + = @title + - if @action_path + a.ms-3.btn.btn-primary href=@action_path style="margin-top: -4px" + = @action_name = yield \ No newline at end of file