Sha256: 94726dfd2146f451327de69fbc8c9da65a221d6303c8190a7ac39151baf0afa7

Contents?: true

Size: 1.17 KB

Versions: 9

Compression:

Stored size: 1.17 KB

Contents

module RedmineExtensions
  module ApplicationControllerPatch

    def self.included(base)
      base.extend(ClassMethods)
      base.send(:include, InstanceMethods)

      base.class_eval do
      end
    end

    module InstanceMethods

      def index_for_easy_query(query_klass, *)
        @query = query_klass.new(name: '_')
        @query.project = @project
        @query.build_from_params(params)

        sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
        sort_update(@query.sortable_columns)

        @entities = @query.entities
      end

      def easy_extensions?
        self.class.easy_extensions?
      end

    end

    module ClassMethods

      def easy_extensions?
        Redmine::Plugin.installed?(:easy_extensions)
      end

      def include_query_helpers
        if easy_extensions?
          helper :easy_query
          include EasyQueryHelper
        else
          helper :queries
          include QueriesHelper
        end

        helper :sort
        include SortHelper
      end

    end

  end
end

RedmineExtensions::PatchManager.register_controller_patch 'ApplicationController', 'RedmineExtensions::ApplicationControllerPatch'

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
redmine_extensions-0.0.22 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.21 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.20 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.19 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.18 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.17 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.16 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.15 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.14 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb