Class: Kaui::AccountCustomFieldsController

Inherits:
EngineController
  • Object
show all
Defined in:
app/controllers/kaui/account_custom_fields_controller.rb

Constant Summary

Constants included from EngineControllerUtil

EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/kaui/account_custom_fields_controller.rb', line 3

def index
  cached_options_for_klient = options_for_klient
   = Kaui::Account::find_by_id_or_key(params.require(:account_id), true, true, cached_options_for_klient)
  custom_fields = .all_custom_fields(nil, 'NONE', cached_options_for_klient)


  formatter = lambda do |custom_field|
    url_for_object = view_context.url_for_object(custom_field.object_id, custom_field.object_type)
    [
        url_for_object ? view_context.link_to(custom_field.object_id, url_for_object) : custom_field.object_id,
        custom_field.object_type,
        custom_field.name,
        custom_field.value
    ]
  end
  @custom_fields_json = []
  custom_fields.each { |page| @custom_fields_json << formatter.call(page) }

  @custom_fields_json = @custom_fields_json.to_json
end