26 lines
1.1 KiB
Ruby
26 lines
1.1 KiB
Ruby
module SuppliersHelper
|
|
def supplier_form_actions(*actions, &block)
|
|
options = actions.extract_options!
|
|
object = options[:object]
|
|
target = options[:for]
|
|
elements = []
|
|
actions.each do |action|
|
|
if action == :index
|
|
elements << link_to(content_tag(:span, nil, data: {t: 'helpers.links.index'}), [:suppliers, target], class: 'form-action-index')
|
|
elsif action == :new
|
|
elements << link_to(content_tag(:span, nil, data: {t: 'helpers.links.new'}), [:new, :suppliers, target.to_s.singularize], class: 'form-action-new')
|
|
elsif action == :edit
|
|
elements << link_to(content_tag(:span, nil, data: {t: 'helpers.links.edit'}), [:edit, :suppliers, object], class: 'form-action-edit')
|
|
elsif action == :destroy
|
|
elements << link_to(
|
|
content_tag(:span, nil, data: {t: 'helpers.links.destroy'}),
|
|
[:suppliers, object],
|
|
class: 'form-action-destroy', method: :delete, data: {confirm: are_you_sure? }
|
|
)
|
|
end
|
|
end
|
|
elements << capture(&block) if block.present?
|
|
content_tag(:div, elements.inject(&:+), class: 'form-actions').html_safe
|
|
end
|
|
end
|