Sha256: 76cfc302336a2ebd72ba2d479f9fdfeb6c820e8882e440c6ab5d8f96b15dc33a

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 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'
  title               ||= assoc_name.titleize             # 'Restaurant Bars'
  add_button_text     ||= t('fae.common.add', title: title.singularize)
  hide_add_button     ||= false
  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, add_button_text: add_button_text, hide_add_button: hide_add_button, 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
    - unless hide_add_button
      a.js-add-link.table-add-link.button.-small href=new_path = add_button_text
    h2 = 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

1 entries across 1 versions & 1 rubygems

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