<commit_before>class Admin::FormBuilder < ActionView::Helpers::FormBuilder

  def content_block_fields(options = {})
    render 'admin/content_blocks/block_list', f: self
  end

  def multi_select_field(method, *args)
    options = args.extract_options!
    options.reverse_merge!({
      class: '',
      data: {}
    })

    options[:data][:'autoload-path'] = options.delete(:path)
    options[:class] += " multi-select-input"

    text_field(method, *args, options)
  end

  def relation_field(name, *args)
    options = args.extract_options!
    options.reverse_merge!({
      class: '',
      data: {},
      label_field: 'title'
    })

    label = options.delete(:label_field)
    collection = @object.send(name)

    options[:class] += " relation-input"
    options[:data][:'label-field'] = label
    options[:data][:preload] = collection.to_json
    options[:value] = collection.collect(&:id).join(', ')
    options[:path] = polymorphic_path([:admin, name], format: :json)

    multi_select_field(name, *args, options)
  end

  def tag_field(name, *args)
    options = args.extract_options!
    options.reverse_merge!({
      class: ''
    })

    list_name = "#{name.to_s.singularize}_list".to_sym

    options[:path] = polymorphic_path([:admin, @object.class], action: 'tags', scope: name, format: :json)
    options[:class] += " tag-input #{name}-input"

    multi_select_field(list_name, *args, options)
  end

  def image_field(method, *args)
    options = args.extract_options!
    options.reverse_merge!({
      progress_template: 'admin/shared/progress_template'
    })

    content_tag :div, class: 'image-field' do
      image = @object.send(method.to_sym) || @object.send("build_#{method}")
      uploader = fields_for(method, image) do |fields|
        attachment = fields.file_field(:attachment, data: {
          url: admin_images_path(format: :json)<commit_msg>fix tag field not comma separating values in Rails 4.2 -- It's by design!<commit_after>class Admin::FormBuilder < ActionView::Helpers::FormBuilder

  def content_block_fields(options = {})
    render 'admin/content_blocks/block_list', f: self
  end

  def multi_select_field(method, *args)
    options = args.extract_options!
    options.reverse_merge!({
      class: '',
      data: {}
    })

    options[:data][:'autoload-path'] = options.delete(:path)
    options[:class] += " multi-select-input"

    text_field(method, *args, options)
  end

  def relation_field(name, *args)
    options = args.extract_options!
    options.reverse_merge!({
      class: '',
      data: {},
      label_field: 'title'
    })

    label = options.delete(:label_field)
    collection = @object.send(name)

    options[:class] += " relation-input"
    options[:data][:'label-field'] = label
    options[:data][:preload] = collection.to_json
    options[:value] = collection.collect(&:id).join(', ')
    options[:path] = polymorphic_path([:admin, name], format: :json)

    multi_select_field(name, *args, options)
  end

  def tag_field(name, *args)
    options = args.extract_options!
    options.reverse_merge!({
      class: ''
    })

    list_name = "#{name.to_s.singularize}_list".to_sym

    options[:path] = polymorphic_path([:admin, @object.class], action: 'tags', scope: name, format: :json)
    options[:class] += " tag-input #{name}-input"
    options[:value] = @object.send(list_name).to_s

    multi_select_field(list_name, *args, options)
  end

  def image_field(method, *args)
    options = args.extract_options!
    options.reverse_merge!({
      progress_template: 'admin/shared/progress_template'
    })

    content_tag :div, class: 'image-field' do
      image = @object.send(method.to_sym) || @object.send("build_#{method}")
      uploader = fields_for(method, image) do |fields|
        attachment = fields.file_field(:attachment, data: {
          url: admin_images_path(format: :json)
{'fraction_non_alphanumeric': 0.1499613501674826, 'fraction_numerical': 0.000515331100231899, 'mean_word_length': 3.7111650485436893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4491432', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1225, 'n_words': 231}