fix an issue when pulling the options of a select field (content type)

did committed Jan 11, 2016
commit 0191918f72c347187fb8984d35849e7d7b2a8e05
Showing 1 changed file with 13 additions and 0 deletions
locomotive/wagon/commands/pull_sub_commands/pull_content_types_command.rb b/lib/locomotive/wagon/commands/pull_sub_commands/pull_content_types_command.rb +13 -0
@@ @@ -30,9 +30,22 @@ module Locomotive::Wagon
clean_attributes(attributes)
+ # select_options
+ attributes['select_options'] = select_options_yaml(attributes['select_options']) if field['type'] == 'select'
+
{ field['name'] => attributes }
end
+ def select_options_yaml(options)
+ if locales.size > 1
+ locales.inject do |_options, locale|
+ _options[locale] = attributes.map { |option| options['name'][locale.to_s] }
+ end
+ else
+ options.map { |option| option['name'][default_locale] }
+ end
+ end
+
def content_type_filepath(content_type)
File.join('app', 'content_types', "#{content_type.slug}.yml")
end