ozfortress/citadel

View on GitHub
app/views/leagues/matches/comms/edit.html.haml

Summary

Maintainability
Test Coverage
- match_p = present(@match)
- content_for(:title) { "Edit Match Comm | #{match_p}" }

%h1 #{present(@league).link}: #{@match.home_team.division.name}

= render 'shared/head', heading: match_p.link, subheading: 'Editing match comm'

.card.bg-light.mb-3
  .card-body
    = bootstrap_form_for @comm, as: :comm, url: @comm.paths.update do |f|
      = render 'form', f: f

      .d-flex.justify-content-end
        = link_to 'Cancel', match_path(@match), class: 'btn btn-link mr-2'
        = f.primary 'Update'

- if user_can_edit_league?
  .alert.alert-danger.mb-3
    %label.font-weight-bold.alert-heading
      Danger Zone

    .btn-toolbar.guttered
      - if @comm.exists?
        = button_to @comm.paths.destroy, method: :delete, class: 'btn btn-sm btn-danger',
                    data: { confirm: 'Are you sure you want to delete this Match Comm?' } do
          = inline_svg_tag 'open_iconic/trash.svg', class: 'icon mr-2'
          Delete
      - else
        = button_to @comm.paths.restore, method: :patch, class: 'btn btn-sm btn-warning',
                    data: { confirm: 'Are you sure you want to restore this Match Comm?' } do
          = inline_svg_tag 'open_iconic/pulse.svg', class: 'icon mr-2'
          Restore