Sha256: 944e971a70b65e822efc43dc82351208bb711069c04c7bc33c1b12fc095c6b1e

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

class ViewablePresenter < BasePresenter
  def edit_link(name = nil)
    return unless h.cms_edit_mode?

    h.link_to edit_path, class: "cms-edit cms-edit-#{m.dashed_name}", 'data-no-turbolink' => true do
      h.concat h.content_tag(:span, h.t('cms.edit'), class: "cms-edit-action")
      h.concat " "
      h.concat h.content_tag(:span, name, class: "cms-edit-name")
    end
  end

  def li_sortable_tag(options = nil)
    options ||= {}
    if h.cms_edit_mode?
      options['data-cms-sortable-id'] = m.unique_key.id
    end
    h.content_tag :li, options do
      yield
    end
  end

  private

  def edit_path
    h.rails_admin.edit_path(model_name: m.class.name.underscore.gsub('/', '~'), id: m.id)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_admin_cms-0.0.2 app/presenters/viewable_presenter.rb
rails_admin_cms-0.0.1 app/presenters/viewable_presenter.rb