Sha256: 3128d62112bd73d49a15acb89f95d92df0993591bf0375e551f0a1a15aa20ae5

Contents?: true

Size: 977 Bytes

Versions: 9

Compression:

Stored size: 977 Bytes

Contents

module Admin::Resources::DataTypes::HasAndBelongsToManyHelper

  def table_has_and_belongs_to_many_field(attribute, item)
    item.send(attribute).map { |i| i.to_label }.join(", ")
  end

  alias_method :table_has_many_field, :table_has_and_belongs_to_many_field

  def typus_form_has_and_belongs_to_many(field)
    setup_relationship(field)
    build_pagination

    # TODO: Find a cleaner way to add these actions ...
    @resource_actions = [["Edit", { :action => "edit", :layout => 'admin/headless' }, { :class => 'iframe' }],
                         ["Unrelate", { :resource_id => @item.id,
                                        :resource => @resource.model_name,
                                        :action => "unrelate"},
                                      { :confirm =>"Unrelate?" }]]

    locals = { :association_name => @association_name, :add_new => build_add_new, :table => build_relationship_table }
    render "admin/templates/has_n", locals
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
typus-3.1.0.rc18 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc17 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc16 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc15 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc14 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc13 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc12 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc11 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc10 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb