anthonymidili/Bullhorn

View on GitHub
app/views/events/_form.html.haml

Summary

Maintainability
Test Coverage
= form_with model: @event, data: { turbo: false } do |f|
  = render 'notifications/error_messages', object: f.object

  .row
    .col-12.col-lg-6
      .field.mb-3
        = f.label :image, class: "form-label"
        = f.hidden_field :image, value: f.object.image.signed_id if f.object.image.attached?
        = f.file_field :image, direct_upload: true, class: "form-control", 
        accept: 'image/png,image/jpg,image/jpeg,image/gif'
    .col-12.col-lg-6
      - if f.object.image.attached?
        .mb-3
          .image= image_tag medium_image(f.object.image), class: "img-thumbnail"
          .remove= link_to 'Remove image', remove_image_event_path(f.object) if f.object.persisted?
  .field.mb-3
    = f.label :name, class: "form-label"
    = f.text_field :name, class: "form-control"
  = render 'address/fields', f: f,
  location_examples: 'Examples - Home, Business, Plaza'
  .field.mb-3
    = f.label :description, class: "form-label"
    = f.text_area :description, rows: 3, class: "form-control"
  .field.mb-3
    = f.label :start_date, class: "form-label"
    = f.datetime_select :start_date, ampm: true, minute_step: 5, class: "form-control"
  .field.mb-3
    = f.label :end_date, class: "form-label"
    = f.datetime_select :end_date, ampm: true, minute_step: 5, class: "form-control"
  .field.mb-3
    = f.label :timezone, 'Event timezone', class: "form-label"
    = f.time_zone_select :timezone, ActiveSupport::TimeZone.us_zones,
    default: current_user.timezone, class: "form-control"
  .field.links{data: { controller: "check-box-select-all" }}
    .mb-3
      %h3 Who are you inviting?
      = button_tag "Select all", 
      { data: { action: "click->check-box-select-all#selectAll" },
      type: "button", class: "btn btn-outline-primary btn-sm" }
      = button_tag "Clear all", 
      { data: { action: "click->check-box-select-all#clearAll" },
      type: "button", class: "btn btn-outline-secondary btn-sm" }
      #check_boxes.row
    -# Add event creator into user_ids so creator does not have to be
    -# selected as going.
    = hidden_field_tag "event[user_ids][]", f.object.user.id
    
    -# Render followers and following check box array to select
    -# who will be invited.
    .row
      - f.object.user.all_relationships.each do |user|
        = render 'invitations/check_box', event: f.object, user: user
  .actions.mb-3
    = f.submit class: 'btn btn-primary'