mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Swap wrestlers moved from edit wrestler to the bracket page
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -27,4 +27,21 @@
|
||||
<% if @weight.wrestlers.size <= 6 && @weight.allPoolMatchesFinished(1) %>
|
||||
<%= render 'onePoolResults' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if can? :manage, @tournament %>
|
||||
<br><br>
|
||||
<h3>Swap Bracket Position</h3>
|
||||
<%= form_for(Wrestler.new, url: swap_wrestlers_path(@tournament)) do |f| %>
|
||||
<div class="field">
|
||||
<%= f.label 'Wrestler 1' %><br>
|
||||
<%= f.collection_select :originalId, @weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label 'Wrestler 2' %><br>
|
||||
<%= f.collection_select :swapId, @weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<br>
|
||||
<%= submit_tag "Swap", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -52,19 +52,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if can? :manage, @wrestler.tournament %>
|
||||
<br><br>
|
||||
<h3>Swap Bracket Position</h3>
|
||||
<%= form_for(Wrestler.new, url: swap_wrestlers_path(@wrestler.tournament)) do |f| %>
|
||||
<%= f.hidden_field :originalId, :value => @wrestler.id %>
|
||||
<div class="field">
|
||||
<%= f.label 'Swap With' %><br>
|
||||
<%= f.collection_select :swapId, @wrestler.weight.wrestlers, :id, :name %>
|
||||
</div>
|
||||
<br>
|
||||
<%= submit_tag "Swap", :class=>"btn btn-success"%>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user