Module: Dorsale::Flyboy::ApplicationHelper

Includes:
Handles::SortableColumns::InstanceMethods
Included in:
AllHelpers
Defined in:
app/helpers/dorsale/flyboy/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#folder_color(folder) ⇒ Object



39
40
41
42
43
44
# File 'app/helpers/dorsale/flyboy/application_helper.rb', line 39

def folder_color(folder)
  return "onalert"   if ::Dorsale::Flyboy::Task.where(taskable: folder).where('done = ? AND term < ?', false, Time.zone.now.to_date).count > 0
  return "onwarning" if ::Dorsale::Flyboy::Task.where(taskable: folder).where('done = ? AND term > ? AND reminder < ?', false, Time.zone.now.to_date, Time.zone.now.to_date).count > 0
  return "finished"  if folder.closed?
  return "ontime"
end

#show_tasks_summaryObject



28
29
30
# File 'app/helpers/dorsale/flyboy/application_helper.rb', line 28

def show_tasks_summary
  render "dorsale/flyboy/tasks/summary"
end

#task_color(task) ⇒ Object



32
33
34
35
36
37
# File 'app/helpers/dorsale/flyboy/application_helper.rb', line 32

def task_color(task)
  return "finished" if task.done
  return "ontime"   if task.reminder > Time.zone.now.to_date
  return "onalert"  if task.term     < Time.zone.now.to_date
  return "onwarning"
end

#tasks_for(taskable) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/dorsale/flyboy/application_helper.rb', line 6

def tasks_for(taskable)
  @filters = ::Dorsale::Flyboy::SmallData::FilterForTasks.new(cookies)

  order ||= sortable_column_order do |column, direction|
    case column
    when "name", "status"
      %(LOWER(dorsale_flyboy_tasks.#{column}) #{direction})
    when "progress", "term"
      %(dorsale_flyboy_tasks.#{column} #{direction})
    else
      params["sort"] = "term"
      "dorsale_flyboy_tasks.term ASC"
    end
  end

  tasks = ::Dorsale::Flyboy::Task.where(taskable: taskable)
  tasks = @filters.apply(tasks)
  tasks = tasks.order(order)

  render "dorsale/flyboy/tasks/tasks_for_taskable", tasks: tasks, taskable: taskable
end