Sha256: b3d764a8aa76112f6ab5eba3ac0ac591cfedc1bc682a37152e10d6ffd5589747

Contents?: true

Size: 1.25 KB

Versions: 31

Compression:

Stored size: 1.25 KB

Contents

module KepplerPoll
  module Concerns
    # Concern con la configuracion de parametros de los formulario
    module Commons
      extend ActiveSupport::Concern

      included do
        before_action :set_attachments
        before_action :paginator_params
        before_action :set_setting
      end

      private

      def set_attachments
        @attachments = %w[logo brand photo avatar cover image
                          picture banner attachment pic file]
      end

      def paginator_params
        @search_field = model.search_field if listing?
        @query = params[:search] unless params[:search].blank?
        @current_page = params[:page] unless params[:page].blank?
      end

      def set_setting
        @setting = Setting.first
      end

      def module_name
        self.class.to_s.split('::').first.constantize
      end

      # Get submit key to redirect, only [:create, :update]
      def redirect(object, commit)
        if commit.key?('_save')
          redirect_to([:admin, :ckn, object], notice: actions_messages(object))
        elsif commit.key?('_add_other')
          redirect_to(
            send("new_admin_#{underscore(object)}_path"),
            notice: actions_messages(object)
          )
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
keppler-2.1.22 installer/plugins/concerns/commons.rb
keppler-2.1.21 installer/plugins/concerns/commons.rb
keppler-2.1.20 installer/plugins/concerns/commons.rb
keppler-2.1.19 installer/plugins/concerns/commons.rb
keppler-2.1.18 installer/plugins/concerns/commons.rb
keppler-2.1.17 installer/plugins/concerns/commons.rb
keppler-2.1.16 installer/plugins/concerns/commons.rb
keppler-2.1.15 installer/plugins/concerns/commons.rb
keppler-2.1.14 installer/plugins/concerns/commons.rb
keppler-2.1.13 installer/plugins/concerns/commons.rb
keppler-2.1.12 installer/plugins/concerns/commons.rb
keppler-2.1.11 installer/plugins/concerns/commons.rb
keppler-2.1.10 installer/plugins/concerns/commons.rb
keppler-2.1.9 installer/plugins/concerns/commons.rb
keppler-2.1.8 installer/plugins/concerns/commons.rb
keppler-2.1.7 installer/plugins/concerns/commons.rb
keppler-2.1.6 installer/plugins/concerns/commons.rb
keppler-2.1.5 installer/plugins/concerns/commons.rb
keppler-2.1.4 installer/plugins/concerns/commons.rb
keppler-2.1.3 installer/plugins/concerns/commons.rb