Sha256: 12e2d93863ba12a751b007176bf1df08a4cc3dad0c4c8fa0e94e1309ae1d9ef0

Contents?: true

Size: 1.21 KB

Versions: 31

Compression:

Stored size: 1.21 KB

Contents

module RedmineExtensions
  module ApplicationControllerPatch

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

      base.class_eval do
        helper_method :easy_extensions?
      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

31 entries across 31 versions & 1 rubygems

Version Path
redmine_extensions-0.1.27 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.26 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.25 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.24 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.23 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.21 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.20 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.39 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.19 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.18 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.17 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.16 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.15 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.14 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.38 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.13 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.37 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.11 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.1.10 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.0.36 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb