Sha256: 2734ecdc2bf1cd51079e49e31eb8dd94d598f7f0af268572f94d433626bca617

Contents?: true

Size: 929 Bytes

Versions: 18

Compression:

Stored size: 929 Bytes

Contents

module Brightcontent
  module BaseHelper
    def render_list_field(item, field)
      ViewLookup::ListField.new(self, item: item, field: field).call
    end

    def render_filter_field(form, field, options)
      ViewLookup::FilterField.new(self, field: field, form: form, options: options).call
    end

    def render_form_field(form, field)
      ViewLookup::FormField.new(self, item: form.object, field: field, form: form).call
    end

    def render_if_exists(*args)
      render(*args)
    rescue ActionView::MissingTemplate
      nil
    end

    # Returns filter field definitions as a nested array.
    #
    #  [:foo, { bar: { as: :select }, qux: { as: :string } }]
    #
    # Becomes:
    #
    #  [[:foo], [:bar, { as: :select }], [:qux, { as: :string }]]
    #
    def normalized_filter_fields
      filter_fields.flat_map do |field|
        field.is_a?(Hash) ? field.to_a : [[field]]
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
brightcontent-core-2.6.0 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.5.1 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.5.0 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.6 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.5 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.4 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.3 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.2 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.1 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.4.0 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.3.4 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.3.3 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.3.2 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.3.1 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.3.0 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.2.2 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.2.1 app/helpers/brightcontent/base_helper.rb
brightcontent-core-2.2.0 app/helpers/brightcontent/base_helper.rb