ozfortress/citadel

View on GitHub
app/views/leagues/matches/_match_scores_form.html.haml

Summary

Maintainability
Test Coverage
= bootstrap_form_for match, as: :match, url: submit_match_path(match) do |f|
  = f.errors_on :base

  .form-group
    %label{ for: 'scores-table' } Scores
    %table.table#scores-table
      %tr
        %th Map
        %th= match.home_team.name
        %th= match.away_team.name

      = f.fields_for :rounds, match.rounds do |ff|
        - round_p = present(ff.object)

        %tr
          %td= round_p.map.link
          %td= ff.number_field :home_team_score, hide_label: true, wrapper: false
          %td= ff.number_field :away_team_score, hide_label: true, wrapper: false

  - if user_can_edit_league?
    = f.select(:status, League::Match.statuses.keys.map { |s| [s.humanize, s] })
    = f.select(:forfeit_by, League::Match.forfeit_bies.keys.map { |s| [s.humanize, s] })

  .d-flex.justify-content-end
    - unless user_can_edit_league?
      = button_to 'Forfeit', forfeit_match_path(match),
                  class: 'btn btn-danger mr-2', method: :patch,
                  data: { confirm: 'Are you sure you want to forfeit this match?' }

    - if user_can_edit_league?
      = f.primary 'Update'
    - else
      = f.primary 'Submit Score'