class Omniboard::ProjectWrapper

Attributes

column[RW]
dimmed[RW]

Is this project dimmed (i.e. shown “faded out”)

dimmed?[RW]

Is this project dimmed (i.e. shown “faded out”)

group[RW]
icon[RW]

Should this project display an icon in the kanban? If so, what's the filename of the icon?

icon_alt[RW]

If this project displayed an icon, we can supply an alternate text

marked[RW]

Is this project marked to show up specially?

marked?[RW]

Is this project marked to show up specially?

project[RW]

Public Class Methods

new(project, column: nil) click to toggle source

Create a new project wrapper, wrapping project

# File lib/omniboard/project_wrapper.rb, line 21
def initialize(project, column: nil)
  @project = project
  @column = column
  @marked = false
end

Public Instance Methods

all_tasks_deferred?() click to toggle source

Are all the available tasks in this project deferred?

# File lib/omniboard/project_wrapper.rb, line 97
def all_tasks_deferred?
        next_tasks.size > 0 && actionable_tasks.size == 0
end
colour() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 29
def colour
        if @column && @column.colour
                @column.colour
        elsif @group
                @group.colour
        else
                Omniboard::Group.colour
        end
end
css_classes() click to toggle source

A list of CSS classes to apply to this project

# File lib/omniboard/project_wrapper.rb, line 88
def css_classes
        classes = ["project", column.display]
        classes << "marked" if marked?
        classes << "dimmed" if dimmed?
        classes << "hidden" if dimmed? && column && column.property(:hide_dimmed)
        classes
end
days_until_action() click to toggle source

How many days until one of our tasks becomes available?

# File lib/omniboard/project_wrapper.rb, line 102
def days_until_action
        earliest_start = next_tasks.map(&:start).sort.first
        if earliest_start.nil?
                0
        else
                earliest_start = earliest_start.to_date
                if earliest_start < Date.today
                        0
                else
                        (earliest_start - Date.today).to_i
                end
        end
end
deferred_date() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 71
def deferred_date
        if self.start
                self.start.strftime("%d %B %Y")
        else
                ""
        end
end
due_date() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 79
def due_date
        if self.due
                self.due.strftime("%d %B %Y")
        else
                ""
        end
end
formatted_note() click to toggle source

Format this project's note field to create nice html

# File lib/omniboard/project_wrapper.rb, line 67
def formatted_note
        @formatted_note ||= Omniboard::StyledText.parse(self.note || "").to_html
end
light_colour() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 39
def light_colour
        (@group || Omniboard::Group).light_colour
end
method_missing(sym, *args, &blck) click to toggle source
# File lib/omniboard/project_wrapper.rb, line 52
def method_missing(sym, *args, &blck)
        if @project.respond_to?(sym)
                @project.send(sym, *args, &blck)
        else
                raise NoMethodError, "undefined method #{sym} for #{self.inspect}"
        end
end
num_tasks() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 45
def num_tasks
        @num_tasks ||= project.incomplete_tasks.count
end
task_list() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 62
def task_list
        tasks_to_list(@project.tasks)
end
to_s() click to toggle source
# File lib/omniboard/project_wrapper.rb, line 116
def to_s
        self.project.to_s || ""
end

Private Instance Methods

tasks_to_list(arr) click to toggle source
# File lib/omniboard/project_wrapper.rb, line 121
def tasks_to_list(arr)
        arr = arr.sort_by(&:rank)
        "<ul>" + arr.map { |task| %|<li class="#{task.completed? ? "complete" : "incomplete"}">#{task.name}| + (task.has_subtasks? ? tasks_to_list(task.tasks) : "") + "</li>" }.join("") + "</ul>"
end