Sha256: 601cba8ee62b905f57a7a7c8f16854335a13d3884cea7fffb55dbe95f1a49761

Contents?: true

Size: 1.6 KB

Versions: 12

Compression:

Stored size: 1.6 KB

Contents

#! no set module
class FollowLink
  attr_reader :format, :rule_content, :link_text, :action, :css_class, :hover_text

  delegate :link_to, to: :format

  def initialize format
    @format = format
    @card = format.card
  end

  def modal_link icon=false
    opts = link_opts.merge(
      "data-path": link_opts[:path],
      "data-bs-toggle": "modal",
      "data-bs-target": "#modal-#{card.name.safe_key}",
      class: css_classes("follow-link", link_opts[:class])
    )
    link_to render_link_text(icon), opts
  end

  def button
    opts = link_opts(:follow_section).merge(
      remote: true,
      class: @format.css_classes("follow-link", link_opts[:class],
                                 "slotter btn btn-sm btn-primary")
    )
    opts["data-update-foreign-slot"] =
      ".d0-card-body > .card-slot.RIGHT-Xfollower.content-view"
    opts["data-hover-text"] = hover_text if hover_text
    link_to render_link_text, opts
  end

  def link_opts success_view=:follow_status
    { title: title,
      path: path(success_view),
      class: css_class }
  end

  def render_link_text icon=false
    verb = %(<span class="follow-verb">#{link_text}</span>)
    icon = icon ? icon_tag(:flag) : ""
    [icon, verb].compact.join.html_safe
  end

  private

  def mark
    @card.follow_set_card.follow_rule_name Auth.current.name
  end

  def path view=:follow_status
    @format.path mark: mark,
                 action: :update,
                 success: { mark: @card.name, view: view },
                 card: { content: "[[#{rule_content}]]" }
  end

  def title
    "#{action} emails about changes to #{@card.follow_label}"
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-mod-follow-0.18.1 set/all/follow/follow_link.rb
card-mod-follow-0.18.0 set/all/follow/follow_link.rb
card-mod-follow-0.17.0 set/all/follow/follow_link.rb
card-mod-follow-0.16.0 set/all/follow/follow_link.rb
card-mod-follow-0.15.6 set/all/follow/follow_link.rb
card-mod-follow-0.15.5 set/all/follow/follow_link.rb
card-mod-follow-0.15.4 set/all/follow/follow_link.rb
card-mod-follow-0.15.3 set/all/follow/follow_link.rb
card-mod-follow-0.15.2.pre1 set/all/follow/follow_link.rb
card-mod-follow-0.15.1.1 set/all/follow/follow_link.rb
card-mod-follow-0.15.1 set/all/follow/follow_link.rb
card-mod-follow-0.15.0 set/all/follow/follow_link.rb