From b5d07e103e1a75ee2256397714beab203beda496 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 31 Jan 2017 13:43:56 +0000 Subject: [PATCH] Swap wrestlers moved from edit wrestler to the bracket page --- app/controllers/tournaments_controller.rb | 2 +- app/views/tournaments/bracket.html.erb | 17 +++++++++++++++++ app/views/wrestlers/_form.html.erb | 14 +------------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index b89d609..0f443b6 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -13,7 +13,7 @@ class TournamentsController < ApplicationController @wrestler = Wrestler.find(params[:wrestler][:originalId]) respond_to do |format| if SwapWrestlers.new.swapWrestlers(params[:wrestler][:originalId], params[:wrestler][:swapId]) - format.html { redirect_to @wrestler, notice: 'Wrestler was successfully swaped.' } + format.html { redirect_to "/tournaments/#{@wrestler.tournament.id}/brackets/#{@wrestler.weight.id}", notice: 'Wrestler was successfully swaped.' } format.json { render action: 'show', status: :created, location: @wrestler } end end diff --git a/app/views/tournaments/bracket.html.erb b/app/views/tournaments/bracket.html.erb index 3b476f2..04094b0 100644 --- a/app/views/tournaments/bracket.html.erb +++ b/app/views/tournaments/bracket.html.erb @@ -27,4 +27,21 @@ <% if @weight.wrestlers.size <= 6 && @weight.allPoolMatchesFinished(1) %> <%= render 'onePoolResults' %> <% end %> +<% end %> + +<% if can? :manage, @tournament %> +

+

Swap Bracket Position

+ <%= form_for(Wrestler.new, url: swap_wrestlers_path(@tournament)) do |f| %> +
+ <%= f.label 'Wrestler 1' %>
+ <%= f.collection_select :originalId, @weight.wrestlers, :id, :name %> +
+
+ <%= f.label 'Wrestler 2' %>
+ <%= f.collection_select :swapId, @weight.wrestlers, :id, :name %> +
+
+ <%= submit_tag "Swap", :class=>"btn btn-success"%> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/wrestlers/_form.html.erb b/app/views/wrestlers/_form.html.erb index bb1a141..6faa35e 100644 --- a/app/views/wrestlers/_form.html.erb +++ b/app/views/wrestlers/_form.html.erb @@ -52,19 +52,7 @@ <% end %> -<% if can? :manage, @wrestler.tournament %> -

-

Swap Bracket Position

- <%= form_for(Wrestler.new, url: swap_wrestlers_path(@wrestler.tournament)) do |f| %> - <%= f.hidden_field :originalId, :value => @wrestler.id %> -
- <%= f.label 'Swap With' %>
- <%= f.collection_select :swapId, @wrestler.weight.wrestlers, :id, :name %> -
-
- <%= submit_tag "Swap", :class=>"btn btn-success"%> - <% end %> -<% end %> +