Sha256: 19469924698430b411ae11d37abc937de2454350894653c9c41cc626029b995c

Contents?: true

Size: 1.47 KB

Versions: 34

Compression:

Stored size: 1.47 KB

Contents

module RedmineExtensions
  module ApplicationControllerPatch

    def self.included(base)
      base.extend ClassMethods
      base.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

      private

      def save_easy_settings(project = nil)
        if params[:easy_setting]
          wrapper = EasySettings::ParamsWrapper.from_params(params.require(:easy_setting).permit!, project: project)
          wrapper.save
          wrapper
        end
      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

34 entries across 34 versions & 1 rubygems

Version Path
redmine_extensions-0.6.3 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.6.2 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.6.1 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.6.0 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.4.5 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.5.1 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.4.4 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.4.3 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.4.1 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.4.0 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.4.0.beta lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.11 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.10 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.9 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.8 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.7 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.6 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.4 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.3 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb
redmine_extensions-0.3.2 lib/redmine_extensions/redmine_patches/controllers/application_controller_patch.rb