Class: RecordsController

Inherits:
ApplicationController show all
Includes:
ApplicationHelper
Defined in:
app/controllers/records_controller.rb

Constant Summary collapse

EXPLOSE_ALL_TABLES =
true

Instance Method Summary collapse

Methods included from AuthentificationHelper

#accessible_company_ids_from_tenant_and_user, #application_mode_from_hostname, #current_company_id_from_accessible_company_ids, #current_tenant_from_user, #current_user_and_locale_from_token

Instance Method Details

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/records_controller.rb', line 9

def index
  render json: { message: :unauthorized }, status: :unauthorized

  # table_name = params[:record_name]
  # unless (exposed_table = exposed_tables.dig(table_name)) || EXPLOSE_ALL_TABLES
  #   return render(
  #     json: { message: :unauthorized },
  #     status: :unauthorized
  #   )
  # end

  # model_class = if Object.const_defined?(table_name.classify)
  #                 table_name.classify.constantize
  #               else
  #                 Class.new(ActiveRecord::Base) do
  #                   self.inheritance_column = :_type_disabled
  #                   self.table_name = table_name
  #                 end
  #               end

  # exposed_columns = EXPLOSE_ALL_TABLES ? ActiveRecord::Base.connection.columns(table_name).map(&:name) : exposed_table[:columns]
  # fields = records_params[:fields] || {}
  # fieldsValues = fields.values.presence || exposed_columns
  # @records = model_class.select(fieldsValues)

  # if (filters = records_params[:filters]).present?
  #   @records = @records.where(filters)
  # end

  # if ((order_by = records_params[:order_by]) && (order = records_params[:order])).present?
  #   @records = @records.order("#{order_by} #{order}")
  # end

  # if (query = records_params[:query]).present?
  #   conditions = fieldsValues.map { |field| "#{field} LIKE :query" }.join(' OR ')
  #   @records = @records.where(conditions, query: "%#{query}%")
  # end

  # @total = @records.count('*')

  # @records = @records.offset(@offset) if (@offset = records_params[:offset].to_i).present? && @offset != 0

  # @records = @records.limit(@limit) if (@limit = records_params[:limit].to_i).present? && @limit != 0

  # columns = ActiveRecord::Base.connection.columns(model_class.table_name)
  # columns = columns.select { |column| fieldsValues.include?(column.name) }
  # @headers = columns.map do |column|
  #   column_name = column.name
  #   %i[integer float decimal].include?(column.type)
  #   {
  #     field: column_name,
  #     type: column.type,
  #     label: column_name.humanize
  #   }
  # end
end