app/views/admin/events/edit.html.erb
<% @page_title = "Admin: Events: #{@event.name}" %>
<%= render "shared/errors", object: @event %>
<h2><%= link_to_parents(@event) %><%= @event.name %></h2>
<div class="edit_event">
<div class="row">
<div class="col-sm-6">
<%= render partial: "parent", object: @event %>
<%= render partial: "events", object: @event %>
<%= render partial: "admin/races_collections/show", locals: { event: @event, previous: @previous } %>
</div>
<div class="col-sm-6">
<%= form_for(@event,
as: :event,
url: @event.new_record? ? admin_events_path : admin_event_path(@event),
html: { class: "form-horizontal", role: "form", method: form_method_for(@event) }) do |f| -%>
<%= f.labelled_select_modal :parent, "event", true %>
<%= f.labelled_text_field :name, nil, editable: administrator?, class: "wants_focus form-control" %>
<% if administrator? %>
<% unless @event.new_record? -%>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<%= link_to "Duplicate", new_admin_event_path(event: @event.attributes_for_duplication), class: "obvious", id: "duplicate_event" %>
</div>
</div>
<% end -%>
<% if @event.type_modifiable? %>
<%= f.labelled_select(:type, [['Event', 'Event'],
['Single Day Event', 'SingleDayEvent'],
['Multi Day Event', 'MultiDayEvent'],
['Series', 'Series'],
['Weekly Series', 'WeeklySeries']],
{},
class: "form-control",
title: "Event: placeholder hidden from schedule (combined TT results).
\nSingle day event: most events.
\nMulti day event: event over consecutive days (stage races, AVC).
\nSeries: weekend events with full BAR points (Cross Crusade).
\nWeekly series: weeknight, BAR points only for overall (PIR)") %>
<% else -%>
<%= f.labelled_text :type, @event.friendly_class_name %>
<% end -%>
<% end -%>
<% case @event
when SingleDayEvent -%>
<% if administrator? %>
<%= f.labelled_date_picker :date %>
<% else %>
<%= f.labelled_text(:date, @event.date ? @event.date.strftime('%A, %B %-d, %Y') : "") %>
<% end -%>
<% when MultiDayEvent -%>
<%- if @event.start_date == @event.end_date -%>
<%= f.labelled_text(:date, @event.start_date ? @event.start_date.strftime('%A, %B %-d, %Y') : "") %>
<%- else -%>
<%= f.labelled_text(:date, (@event.start_date && @event.end_date) ? "#{@event.start_date.strftime('%a %-m/%-d/%Y')} to #{@event.end_date.strftime('%a %-m/%-d/%Y')}" : "") %>
<%- end -%>
<% else -%>
<%= f.labelled_text(:date, @event.date ? @event.date.strftime('%A, %B %-d, %Y') : "") %>
<% end -%>
<%= f.labelled_text_field(:time) if administrator? %>
<%= f.labelled_select(:discipline, @disciplines.sort) if administrator? %>
<div class="form-group form-inline">
<%= f.label :city, "City, State", class: "control-label col-sm-4" %>
<div class="col-sm-8">
<%= f.text_field :city, class: "city_no_zip form-control", maxlength: 30 %>
<%= f.text_field :state, class: "state_no_zip form-control", maxlength: 10 %>
</div>
</div>
<% if Region.count > 0 -%>
<%= f.labelled_select :region_id, Region.order("name").all.map { |r| [ r.name, r.id ] } %>
<%- end %>
<% if RacingAssociation.current.show_events_velodrome? && administrator? -%>
<%= f.labelled_select(:velodrome_id, Velodrome.all.sort_by(&:name).collect {|v| [ v.name, v.id ] }, include_blank: true) %>
<% end -%>
<% if administrator? %>
<div class="check-boxes">
<%= f.labelled_check_box :tentative %>
<%= f.labelled_check_box :canceled %>
<%= f.labelled_check_box :postponed %>
<%= f.labelled_check_box :instructional %>
<%= f.labelled_check_box :practice %>
<%= f.labelled_check_box :beginner_friendly %>
</div>
<% end -%>
<% if administrator? %>
<div class="form-group promoter">
<%= f.label :promoter_id, nil, class: "control-label col-sm-4" %>
<div class="col-sm-8">
<%= f.select_modal :promoter, "person" %>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<a href="#" class="obvious" data-event-id="<%= @event.id %>" id="edit_promoter_link">Edit</a>
</div>
</div>
<% end -%>
<div class="col-sm-offset-4 panel panel-default">
<div class="panel-body">
<h4>Contact Information</h4>
<span class="help-block">If different than promoter's personal contact information</span>
<%= f.labelled_text_field :phone %>
<%= f.labelled_text_field :email %>
</div>
</div>
<% if administrator? %>
<div class="form-group team">
<%= f.label :team_id, "Sponsoring Team", class: "control-label col-sm-4" %>
<div class="col-sm-8">
<%= f.select_modal :team, "team" %>
</div>
</div>
<% end %>
<%= f.labelled_text_field :first_aid_provider, nil, editable: administrator?, class: "form-control col-sm-12" %>
<%= f.labelled_text_field :chief_referee, nil, editable: administrator?, class: "form-control col-sm-12" %>
<% if RacingAssociation.current.sanctioning_organizations.many? -%>
<%= f.labelled_select :sanctioned_by, RacingAssociation.current.sanctioning_organizations %>
<%- end %>
<% if administrator? -%>
<% if RacingAssociation.current.show_events_sanctioning_org_event_id? -%>
<%= f.labelled_text_field :sanctioning_org_event_id, "Sanctioning Org Event ID" %>
<% end -%>
<%= f.labelled_select(:number_issuer_id, NumberIssuer.order(:name).collect {|i| [i.name, i.id]}) %>
<%= f.labelled_check_box :atra_points_series, "ATRA National Championship Series (NCS)" if RacingAssociation.current.competitions.include?(:atra_points_series) %>
<% end -%>
<%= f.labelled_text_field :flyer, nil, editable: administrator?, class: "form-control" %>
<% if administrator? -%>
<%= f.labelled_check_box :flyer_approved, nil %>
<% unless RacingAssociation.current.short_name == "OBRA" -%>
<%= f.labelled_text_field :website, nil, editable: administrator?, class: "form-control" %>
<%= f.labelled_text_field :registration_link, nil, editable: administrator?, class: "form-control" %>
<% end -%>
<%= f.labelled_text_field :pre_event_fees %>
<%= f.labelled_text_field :post_event_fees %>
<%= f.labelled_text_field :flyer_ad_fee %>
<%= f.labelled_text_area :notes, class: "ckeditor col-sm-12" %>
<% end -%>
<div class="form-group col-sm-12">
<%= submit_tag "Save", class: "btn btn-default", id: "save" %>
<%= link_to("Delete", admin_event_path(@event), method: :delete, class: "btn btn-default", id: 'delete') unless @event.new_record? || !administrator? %>
<% if @event.updated_at.present? %>
<div class="pull-right created_updated hidden-xs">
Updated: <%= time_ago_in_words(@event.updated_at, include_seconds: true) %> ago
</div>
<div class="pull-right created_updated visible-xs">
<% @event.updated_at.nil? %>Updated <%= @event.updated_at.to_s(:mdy) %>
</div>
<% end -%>
</div>
<% end -%>
</div>
</div>
</div>
<%= render partial: "modals/select",
locals: {
method: "parent",
object_name: "event",
target: "event_parent",
type: "event"
} %>
<%= render partial: "modals/select",
locals: {
method: "promoter",
object_name: "event",
target: "event_promoter",
type: "person"
} %>
<%= render partial: "modals/select",
locals: {
method: "team",
object_name: "event",
target: "event_team",
type: "team"
} %>
<%# TODO UJS %>
<% if (!@event.promoter || @event.new_record?) && administrator? %>
<% content_for :head do %>
<script type="text/javascript">
$(document).ready(function() {
$('#edit_promoter_link').hide();
});
</script>
<% end -%>
<% end -%>