mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-05 14:17:20 +00:00
Added mat assignment rules for the bout board and fixed the bug where a delegate making the tournamnet info public changes them to the owner
This commit is contained in:
61
app/views/mat_assignment_rules/_form.html.erb
Normal file
61
app/views/mat_assignment_rules/_form.html.erb
Normal file
@@ -0,0 +1,61 @@
|
||||
<%= form_with model: [@tournament, @mat_assignment_rule] do |form| %>
|
||||
<!-- Mat Selection -->
|
||||
<div>
|
||||
<%= form.label :mat_id, "Select Mat" %><br>
|
||||
<% if @available_mats.any? %>
|
||||
<%= form.collection_select :mat_id, @available_mats, :id, :name, { prompt: "Choose a Mat" } %>
|
||||
<% else %>
|
||||
<p>No mats are available. Please create a mat first.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Weight Classes as Checkboxes -->
|
||||
<div>
|
||||
<%= form.label :weight_classes, "Allowed Weight Classes" %><br>
|
||||
<% if @tournament.weights.any? %>
|
||||
<% @tournament.weights.each do |weight| %>
|
||||
<div>
|
||||
<%= check_box_tag "mat_assignment_rule[weight_classes][]", weight.id, @mat_assignment_rule.weight_classes.include?(weight.id) %>
|
||||
<%= label_tag "mat_assignment_rule_weight_classes_#{weight.id}", weight.max %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>No weight classes are available. Please create weight classes first.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Bracket Positions as Checkboxes -->
|
||||
<div>
|
||||
<%= form.label :bracket_positions, "Allowed Bracket Positions" %><br>
|
||||
<% if @unique_bracket_positions.present? %>
|
||||
<% @unique_bracket_positions.each do |position| %>
|
||||
<div>
|
||||
<%= check_box_tag "mat_assignment_rule[bracket_positions][]", position, @mat_assignment_rule.bracket_positions.include?(position) %>
|
||||
<%= label_tag "mat_assignment_rule_bracket_positions_#{position}", position %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>No bracket positions are available. Please ensure matches have bracket positions set.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Rounds as Checkboxes -->
|
||||
<div>
|
||||
<%= form.label :rounds, "Allowed Rounds" %><br>
|
||||
<% if @unique_rounds.present? %>
|
||||
<% @unique_rounds.each do |round| %>
|
||||
<div>
|
||||
<%= check_box_tag "mat_assignment_rule[rounds][]", round, @mat_assignment_rule.rounds.include?(round) %>
|
||||
<%= label_tag "mat_assignment_rule_rounds_#{round}", round %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>No rounds are available. Please ensure matches have rounds set.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div>
|
||||
<%= form.submit 'Submit', :class=>"btn btn-success" %>
|
||||
</div>
|
||||
<% end %>
|
||||
3
app/views/mat_assignment_rules/edit.html.erb
Normal file
3
app/views/mat_assignment_rules/edit.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>Edit Mat Assignment Rule for <%= @tournament.name %></h1>
|
||||
|
||||
<%= render "form", tournament: @tournament, mat_assignment: @mat_assignment_rule, available_mats: @available_mats %>
|
||||
36
app/views/mat_assignment_rules/index.html.erb
Normal file
36
app/views/mat_assignment_rules/index.html.erb
Normal file
@@ -0,0 +1,36 @@
|
||||
<table class="table table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Mat</th>
|
||||
<th>Weight Classes (Max)</th>
|
||||
<th>Bracket Positions</th>
|
||||
<th>Rounds</th>
|
||||
<th><%= link_to ' New Mat Assignment Rule', new_tournament_mat_assignment_rule_path(@tournament), :class=>"fas fa-plus" %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @mat_assignment_rules.each do |rule| %>
|
||||
<tr>
|
||||
<td><%= rule.mat.name %></td>
|
||||
|
||||
<!-- Display max values for each weight associated with the rule -->
|
||||
<td>
|
||||
<% rule.weight_classes.each do |weight_id| %>
|
||||
<% weight = @weights_by_id[weight_id] %>
|
||||
<%= weight ? weight.max : "N/A" %><%= ", " unless weight_id == rule.weight_classes.last %>
|
||||
<% end %>
|
||||
</td>
|
||||
|
||||
<!-- Display bracket positions and rounds -->
|
||||
<td><%= rule.bracket_positions.join(", ") %></td>
|
||||
<td><%= rule.rounds.join(", ") %></td>
|
||||
|
||||
<!-- Edit and Delete Actions -->
|
||||
<td>
|
||||
<%= link_to '', edit_tournament_mat_assignment_rule_path(@tournament, rule), :class=>"fas fa-edit" %>
|
||||
<%= link_to '', tournament_mat_assignment_rule_path(@tournament, rule), method: :delete, data: { confirm: "Are you sure?" }, :class=>"fas fa-trash-alt" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
3
app/views/mat_assignment_rules/new.html.erb
Normal file
3
app/views/mat_assignment_rules/new.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<h1>New Mat Assignment Rule for <%= @tournament.name %></h1>
|
||||
|
||||
<%= render "form", tournament: @tournament, mat_assignment: @mat_assignment_rule, available_mats: @available_mats %>
|
||||
Reference in New Issue
Block a user