Skip to content

Resolve #439 by adding eventdate statuses #536

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 23 additions & 1 deletion app/assets/stylesheets/events.css.scss
Original file line number Diff line number Diff line change
@@ -81,6 +81,12 @@ table.eventslist td:first-child {
}

/* row colors */
table.eventslist tr.date_completed { background: #E1EAEF; }
table.eventslist tr.date_completed > td:first-child { background: #00A4FF; font-size: 5px; }
table.eventslist tr.date_cancelled { background: #F9F9F9; color: #AAAAAA; }
table.eventslist tr.date_cancelled > td:first-child { background: #ECECEC; font-size: 5px; }
table.eventslist tr.date_cancelled a { color: #9999FF; }

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; }
@@ -183,6 +189,23 @@ table.eventslist .ticless {
}
}

/* Event schedule */

#event-schedule table.date_completed * { background: #E1EAEF; }
#event-schedule table.date_completed tr:first-child * { background: #00A4FF; }

#event-schedule table.date_cancelled * { background: #F9F9F9; color: #AAAAAA; }
#event-schedule table.date_cancelled * { background: #ECECEC; }
#event-schedule table.date_cancelled tr:first-child a { color: #9999FF; }

//table.eventslist tr.date_completed { background: #E1EAEF; }
//table.eventslist tr.date_completed > td:first-child { background: #00A4FF; font-size: 5px; }
//
//table.eventslist tr.date_cancelled { background: #F9F9F9; color: #AAAAAA; }
//table.eventslist tr.date_cancelled { background: #F9F9F9; color: #AAAAAA; }
//table.eventslist tr.date_cancelled > td:first-child { background: #ECECEC; font-size: 5px; }
//table.eventslist tr.date_cancelled a { color: #9999FF; }

#event-schedule table {
width: 100%;
margin-bottom: 1em;
@@ -214,7 +237,6 @@ table.eventslist .ticless {
}

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

5 changes: 3 additions & 2 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ def create
:textable, :textable_social, :publish, :contact_name, :contactemail, :contact_phone, :price_quote, :notes, :created_email,
:eventdates_attributes =>
[:startdate, :description, :enddate, :calldate, :strikedate, :calltype, :striketype, :email_description, :notes,
:billable_call, :billable_show, :billable_strike,
:billable_call, :billable_show, :billable_strike, :status,
{:location_ids => []}, {:equipment_profile_ids => []}, {:event_roles_attributes => [:role, :member_id, :appliable]}],
:event_roles_attributes => [:role, :member_id, :appliable],
:attachments_attributes => [:attachment, :name],
@@ -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, :status,
:email_description, :notes, {:location_ids => []}, {:equipment_profile_ids => []},
{:event_roles_attributes => [:id, :role, :member_id, :appliable, :_destroy]}],
:attachments_attributes => [:attachment, :name, :id, :_destroy],
@@ -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(:status)

assistants = red.run_positions_for(current_member).flat_map(&:assistants)
p[:eventdates_attributes][key][:event_roles_attributes].select! do |_,er|
39 changes: 38 additions & 1 deletion app/models/eventdate.rb
Original file line number Diff line number Diff line change
@@ -9,9 +9,21 @@ class Eventdate < ApplicationRecord
include_association [:event_roles, :locations, :equipment_profile]
end

Eventdate_Status_Incomplete = "Date Incomplete"
Eventdate_Status_Completed = "Date Completed"
Eventdate_Status_Cancelled = "Date Cancelled"

Eventdate_Status_Group_All = [
Eventdate_Status_Incomplete,
Eventdate_Status_Completed,
Eventdate_Status_Cancelled,
]


accepts_nested_attributes_for :event_roles, :allow_destroy => true

validates_presence_of :startdate, :enddate, :description, :locations, :calltype, :striketype
validates_presence_of :startdate, :enddate, :description, :locations, :calltype, :striketype, :status
validates_inclusion_of :status, :in => Eventdate_Status_Group_All
validates_associated :locations, :equipment_profile
validate :dates, :validate_call, :validate_strike

@@ -195,6 +207,31 @@ def self.weekify(eventdates)
end
end

def cancelled?
status == Eventdate_Status_Cancelled
end

def completed?
status == Eventdate_Status_Completed
end

def incomplete?
status == Eventdate_Status_Incomplete
end

def status_hint
status unless incomplete?
end

def css_class
status.delete(' ').underscore unless incomplete?
end

def row_css_class
return status.delete(' ').underscore unless incomplete?
event.status.delete(' ').underscore
end

private
def prune_roles
self.event_roles = self.event_roles.reject { |er| er.role.blank? }
4 changes: 4 additions & 0 deletions app/views/events/_eventdate_fields.html.erb
Original file line number Diff line number Diff line change
@@ -8,6 +8,10 @@
<dt><%= f.label :email_description, "Weekly Email Description:" %></dt>
<dd><%= f.text_area :email_description %></dd>
</dl>
<dl>
<dt><%= f.label :status, "Status:" %></dt>
<dd><%= f.select :status, Eventdate::Eventdate_Status_Group_All %></dd>
</dl>
<dl class="big-field">
<dt><%= f.label :billable_call, "Call Billable:" %></dt>
<dd><%= f.check_box :billable_call %></dd>
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.row_css_class %>">
<td>&nbsp;</td>
<td>
<% if eventdate.startdate.year == Date.today.year %>
@@ -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_hint.downcase + ", " if eventdate.status_hint %><%= eventdate.event.status.downcase %><%= eventdate.event.rental ? ", rental" : "" %><%= !eventdate.event.publish ? ",<br/><b>not published</b>".html_safe : "" %>)</small>
<% end %>
</td>
<td>
4 changes: 2 additions & 2 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
@@ -6,9 +6,9 @@

<div id="event-schedule">
<% @event.eventdates.each do |eventdate| %>
<table>
<table class="<%= eventdate.css_class %>">
<tr>
<th colspan=4><%= eventdate.description %></th>
<th colspan=4><%= eventdate.description %><%= " (" + eventdate.status_hint + ")" if eventdate.status_hint %></th>
</tr>
<% eventdate.times.each do |time| %>
<tr>
9 changes: 9 additions & 0 deletions db/migrate/20231127195405_eventdate_statuses.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class EventdateStatuses < ActiveRecord::Migration[6.1]
def up
add_column :eventdates, :status, :string, default: "Date Incomplete"
end

def down
remove_column :eventdates, :status
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.