Sha256: f905b001a428315b360a2152cd333682b57b7be4e8131dce650c20d90050c2b8

Contents?: true

Size: 930 Bytes

Versions: 4

Compression:

Stored size: 930 Bytes

Contents

class Shared::Collection::TablePresenter < Presenter
  def initialize(subject, options = {})
    super(subject, options)
    
    set_default_options(
      {  
        current_parent: parent, show_title: true, append_new_link: true, show_actions: true
      }
    )
  end
  
  def set_options(options)
    @options.merge!(options)
  end
  
  def actions
    return '' unless show_actions
    
    content_tag :td, render('shared/resource/actions', type: type, resource: resource)
  end
  
  def new_link(options = {})
    return '' unless append_new_link

    path = if current_parent
      send(
        "new_#{root_model_class_name(current_parent).tableize.singularize}_#{type.gsub('.', '_').singularize}_path", 
        current_parent, options
      )
    else
      send("new_#{type.gsub('.', '_').singularize}_path", options)
    end
    
    link_to t("#{type}.new.title"), path
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voluntary-0.1.0 app/presenters/shared/collection/table_presenter.rb
voluntary-0.1.0.rc4 app/presenters/shared/collection/table_presenter.rb
voluntary-0.1.0.rc3 app/presenters/shared/collection/table_presenter.rb
voluntary-0.1.0.rc2 app/presenters/shared/collection/table_presenter.rb