Sha256: 95ad9038123f494afc7106fc8b1e30ac5ccc9467a7aef45a9b93bcbdb6270de3

Contents?: true

Size: 969 Bytes

Versions: 3

Compression:

Stored size: 969 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 :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

3 entries across 3 versions & 1 rubygems

Version Path
typus-3.1.0.rc9 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc8 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb
typus-3.1.0.rc7 app/helpers/admin/resources/data_types/has_and_belongs_to_many_helper.rb