ozfortress/citadel

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

Summary

Maintainability
Test Coverage
- comm_p = present(comm)

.comm{ class: "#{local_assigns[:class]} #{comm.created_by.admin? ? 'comm-admin' : ''}" }
  %div{ id: comm.paths.dom_id }

  .card-header
    .row.no-gutters.flex-nowrap.align-items-center
      = render 'users/listing', user: comm.created_by, team: comm_p.user_team, show_team_name: true

      .spacer

      .dropdown
        .btn.btn-light{ data: { toggle: 'dropdown' } }
          = inline_svg_tag 'open_iconic/ellipses.svg', class: 'icon fill-secondary'

        .dropdown-menu.dropdown-menu-right
          = link_to 'Link', comm.paths.show, class: 'dropdown-item'

          - if user_can_edit_comm?(comm)
            = link_to 'Edit', comm.paths.edit, class: 'dropdown-item'

          - if user_can_edit_comm?(comm) && comm.edits.size > 1
            = link_to 'History', comm.paths.edits, class: 'dropdown-item'

  .card-body
    .markdown.pb-3
      = comm_p.content

    .footer.row.no-gutters.align-items-center.pt-2
      .created-at{ 'data-toggle': 'tooltip', title: comm_p.created_at }
        Posted #{comm_p.created_at_in_words} ago

      - if comm.edits.size > 1
        %span.edited-at.ml-1{ 'data-toggle': 'tooltip', title: comm_p.last_edited }
          \- edited #{comm_p.last_edited_in_words} ago