Sha256: d80a1f24ccba64b6c71d9fa922b458d1a8e7688fb12348e668d037cc694e3f6a

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

Contents

class AssetManagerInput
  include Formtastic::Inputs::Base

  def to_html
    no_items_label = I18n.t('not_available', scope: [object.class.i18n_scope, object.class.name.demodulize.tableize, :show], default: 'N/A')

    input_wrapping do
      result = label_html
      result << template.content_tag(:div, class: 'asset_manager_container') do
        template.controller.view_context.am_select_link(object, method) <<
        template.content_tag(:div, id: "dinamyc_assets_#{method}", no_items_label: no_items_label) do
          cr = object.send(method)
          unless cr.blank?
            if cr.kind_of?(Array)
              template.controller.view_context.render(partial: '/admin/asset_manager/assets/assets', locals: { collection: cr })
            else
              template.controller.view_context.render(partial: '/admin/asset_manager/assets/asset', locals: { resource: cr })
            end
          else
            no_items_label
          end
        end
      end
      result
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
intesys_asset_manager-1.0.0 app/inputs/asset_manager_input.rb