Sha256: fefaf24dd38379ee0e09719ac81487d331c8949e6e12bed929af351c1547e69b

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true
module EacRailsBase0
  module LinksHelper
    def short_delete_link(object)
      value_or_sign(object, '') do |value|
        link_to '', object_path(value),
                class: 'delete_link', method: :delete, target: '_blank',
                title: ::I18n.t('eac_rails_base0.links.delete_object', label: value.to_s),
                data: {
                  confirm: ::I18n.t('eac_rails_base0.links.delete_confirm', label: value.to_s)
                }
      end
    end

    def short_edit_link(object)
      value_or_sign(object, '') do |value|
        link_to '', object_path(value, 'edit'),
                class: 'edit_link', target: '_blank',
                title: ::I18n.t('eac_rails_base0.links.edit_object', label: value.to_s)
      end
    end

    def short_goto_link(url)
      value_or_sign(url, '') do |value|
        link_to '', value, class: 'goto_link', target: '_blank',
                           title: ::I18n.t('eac_rails_base0.links.goto_url', url: value.to_s)
      end
    end

    def object_path(object, action = nil)
      path = "#{object.class.name.underscore.tr('/', '_')}_url"
      path = "#{action}_#{path}" if action.present?
      send(path, object)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eac_rails_base0-0.17.0 app/helpers/eac_rails_base0/links_helper.rb
eac_rails_base0-0.16.0 app/helpers/eac_rails_base0/links_helper.rb