Sha256: fe8dc34f68a4fe3f5169c0f09923c08e291605d4956376c0f5a799b0d83745d2

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

format :html do
  view :menu, denial: :blank, tags: :unknown_ok do
    return "" if card.unknown?
    wrap_with :div, class: "card-menu #{menu_link_classes}" do
      menu
    end
  end

  def menu
    case voo.edit
    when :content_inline
      edit_in_place_link
    when :content_modal
      edit_in_modal_link
    else
      standard_edit_link
    end
  end

  view :edit_link, tags: :unknown_ok, denial: :blank do
    edit_link
  end

  view :full_page_link do
    full_page_link
  end

  def full_page_link
    link_to_card card, full_page_icon, class: classy("full-page-link")
  end

  def edit_link view=:edit, opts={}
    link_to_view view, menu_icon, edit_link_opts(opts)
  end

  # @param modal [Symbol] modal size
  def edit_link_opts modal: nil
    opts = { class: "text-muted" }
    if modal
      opts.merge! "data-slotter-mode": "modal", "data-modal-class": "modal-#{modal}"
    end
    opts
  end

  def wrap_menu
    wrap_with :div, class: classy(%w[menu-slot nodblclick]) do
      yield
    end
   end

  def standard_edit_link
    edit_link :edit, modal: :full
  end

  def edit_in_modal_link
    edit_link :edit, modal: :large
  end

  def edit_in_place_link
    edit_link :edit_in_place
  end

  def menu_link_classes
    if show_view? :hover_link
      "_show-on-hover"
    else
      ""
    end
  end

  def menu_icon
    material_icon "edit"
  end

  def full_page_icon
    icon_tag :open_in_new
  end

  def show_menu_item_edit?
    return unless card.real?

    card.ok?(:update) || structure_editable?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.97.0 mod/standard/set/all/rich_html/menu.rb