module YeshuaCrm module Liquid class CellsDrop < ::Liquid::Drop def self.default_drop self.new Cell.visible.order(:name) end def initialize(cells) @cells = cells end def before_method(identifier) cell = @cells.where(:identifier => identifier).first || Cell.new CellDrop.new cell end def all @all ||= @cells.map do |cell| CellDrop.new cell end end def active @active ||= @cells.select(&:active?).map do |cell| CellDrop.new cell end end def each(&block) all.each(&block) end def size @cells.size end end class CellDrop < ::Liquid::Drop include ActionView::Helpers::UrlHelper delegate :id, :identifier, :name, :is_public, :description, :visible?, :active?, :archived?, :short_description, :start_date, :due_date, :overdue?, :completed_percent, :to => :@cell def initialize(cell) @cell = cell end def link link_to @cell.name, self.url end def url Rails.application.routes.url_helpers.cell_path(@cell) end def issues @issues ||= IssuesDrop.new @cell.issues.visible end def users @users ||= UsersDrop.new @cell.users end def subcells @subcells ||= CellsDrop.new @cell.children end def custom_field_values @cell.custom_field_values end end end end