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

Allow task due date inline editing if no date #563

Merged
Merged
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
3 changes: 3 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ body {
text-align: center;
}

.date-view {
cursor: pointer;
}
22 changes: 11 additions & 11 deletions app/models/network_event_task.rb
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
class NetworkEventTask < ApplicationRecord
include PgSearch

pg_search_scope :search_by_task_name,
:against => [:name],
:using => { :tsearch => {:prefix => true} }
belongs_to :user
belongs_to :owner, :class_name => "User"
belongs_to :network_event
belongs_to :common_task

validates_presence_of :name

def self.in_date_range(start_date, end_date)
start_date = Date.strptime(start_date, '%A %B %d %Y')
end_date = Date.strptime(end_date, '%A %B %d %Y')
where(due_date: [start_date.beginning_of_day..end_date.end_of_day, nil])
end

def formatted_due_date
if due_date.present?
due_date.in_time_zone("Central Time (US & Canada)").strftime(' %a, %B %e %Y')
due_date.in_time_zone("Central Time (US & Canada)").strftime(' %a, %B %e %Y')
else
nil
date_modifier
end
end

def formatted_completed_at
if completed_at.present?
completed_at.in_time_zone("Central Time (US & Canada)").strftime(' %a, %B %e %Y')
completed_at.in_time_zone("Central Time (US & Canada)").strftime(' %a, %B %e %Y')
else
nil
end
end

def completed?
return completed_at.present?
end

def as_json(options)
result = super
if completed_at?
result["completed_at"] = completed_at.in_time_zone("Central Time (US & Canada)").strftime(' %a, %B %e %Y')
end
result
end
end
end
6 changes: 3 additions & 3 deletions app/views/network_events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@
</div>
<div class="form-group">
<%= f.label :owner %>
<%= f.collection_select :owner_id, User.all, :id, :email, {:include_blank => "No owner selected"}, class: "select2 form-control"%>
<%= f.collection_select :owner_id, User.all, :id, :email, {:include_blank => "No owner selected"}, class: "select2"%>
</div>
<div class="form-group">
<%= f.label :common_task %>
<%= f.collection_select :common_task_id, CommonTask.all, :id, :name, {:include_blank => "No common task selected" }, class: "select2 form-control"%>
<%= f.collection_select :common_task_id, CommonTask.all, :id, :name, {:include_blank => "No common task selected" }, class: "select2"%>
</div>
<div class="form-group">
<%= f.label :date_modifier, "Due date" %>
Expand All @@ -199,7 +199,7 @@
:to_s,
:titleize,
{},
class: "select2 form-control task-field",
class: "select2 task-field",
multiple: false,
data: {placeholder: 'Select Date Modifier'} %>
</div>
Expand Down