Sha256: 2cc49db8503ad3786af75a93fbac8370e02b74d262b3cb2939031224554419ec

Contents?: true

Size: 1.69 KB

Versions: 18

Compression:

Stored size: 1.69 KB

Contents

require 'ransack' if Itsf::Backend.features?(:ransack)
require 'kaminari' if Itsf::Backend.features?(:kaminari)

module Itsf::Backend
  class Resource::BaseController < Configuration.resource_base_controller.constantize
    if Itsf::Backend.features?(:pundit)
      include Controller::RestActionsConcernWithPundit
      include Pundit
      prepend Controller::PunditNamespacedAuthorizeConcern
      include Controller::PunditAuthorizationFailureHandlingConcern
      helper_method :engine_policy
    else
      include Controller::RestActionsConcern
    end
    include Controller::ResourceUrlsConcern
    include Controller::ResourceInflectionsConcern
    include Controller::RansackConcern if Itsf::Backend.features?(:ransack)
    include Controller::PaginationConcern if Itsf::Backend.features?(:kaminari)
    include Controller::JsonApiConcern
    helper Itsf::Backend::ApplicationHelper
    helper MultiClientHelper if Itsf::Backend.features?(:multi_client)
    
    helper_method :resource_class

    helper ResourceRenderer::ViewHelper

    layout 'itsf/backend/base'

    def self.resource_class
      name.gsub('Controller', '').singularize.constantize
    end

    def resource_class
      self.class.resource_class
    end

    private

    def after_create_location
      return edit_resource_path(@resource) if params.has_key?(:commit_and_continue_with_edit)
      return new_resource_path if params.has_key?(:commit_and_continue_with_new)
      collection_path  
    end

    def after_update_location
      return edit_resource_path(@resource) if params.has_key?(:commit_and_continue_with_edit)
      return new_resource_path if params.has_key?(:commit_and_continue_with_new)
      collection_path  
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
itsf_backend-2.1.0 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-2.0.2 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-2.0.1 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.8 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.7 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.6 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.5 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.4 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.1 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.2.0 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.15 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.14 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.13 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.12 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.11 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.10 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.9 app/controllers/itsf/backend/resource/base_controller.rb
itsf_backend-1.1.8 app/controllers/itsf/backend/resource/base_controller.rb