OfficeMomsandDads/scheduler

View on GitHub
app/views/shifts/_manage_shifts.html.haml

Summary

Maintainability
Test Coverage
- if shifts.first.start_at.advance(hours: -1) > Time.zone.now
  = link_to need_shifts_path(@need, shift: { start_at: shifts.first.start_at - 1.hour, duration: 60 }), method: :post do
    .grid-x.grid-margin-y.grid-margin-x
      .cell.small-12.medium-6.shift.add-shift
        .grid-x.grid-padding-x.grid-padding-y
          .cell.text-center
            %i.fas.fa-plus
            Add Shift Before
- shifts.each_with_index do |shift, i|
  %hr
  .grid-x.grid-margin-y.grid-margin-x.align-spaced.align-middle
    = render partial: 'shift_list', locals: { shift: shift, classes: [(shift.user_id ? 'secondary claimed' : 'success unclaimed'), 'medium-6'] }
    - unless shift.expired?
      .cell.small-12.medium-6
        .button-group.stacked-for-small
          - if shift.user_id
            = link_to 'Remove Volunteer', need_shift_path(@need, shift, { shift: { user_id: nil }, redirect_to: need_shifts_path(@need) }), method: :put, class: 'button warning', data: { confirm: 'Are you sure you want to unassign this Volunteer?' }
          - else
            %button.button.success{ data: { open: "volunteerModal#{i}" } } Assign Volunteer
          = link_to 'Delete Shift', need_shift_path(@need, shift, redirect_to: need_shifts_path(@need)), method: :delete, class: 'button alert', data: { confirm: 'Are you sure you want to delete this Shift?' }
        .reveal{ id: "volunteerModal#{i}", data: { reveal: true } }
          %button.close-button{ data: { close: true }, aria: { label: 'Close Modal' } }
            %i.fas.fa-times
          = form_for shift, url: need_shift_path(@need, shift, redirect_to: need_shifts_path(@need)), method: :patch, class: 'user-select-form' do |f|
            = f.collection_select :user_id, @need.office.users.volunteerable, :id, :name
            = f.submit 'Update', class: 'button success'
= link_to need_shifts_path(@need, shift: { start_at: shifts.last.start_at + shifts.last.duration.minutes, duration: 60 }), method: :post do
  .grid-x.grid-margin-y.grid-margin-x
    .cell.small-12.medium-6.shift.add-shift
      .grid-x.grid-padding-x.grid-padding-y
        .cell.text-center
          %i.fas.fa-plus
          Add Shift After