Sha256: ccd442bb3301c2eb0f4b80b25bb26feded3ea016b6efd1cf9842edd9a6335f4e

Contents?: true

Size: 948 Bytes

Versions: 13

Compression:

Stored size: 948 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 content_tag(:td, '') 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

13 entries across 13 versions & 1 rubygems

Version Path
voluntary-0.7.1 app/presenters/shared/collection/table_presenter.rb
voluntary-0.7.0 app/presenters/shared/collection/table_presenter.rb
voluntary-0.6.0 app/presenters/shared/collection/table_presenter.rb
voluntary-0.5.2 app/presenters/shared/collection/table_presenter.rb
voluntary-0.5.1 app/presenters/shared/collection/table_presenter.rb
voluntary-0.5.0 app/presenters/shared/collection/table_presenter.rb
voluntary-0.4.0 app/presenters/shared/collection/table_presenter.rb
voluntary-0.3.0 app/presenters/shared/collection/table_presenter.rb
voluntary-0.2.4 app/presenters/shared/collection/table_presenter.rb
voluntary-0.2.3 app/presenters/shared/collection/table_presenter.rb
voluntary-0.2.2 app/presenters/shared/collection/table_presenter.rb
voluntary-0.2.1 app/presenters/shared/collection/table_presenter.rb
voluntary-0.2.0 app/presenters/shared/collection/table_presenter.rb