parent
78cd9bd675
commit
642e9c16c6
@ -0,0 +1,27 @@ |
||||
module Api |
||||
module V2 |
||||
class CustomFieldsController < ApplicationController |
||||
|
||||
include ::Api::V2::ApiController |
||||
|
||||
def index |
||||
@custom_fields = CustomField.find :all, |
||||
:offset => params[:offset], |
||||
:limit => params[:limit] |
||||
|
||||
respond_to do |format| |
||||
format.api |
||||
end |
||||
end |
||||
|
||||
def show |
||||
@custom_field = CustomField.find params[:id] |
||||
|
||||
respond_to do |format| |
||||
format.api |
||||
end |
||||
end |
||||
|
||||
end |
||||
end |
||||
end |
@ -0,0 +1,26 @@ |
||||
api.custom_field do |
||||
api.id custom_field.id |
||||
api.name custom_field.name |
||||
api.customized_type custom_field.type.gsub(/CustomField$/, '').underscore |
||||
api.field_format custom_field.field_format |
||||
api.regexp custom_field.regexp |
||||
api.min_length custom_field.min_length |
||||
api.max_length custom_field.max_length |
||||
api.is_required custom_field.is_required |
||||
api.is_filter custom_field.is_filter |
||||
api.searchable custom_field.searchable |
||||
api.is_for_all custom_field.is_for_all |
||||
api.position custom_field.position |
||||
api.editable custom_field.editable |
||||
api.visible custom_field.visible |
||||
|
||||
if custom_field.field_format == 'list' && !custom_field.possible_values.empty? |
||||
api.array :possible_values, api_meta(:size => custom_field.possible_values.size) do |
||||
custom_field.possible_values.each do |possible_value| |
||||
api.possible_value do |
||||
api.value possible_value |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,5 @@ |
||||
api.custom_field do |
||||
api.name custom_field_value.custom_field.name |
||||
api.value custom_field_value.value |
||||
api.id custom_field_value.custom_field.id |
||||
end |
@ -0,0 +1,6 @@ |
||||
api.array :custom_fields, api_meta(:size => custom_field_values.size) do |
||||
custom_field_values.each do |custom_field_value| |
||||
render :partial => '/api/v2/custom_fields/custom_field_value.api', |
||||
:locals => {:custom_field_value => custom_field_value} |
||||
end |
||||
end |
@ -0,0 +1,5 @@ |
||||
api.array :custom_fields, api_meta(:size => @custom_fields.size) do |
||||
@custom_fields.each do |custom_field| |
||||
render :partial => '/api/v2/custom_fields/custom_field.api', :object => custom_field |
||||
end |
||||
end |
@ -0,0 +1 @@ |
||||
render :partial => '/api/v2/custom_fields/custom_field.api', :object => @custom_field |
Loading…
Reference in new issue