ozfortress/citadel

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

Summary

Maintainability
Test Coverage
- content_for(:title) { "Create Match | #{@league.name}" }

- league_p = present(@league)

%h1
  = league_p.link
  Create Single Match

.mb-5
  .card.bg-light.mb-3
    .p-2
      .nav.nav-pills.justify-content-center
        - @league.divisions.each do |div|
          - klass = div == @division ? 'active' : ''

          %a.nav-item.nav-link{ data: { toggle: 'tab' }, href: "##{div.to_s.parameterize}", class: klass }
            %h6.m-0
              = div.name


  .tab-content
    - @league.divisions.each do |div|
      - klass = div == @division ? 'active' : ''

      %div{ id: div.to_s.parameterize, class: 'tab-pane ' + klass }
        = bootstrap_form_for @match, as: :match, url: league_matches_path(@league) do |f|
          = hidden_field_tag :division_id, div.id

          = f.errors_on :base
          = render 'match_form', f: f, div: div

          .d-flex.justify-content-end
            = link_to 'Cancel', league_matches_path(@league), class: 'btn btn-link mr-2'
            = f.primary 'Create'