Class: Lolita::FieldDataController

Inherits:
ApplicationController
  • Object
show all
Includes:
Controllers::AuthenticationHelpers
Defined in:
app/controllers/lolita/field_data_controller.rb

Instance Method Summary collapse

Methods included from Controllers::AuthenticationHelpers

#authenticate_lolita_user!

Instance Method Details

#array_polymorphicObject



6
7
8
9
10
11
12
13
# File 'app/controllers/lolita/field_data_controller.rb', line 6

def array_polymorphic
  klass = params[:class].camelize.constantize
  authorization_proxy.authorize!(:read,klass)
  data_collection = @field.polymorphic_association_values(:klass => klass)
  @id = params[:id].to_s.to_i
  @collection = [[]]+data_collection
  render_component(*@field.build(:state => :options_for_select, :collection => @collection, :id => @id))
end

#autocomplete_fieldObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/lolita/field_data_controller.rb', line 15

def autocomplete_field
   klass = params[:field_class].camelize.constantize
   authorization_proxy.authorize!(:read,klass)
   field = klass.lolita.tabs.fields.detect{|field| field.name.to_s == params[:field_name]}
   data = if field
     (field.search || field.create_search(true)).run(params[:term],request).map do |record|
       {
         :id => record.id,
         :value => record.send(field.current_text_method(field.association.klass)),
         :name => "#{params[:field_class].underscore}[#{params[:field_name].singularize}_ids][]",
         :delete_link => I18n.t("lolita.shared.delete").to_s.downcase
       }
     end
   end
   render :json => data || {}
end

#is_lolita_resource?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/controllers/lolita/field_data_controller.rb', line 32

def is_lolita_resource?
  true
end