Sha256: 91276034e2fdca17aac53b4e00efb0418a4c9da791bf70e0d7319b1e8261f2c2

Contents?: true

Size: 1.78 KB

Versions: 13

Compression:

Stored size: 1.78 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.visible
      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

13 entries across 13 versions & 1 rubygems

Version Path
redmine_crm-0.0.38 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.37 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.36 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.35 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.34 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.33 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.32 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.31 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.30 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.28 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.27 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.26 lib/redmine_crm/liquid/drops/projects_drop.rb
redmine_crm-0.0.25 lib/redmine_crm/liquid/drops/projects_drop.rb