Sha256: 22aec65a05047b166b81fb12108b032c6c2dc0d98db7a6e0a5d59d6902f722bd

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

module Elabs
  module AdminContentHelper
    def admin_action_links(singular_model, entity)
      out = []
      out.push(admin_show_online_link(entity))
      out.push(admin_lock_link(singular_model, entity))
      out.push(admin_destroy_link(singular_model, entity))

      raw out.join('')
    end

    def admin_show_link(singular_model, entity)
      link_to send("admin_#{singular_model}_path".to_sym, entity),
              title:  _('Show'),
              class:  'btn btn--small btn--show' do
        icon('eye', ['fw'])
      end
    end

    def admin_show_online_link(entity)
      link_to entity,
              title: _('View online'),
              class: 'btn btn--small btn--show' do
        icon('globe', ['fw'])
      end
    end

    def admin_lock_link(singular_model, entity)
      link_to send("admin_#{singular_model}_toggle_lock_path", entity),
              title:  (entity.locked? ? _('Unlock') : _('Lock')),
              class:  'btn btn--small btn--lock',
              method: :put do
        icon(entity.locked? ? 'unlock' : 'lock', ['fw'])
      end
    end

    def admin_destroy_link(singular_model, entity)
      link_to send("admin_#{singular_model}_path".to_sym, entity),
              title:  _('Destroy'),
              class:  'btn btn--small btn--destroy',
              method: :delete, data: { confirm: _('Are you sure?') } do
        icon('trash', ['fw'])
      end
    end

    def admin_edit_link(singular_model, entity)
      link_to send("edit_admin_#{singular_model}_path".to_sym, entity),
              title: _('Edit'),
              class: 'btn btn--small btn--edit' do
        icon('pencil-alt', ['fw'])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elabs-2.0.0 app/helpers/elabs/admin_content_helper.rb
elabs-2.0.0.pre app/helpers/elabs/admin_content_helper.rb