Sha256: 2608fb38eb1f854157cd465e3f8c5d4591d009b98395bdeb039239c3bd3f854c

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

ruby:
  index ||= false

  if index
    require_locals(['assoc'], local_assigns)
  else
    require_locals(['assoc', 'parent_item'], local_assigns)
  end

  # optional locals
  assoc_name          ||= assoc.to_s                      # 'restaurant_bars'
  # @depreciation - remove header option in v2.0
  header              ||= assoc_name.titleize             # 'Restaurant Bars'
  title               ||= header
  add_button_text     ||= "Add #{title.singularize}"
  ordered             ||= false
  has_thumb           ||= false
  edit_column         ||= false
  cols                ||= []
  helper_text         ||= ''

  # lesser known optional locals, dervived from options by default
  assoc_name_singular ||= assoc_name.singularize          # 'restaurant_bar'
  new_path            ||= "new_#{fae_path}_#{assoc_name_singular}_path"
  edit_path           ||= "edit_#{fae_path}_#{assoc_name_singular}_path"

  begin
    if index
      new_path = self.send(new_path)
    else
      new_path = self.send(new_path, item_id: parent_item.id, item_class: parent_item.class.to_s)
    end
  rescue
    new_path += new_path['?'] ? '&' : '?'
    new_path += "item_id=#{parent_item.id}&=item_class=#{parent_item.class.to_s}"
  end

  options_for_table = { index: index, assoc: assoc, assoc_name: assoc_name, title: title, header: header, add_button_text: add_button_text, ordered: ordered, has_thumb: has_thumb, edit_column: edit_column, cols: cols, assoc_name_singular: assoc_name_singular, new_path: new_path, edit_path: edit_path }
  options_for_table[:parent_item] = parent_item unless index

section.addedit-form.js-addedit-form class="#{'content' if index}"
  - if index
    == render 'fae/shared/shared_nested_table', options_for_table

  - else
    a.js-add-link.table-add-link.button.-small href=new_path = add_button_text
    h3 = title
    - if helper_text.present?
      h6.table-helper-text = helper_text
    == render 'fae/application/flash_messages'
    == render 'fae/shared/shared_nested_table', options_for_table

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fae-rails-1.5.1 app/views/fae/shared/_nested_table.html.slim
fae-rails-1.5.0 app/views/fae/shared/_nested_table.html.slim