Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #439 ability to cancel individual event date #534

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/assets/stylesheets/events.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ table.eventslist td:first-child {
}

/* row colors */
/*
All of these are event statuses,
except for this_date_cancelled which can
only come from eventdate.status for a
cancelled eventdate.
*/
table.eventslist tr.event_confirmed { background: #E2F2E2; }
table.eventslist tr.event_confirmed > td:first-child { background: #00FF00; font-size: 5px; }
table.eventslist tr.billing_pending { background: #E1EAEF; }
Expand All @@ -90,6 +96,9 @@ table.eventslist tr.event_completed > td:first-child { background: #00A4FF; font
table.eventslist tr.event_cancelled { background: #F9F9F9; color: #AAAAAA; }
table.eventslist tr.event_cancelled > td:first-child { background: #ECECEC; font-size: 5px; }
table.eventslist tr.event_cancelled a { color: #9999FF; }
table.eventslist tr.this_date_cancelled { background: #F9F9F9; color: #AAAAAA; }
table.eventslist tr.this_date_cancelled > td:first-child { background: #ECECEC; font-size: 5px; }
table.eventslist tr.this_date_cancelled a { color: #9999FF; }
table.eventslist tr.quote_sent,
table.eventslist tr.details_requested { background: #F7F7D3; }
table.eventslist tr.quote_sent > td:first-child,
Expand Down Expand Up @@ -191,6 +200,10 @@ table.eventslist .ticless {
border-right: 1px solid #ccc;
}

#event-schedule table.this_date_cancelled {
color: #AAAAAA;
}

#event-schedule table th {
font-weight: bold;
background-color: #f7f7f7;
Expand All @@ -214,7 +227,6 @@ table.eventslist .ticless {
}

#event-schedule td.es-time {
color: #222;
white-space: nowrap;
}

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def update
:textable, :textable_social, :publish, :contact_name, :contactemail, :contact_phone, :price_quote, :notes,
:eventdates_attributes =>
[:id, :_destroy, :startdate, :description, :enddate, :calldate, :strikedate, :calltype, :striketype,
:billable_call, :billable_show, :billable_strike,
:billable_call, :billable_show, :billable_strike, :cancelled,
:email_description, :notes, {:location_ids => []}, {:equipment_profile_ids => []},
{:event_roles_attributes => [:id, :role, :member_id, :appliable, :_destroy]}],
:attachments_attributes => [:attachment, :name, :id, :_destroy],
Expand Down Expand Up @@ -250,6 +250,7 @@ def update
p[:eventdates_attributes][key].delete(:billable_call)
p[:eventdates_attributes][key].delete(:billable_show)
p[:eventdates_attributes][key].delete(:billable_strike)
p[:eventdates_attributes][key].delete(:cancelled)

assistants = red.run_positions_for(current_member).flat_map(&:assistants)
p[:eventdates_attributes][key][:event_roles_attributes].select! do |_,er|
Expand Down
5 changes: 5 additions & 0 deletions app/models/eventdate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Eventdate < ApplicationRecord
accepts_nested_attributes_for :event_roles, :allow_destroy => true

validates_presence_of :startdate, :enddate, :description, :locations, :calltype, :striketype
validates_inclusion_of :cancelled, :in => [true, false]
validates_associated :locations, :equipment_profile
validate :dates, :validate_call, :validate_strike

Expand Down Expand Up @@ -195,6 +196,10 @@ def self.weekify(eventdates)
end
end

def status
cancelled ? "This Date Cancelled" : event.status
end

private
def prune_roles
self.event_roles = self.event_roles.reject { |er| er.role.blank? }
Expand Down
4 changes: 4 additions & 0 deletions app/views/events/_eventdate_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<dt><%= f.label :billable_strike, "Strike Billable:" %></dt>
<dd><%= f.check_box :billable_strike %></dd>
</dl>
<dl class="big-field">
<dt><%= f.label :cancelled, "Cancelled:" %></dt>
<dd><%= f.check_box :cancelled %></dd>
</dl>
<dl>
<dt><%= f.label :calldate, "Call:" %></dt>
<dd>
Expand Down
4 changes: 2 additions & 2 deletions app/views/events/_run.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% run.each_with_index do |eventdate, run_i| %>
<tr class="<%= eventdate.event.status.delete(' ').underscore %>">
<tr class="<%= eventdate.status.delete(' ').underscore %>">
<td>&nbsp;</td>
<td>
<% if eventdate.startdate.year == Date.today.year %>
Expand All @@ -8,7 +8,7 @@
<%= eventdate.startdate.strftime("%A, %B %d, %Y") %>
<% end %><br />
<% if can? :read, Event %>
<small class="published">(<%= eventdate.event.status.downcase %><%= eventdate.event.rental ? ", rental" : "" %><%= !eventdate.event.publish ? ",<br/><b>not published</b>".html_safe : "" %>)</small>
<small class="published">(<%= eventdate.status.downcase %><%= eventdate.event.rental ? ", rental" : "" %><%= !eventdate.event.publish ? ",<br/><b>not published</b>".html_safe : "" %>)</small>
<% end %>
</td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

<div id="event-schedule">
<% @event.eventdates.each do |eventdate| %>
<table>
<table<% if eventdate.cancelled %> class="this_date_cancelled"<% end %>>
<tr>
<th colspan=4><%= eventdate.description %></th>
<th colspan=4><%= eventdate.description %><% if eventdate.cancelled %> (Cancelled)<% end %></th>
</tr>
<% eventdate.times.each do |time| %>
<tr>
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20231127150626_cancel_eventdates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CancelEventdates < ActiveRecord::Migration[6.1]
def up
add_column :eventdates, :cancelled, :boolean, default: false
end

def down
remove_column :eventdates, :cancelled
end
end
6 changes: 4 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.