Sha256: 4371ddd4f4e7f51fe692e3420308bee4112edc7b4a974ac032e050996500bd9a

Contents?: true

Size: 1.29 KB

Versions: 24

Compression:

Stored size: 1.29 KB

Contents

module KepplerFrontend
  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(request.path.split('/')[1..-2].map(&:to_sym).push(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

24 entries across 24 versions & 1 rubygems

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