rtopitt/bolao2014

View on GitHub
app/views/match_bets/edit.html.erb

Summary

Maintainability
Test Coverage
<% content_for(:title) { t('.title', match_number: @match.number) } %>

<div class="row">
  <div class="small-12 column">
    <h2><%= t '.my_bet' %></h2>

    <h3><%= Match.model_name.human(count: 1) %> #<%= @match.number %></h3>

    <p>
      <%= @match.round_text %>
      <% if @match.group.present? %>
        | <%= Match.human_attribute_name(:group) %> <%= @match.group %>
      <% end %>
    </p>

    <p><%= l @match.played_at, format: :detailed %> @ <%= @match.played_on_text %></p>
  </div>
</div>

<% if @match.locked? %>
  <div class="row">
    <div class="small-12 column">
      <div class="row">
        <div class="small-3 columns text-left">
          <p><%= @match.team_a_name %></p>
        </div>
        <div class="small-1 columns text-center">
          <p>&nbsp;</p>
        </div>
        <div class="small-3 columns text-right end">
          <p><%= @match.team_b_name %></p>
        </div>
      </div>

      <div class="row">
        <div class="small-1 columns text-left">
          <%= @match.team_a_flag %>
        </div>
        <div class="small-2 columns text-left">
          <%= text_field_tag :goals_a, @match_bet.goals_a_or_blank, disabled: true %>
        </div>

        <div class="small-1 column text-center">
          <p>VS</p>
        </div>

        <div class="small-2 columns text-right">
          <%= text_field_tag :goals_a, @match_bet.goals_b_or_blank, disabled: true %>
        </div>
        <div class="small-1 columns text-right end">
          <%= @match.team_b_flag %>
        </div>
      </div>
      <p><%= t '.match_is_locked' %></p>
    </div>
  </div>
<% else %>
  <%= form_for @_match_bet, url: my_match_bet_path(@match), method: (@_match_bet.new_record? ? :post : :put), html: {id: @match_bet.form_id} do |f| %>
    <div class="row">
      <div class="small-3 columns text-left">
        <p><%= @match.team_a_name %></p>
      </div>
      <div class="small-1 columns text-center">
        <p>&nbsp;</p>
      </div>
      <div class="small-3 columns text-right end">
        <p><%= @match.team_b_name %></p>
      </div>
    </div>

    <div class="row">
      <div class="small-1 columns text-left">
        <%= @match.team_a_flag %>
      </div>
      <div class="small-2 columns text-left">
        <%= f.text_field :goals_a, placeholder: '?', autofocus: true, class: "goal-guess #{'error' if @_match_bet.errors.include?(:goals_a)}" %>
        <% if @_match_bet.errors.include?(:goals_a) %>
          <small class="error"><%= @_match_bet.errors.get(:goals_a).to_sentence %></small>
        <% end %>
      </div>

      <div class="small-1 column text-center">
        <p>VS</p>
      </div>

      <div class="small-2 columns text-right">
        <%= f.text_field :goals_b, placeholder: '?', class: "goal-guess #{'error' if @_match_bet.errors.include?(:goals_b)}" %>
        <% if @_match_bet.errors.include?(:goals_b) %>
          <small class="error"><%= @_match_bet.errors.get(:goals_b).to_sentence %></small>
        <% end %>
      </div>
      <div class="small-1 columns text-right end">
        <%= @match.team_b_flag %>
      </div>
    </div>

    <% unless @match.drawable? %>
      <div id="penalty-winner-selector" class="row <%= 'hide' if !@match_bet.penalty_winner_select_visible? %>">
        <div class="small-7 column end">
          <%= f.label :penalty_winner_id %>
          <%= f.select :penalty_winner_id, @match_bet.teams_options_for_select, {include_blank: true}, {class: ('error' if @_match_bet.errors.include?(:penalty_winner_id))} %>
          <% if @_match_bet.errors.include?(:penalty_winner_id) %>
            <small class="error"><%= @_match_bet.errors.get(:penalty_winner_id).to_sentence %></small>
          <% end %>
        </div>
      </div>
    <% end %>

    <div class="row">
      <div class="small-12 column">
        <%= f.submit t('common.submit'), class: 'button' %>
        <p><%= t '.you_may_change_your_bet_until', datetime: l(@match.bettable_until, format: :detailed ) %></p>
      </div>
    </div>
  <% end %>
<% end %>

<div class="row">
  <div class="small-12 column">
    <p>
      <%= link_to t('.my_bet').downcase, my_bet_path %> |
      <%= link_to t('.all_matches'), my_bet_matches_path %> |
      <%= @match.link_to_previous_bettable %> |
      <%= @match.link_to_next_bettable %>
    </p>
  </div>
</div>