the API for content_types now allows to change the label_field property of a content type
This commit is contained in:
parent
c5ddabd585
commit
61281db943
@ -5,6 +5,10 @@ module Locomotive
|
||||
include Locomotive::Routing::SiteDispatcher
|
||||
include Locomotive::ActionController::LocaleHelpers
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
|
||||
skip_load_and_authorize_resource
|
||||
|
||||
before_filter :require_account
|
||||
|
||||
before_filter :require_site
|
||||
@ -13,10 +17,6 @@ module Locomotive
|
||||
|
||||
# before_filter :validate_site_membership
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
|
||||
skip_load_and_authorize_resource
|
||||
|
||||
self.responder = Locomotive::ActionController::Responder # custom responder
|
||||
|
||||
respond_to :json, :xml
|
||||
|
@ -78,6 +78,12 @@ module Locomotive
|
||||
self.class.class_name_to_content_type(class_name, self.site)
|
||||
end
|
||||
|
||||
def label_field_name=(value)
|
||||
# mandatory if we allow the API to set the label field name without an id of the field
|
||||
@new_label_field_name = value unless value.blank?
|
||||
super(value)
|
||||
end
|
||||
|
||||
# Retrieve from a class name the associated content type within the scope of a site.
|
||||
# If no content type is found, the method returns nil
|
||||
#
|
||||
@ -111,7 +117,15 @@ module Locomotive
|
||||
|
||||
def set_default_values
|
||||
self.order_by ||= 'created_at'
|
||||
self.label_field_id = self.entries_custom_fields.first._id if self.label_field_id.blank?
|
||||
|
||||
if @new_label_field_name.present?
|
||||
self.label_field_id = self.entries_custom_fields.detect { |f| f.name == @new_label_field_name.underscore }._id
|
||||
end
|
||||
|
||||
if self.label_field_id.blank?
|
||||
self.label_field_id = self.entries_custom_fields.first._id
|
||||
end
|
||||
|
||||
field = self.entries_custom_fields.find(self.label_field_id)
|
||||
|
||||
# the label field should always be required
|
||||
|
@ -17,10 +17,6 @@ module Locomotive
|
||||
|
||||
output = @page.render(locomotive_context)
|
||||
|
||||
# puts "======================"
|
||||
# puts output.inspect
|
||||
# puts "======================"
|
||||
|
||||
self.prepare_and_set_response(output)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user