Sha256: 81c33d09bf1dc41d01a16c52e03f9a1da3fa5a3514330c8ce2c34a905f8012ad

Contents?: true

Size: 1.77 KB

Versions: 24

Compression:

Stored size: 1.77 KB

Contents

module RedmineCrm
  module Liquid
    class ProjectsDrop < ::Liquid::Drop

      def self.default_drop
        self.new Project.visible.order(:name)
      end

      def initialize(projects)
        @projects = projects
      end

      def before_method(identifier)
        project = @projects.where(:identifier => identifier).first || Project.new
        ProjectDrop.new project
      end

      def all
        @all ||= @projects.map do |project|
          ProjectDrop.new project
        end
      end

      def active
        @active ||= @projects.select(&:active?).map do |project|
          ProjectDrop.new project
        end
      end

      def each(&block)
        all.each(&block)
      end

      def size
        @projects.size
      end
    end

    class ProjectDrop < ::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 => :@project

      def initialize(project)
        @project = project
      end

      def link
        link_to @project.name, self.url
      end

      def url
        Rails.application.routes.url_helpers.project_path(@project)
      end

      def issues
        @issues ||= IssuesDrop.new @project.issues
      end

      def users
        @users ||= UsersDrop.new @project.users
      end

      def subprojects
        @subprojects ||= ProjectsDrop.new @project.children
      end

      def custom_field_values
        @project.custom_field_values
      end         
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
redmine_crm-0.0.63 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.62 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.61 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.60 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.59 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.58 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.57 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.56 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.55 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.54 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.53 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.52 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.51 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.50 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.49 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.48 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.47 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.46 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.45 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.44 lib/redmine_crm/liquid/drops/projects_drop.rb