From d7a0fffe1aab9de4b18db88c409fcd5dc486ab5c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 1 May 2014 16:19:34 -0400 Subject: clean up forms --- app/views/tournaments/show.html.erb | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'app/views/tournaments/show.html.erb') diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 7e3fbae..6cb9783 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,3 +1,5 @@ +<%= link_to '« Back to all tournaments', tournaments_path, class: :breadcrumb %> +

<%= @tournament.name %>

@@ -72,33 +74,26 @@ <% end %> -
- <%# If user can join, and user hasn't joined already, show the join tournment tag %> +
+ <%# If user can join, and user hasn't joined already, show a join tournment button %> <% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> + <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %> <%= submit_tag("Join Tournament") %> <% end %> <% elsif @tournament.players.include?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> + <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %> <%= submit_tag("Leave Tournament") %> <% end %> <% end %> - <%# If user is the host, let them start the tournment %> - <% if @tournament.hosts.include?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> + <% if @tournament.check_permission(current_user, :edit) %> + <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %> - <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %> - <%= submit_tag("Start Tournament") %> - <% else %> - <%= submit_tag("Start Tournament", disabled: true) %> - <% end %> + <%= submit_tag("Start Tournament", disabled: (@tournament.players.count < @tournament.min_players_per_team * @tournament.min_teams_per_match)) %> <% end %> - <%= link_to 'Edit', edit_tournament_path(@tournament) %> | - <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' } %> + <%= link_to 'Edit Tournament', edit_tournament_path(@tournament), role: :button %> + <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' }, role: :button %> <% end %>
- -<%= link_to 'Back', tournaments_path %> -- cgit v1.2.3