Class: Kaui::CustomFieldsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/custom_fields_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_ability, #current_user, #options_for_klient

Instance Method Details

#indexObject



3
4
# File 'app/controllers/kaui/custom_fields_controller.rb', line 3

def index
end

#paginationObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/kaui/custom_fields_controller.rb', line 6

def pagination
  search_key = params[:sSearch]
  offset     = params[:iDisplayStart] || 0
  limit      = params[:iDisplayLength] || 10

  custom_fields = Kaui::CustomField.list_or_search(search_key, offset, limit, options_for_klient)

  json = {
      :sEcho                => params[:sEcho],
      :iTotalRecords        => custom_fields.pagination_max_nb_records,
      :iTotalDisplayRecords => custom_fields.pagination_total_nb_records,
      :aaData               => []
  }

  custom_fields.each do |custom_field|
    json[:aaData] << [
        custom_field.name,
        custom_field.value
    ]
  end

  respond_to do |format|
    format.json { render :json => json }
  end
end