Sha256: 0ee4733d9d17419469606abe1a024f1ccc13bec1b0fc03a25b4a01f871e44a87

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

module Redmineup
  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

4 entries across 4 versions & 1 rubygems

Version Path
redmineup-1.0.5 lib/redmineup/liquid/drops/projects_drop.rb
redmineup-1.0.4 lib/redmineup/liquid/drops/projects_drop.rb
redmineup-1.0.3 lib/redmineup/liquid/drops/projects_drop.rb
redmineup-1.0.2 lib/redmineup/liquid/drops/projects_drop.rb