2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2010-06-10 13:30:32 +00:00
|
|
|
class CustomFieldsController < BaseController
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-10 13:30:32 +00:00
|
|
|
layout false
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-22 13:04:40 +00:00
|
|
|
before_filter :set_parent_and_fields
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-06-26 23:02:48 +00:00
|
|
|
skip_load_and_authorize_resource
|
|
|
|
|
2010-06-10 13:30:32 +00:00
|
|
|
def edit
|
2010-06-22 13:04:40 +00:00
|
|
|
@field = @fields.find(params[:id])
|
2010-06-10 13:30:32 +00:00
|
|
|
render :action => "edit_#{@field.kind.downcase}"
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-10 13:30:32 +00:00
|
|
|
def update
|
2010-06-22 13:04:40 +00:00
|
|
|
@field = @fields.find(params[:id])
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-10 13:30:32 +00:00
|
|
|
if @field.update_attributes(params[:custom_field])
|
2011-03-17 16:41:25 +00:00
|
|
|
render :json => @field.to_json
|
2010-06-10 13:30:32 +00:00
|
|
|
else
|
2011-10-30 23:02:41 +00:00
|
|
|
render :json => { :error => t('flash.locomotive.custom_fields.update.alert') }
|
2010-06-10 13:30:32 +00:00
|
|
|
end
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-10 13:30:32 +00:00
|
|
|
protected
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-22 13:04:40 +00:00
|
|
|
def set_parent_and_fields
|
2011-06-21 13:12:20 +00:00
|
|
|
@parent = current_site.content_types.where(:slug => params[:slug]).first
|
2011-12-05 14:29:32 +00:00
|
|
|
@fields = @parent.contents_custom_fields
|
2010-06-10 13:30:32 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-06-10 13:30:32 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|