Sha256: 0c706aa42196a40ce20c71114f1c0ff183f4b7c2081213e85211afd04bb78b7e

Contents?: true

Size: 1.69 KB

Versions: 8

Compression:

Stored size: 1.69 KB

Contents

module Dorsale::Flyboy::ApplicationHelper
  include ::Handles::SortableColumns::InstanceMethods

  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

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

  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

  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

  def flyboy_status_for_filters_select
    {
      Dorsale::Flyboy::Folder.t("status.all")    => "",
      Dorsale::Flyboy::Folder.t("status.open")   => "open",
      Dorsale::Flyboy::Folder.t("status.closed") => "closed",
    }
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dorsale-3.1.7 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.6 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.5 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.4 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.3 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.2 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.1 app/helpers/dorsale/flyboy/application_helper.rb
dorsale-3.1.0 app/helpers/dorsale/flyboy/application_helper.rb