class CmAdmin::ResourceController

def cm_index(params)

def cm_index(params)
  @current_action = CmAdmin::Models::Action.find_by(@model, name: 'index')
  # Based on the params the filter and pagination object to be set
  authorize @ar_object, policy_class: "CmAdmin::#{controller_name.classify}Policy".constantize if defined? "CmAdmin::#{controller_name.classify}Policy".constantize
  records = "CmAdmin::#{@model.name}PolicyIndexScope".constantize.new(Current.user, @model.name.constantize).resolve
  records = records.includes(@current_action.eager_load_associations) if @current_action.eager_load_associations.present?
  records = apply_scopes(records)
  @ar_object = if %w[table card].include?(params[:view_type]) || %i[table card].include?(@current_action.view_type)
                 filter_by(params, records, filter_params: @model.filter_params(params))
               elsif (request.xhr? && params[:view_type] == 'kanban') || @current_action.view_type == :kanban
                 kanban_filter_by(params, records, @model.filter_params(params))
               else
                 filter_by(params, records, filter_params: @model.filter_params(params))
               end
  respond_to do |format|
    if request.xhr? && (params[:view_type] == 'kanban' || @current_action.view_type == :kanban)
      format.json { render json: @ar_object }
    elsif request.xhr?
      format.html { render partial: '/cm_admin/main/table' }
    else
      format.html { render '/cm_admin/main/' + action_name }
    end
  end
end