Merge lineup forms

This commit is contained in:
Prommah 2015-11-06 19:43:30 +00:00
parent a27b8b9f21
commit f5d8960647
4 changed files with 45 additions and 95 deletions

View file

@ -156,6 +156,7 @@ div#match {
.team-1, .team-1,
.team-2 { .team-2 {
position: relative; position: relative;
margin-bottom: 20px;
.player { .player {
@include span-columns(12); @include span-columns(12);
@ -167,21 +168,8 @@ div#match {
position: relative; position: relative;
} }
.controls { label.checkbox {
top: 0; padding: 0;
position: absolute;
z-index: 100;
input {
margin: 0;
}
}
form {
label.checkbox {
padding: 0;
}
} }
} }
@ -193,16 +181,9 @@ div#match {
margin: 0 0 0 10px; margin: 0 0 0 10px;
} }
.controls { label.checkbox {
left: 0; float: right;
} margin-left: 1em;
form {
label.checkbox {
float: right;
margin-left: 1em;
}
} }
} }
@ -210,16 +191,9 @@ div#match {
@include span-columns(6); @include span-columns(6);
@include omega; @include omega;
.controls { label.checkbox {
right: 0; float: left;
} margin-right: 1em;
form {
label.checkbox {
float: left;
margin-right: 1em;
}
} }
} }
@ -234,6 +208,10 @@ div#match {
margin: 0; margin: 0;
} }
} }
form .controls {
clear: both;
}
} }
.scoring { .scoring {

48
app/assets/stylesheets/themes/flat/pages/_matches.scss Normal file → Executable file
View file

@ -155,6 +155,7 @@ div#match {
.team-1, .team-1,
.team-2 { .team-2 {
position: relative; position: relative;
margin-bottom: 20px;
.player { .player {
@include span-columns(12); @include span-columns(12);
@ -166,21 +167,8 @@ div#match {
position: relative; position: relative;
} }
.controls { label.checkbox {
top: 0; padding: 0;
position: absolute;
z-index: 100;
input {
margin: 0;
}
}
form {
label.checkbox {
padding: 0;
}
} }
} }
@ -192,16 +180,9 @@ div#match {
margin: 0 0 0 10px; margin: 0 0 0 10px;
} }
.controls { label.checkbox {
left: 0; float: right;
} margin-left: 1em;
form {
label.checkbox {
float: right;
margin-left: 1em;
}
} }
} }
@ -209,16 +190,9 @@ div#match {
@include span-columns(6); @include span-columns(6);
@include omega; @include omega;
.controls { label.checkbox {
right: 0; float: left;
} margin-right: 1em;
form {
label.checkbox {
float: left;
margin-right: 1em;
}
} }
} }
@ -233,6 +207,10 @@ div#match {
margin: 0; margin: 0;
} }
} }
form .controls {
clear: both;
}
} }
.scoring { .scoring {

6
app/views/matches/_lineup.html.erb Normal file → Executable file
View file

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

38
app/views/matches/ref.html.erb Normal file → Executable file
View file

@ -16,33 +16,25 @@
<div class="lineups"> <div class="lineups">
<h3>Lineups</h3> <h3>Lineups</h3>
<div class="team-1"> <%= form_for @match do |f| %>
<%= form_for @match do |f| %> <%= f.error_messages %>
<%= f.error_messages %>
<div class="controls">
<%= f.submit 'Save Lineup' %>
</div>
<div class="team-1">
<% [@match.contester1].each do |contester| %> <% [@match.contester1].each do |contester| %>
<%= render partial: "lineup", locals: { contester: contester } %> <%= render partial: "lineup", locals: { contester: contester } %>
<% end %> <% end %>
<% end %> </div>
</div>
<div class="team-2">
<div class="team-2">
<%= form_for @match do |f| %>
<%= f.error_messages %>
<div class="controls">
<%= f.submit 'Save Lineup' %>
</div>
<% [@match.contester2].each do |contester| %> <% [@match.contester2].each do |contester| %>
<%= render partial: "lineup", locals: { contester: contester } %> <%= render partial: "lineup", locals: { contester: contester } %>
<% end %> <% end %>
<% end %> </div>
</div>
<div class="controls">
<%= f.submit 'Save Lineups' %>
</div>
<% end %>
</div> </div>
<div class="scoring"> <div class="scoring">
@ -83,7 +75,7 @@
</div> </div>
<div class="controls"> <div class="controls">
<%= f.submit 'Save Scores' %> <%= f.submit 'Save Scoring' %>
</div> </div>
<% end %> <% end %>
</div> </div>