ensl.org/app/views/matches/_lineup.html.erb
2015-11-06 19:43:30 +00:00

51 lines
2.2 KiB
Text
Executable file

<div class="players">
<% contester.lineup.each do |teamer| %>
<div class="player fields">
<% if matcher = @match.matchers.first(conditions: { user_id: teamer.user_id, contester_id: contester.id }) %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][id]", matcher.id %>
<% end %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][user_id]", teamer.user_id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][contester_id]", contester.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][match_id]", @match.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][merc]", false %>
<%= check_box_tag "match[matchers_attributes][#{@n}][_destroy]", "keep", !matcher.nil?, { id: "player_#{@n}" } %>
<%= label_tag "player_#{@n}", '', class: 'checkbox' %>
<span><%= teamer.user %></span>
</div>
<% @n = @n + 1 %>
<% end %>
</div>
<div class="mercenaries">
<% @match.matchers.mercs.of_contester(contester).each do |matcher| %>
<div class="player fields">
<%= hidden_field_tag "match[matchers_attributes][#{@n}][id]", matcher.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][user_id]", matcher.user_id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][contester_id]", contester.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][match_id]", @match.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][merc]", true %>
<%= check_box_tag "match[matchers_attributes][#{@n}][_destroy]", "keep", true, { id: "player_#{@n}" } %>
<%= label_tag "player_#{@n}", '', class: 'checkbox' %>
<span><%= matcher.user %></span>
</div>
<% @n = @n + 1 %>
<% end %>
<div class="fields">
<%= hidden_field_tag "match[matchers_attributes][#{@n}][contester_id]", contester.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][match_id]", @match.id %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][merc]", true %>
<%= hidden_field_tag "match[matchers_attributes][#{@n}][_destroy]", "keep" %>
<%= text_field_tag "match[matchers_attributes][#{@n}][user_id]", '', placeholder: 'Mercenary' %>
<% @n = @n + 1 %>
</div>
</div>