Sha256: 182214b803767dfecdf2c8d03575501f6b8e36fdf5264b723807eab3a2742cb7

Contents?: true

Size: 1.44 KB

Versions: 4

Compression:

Stored size: 1.44 KB

Contents

def virtual?
  !real?
end

format :html do
  view :core do |args|
    if card.left && Auth.signed_in?
      render_rule_editor args
    else
      fname = "#{card.cardname.left}+#{Card[:followers].name}"
      fcard = Card.fetch fname
      nest fcard, view: :titled, items: { view: :link }
    end
  end

  view :status do |_args|
    if (rcard = current_follow_rule_card)
      rcard.item_cards.map do |item|
        %(<div class="alert alert-success" role="alert">
          <strong>#{rcard.rule_set.follow_label}</strong>: #{item.title}
         </div>)
      end.join
    else
      "No following preference"
    end
  end

  view :closed_content do |_args|
    ""
  end

  # view :editor do |args|
  #   hidden_field( :content, class: 'd0-card-content', 'no-autosave'=>true) +
  #   (args.delete(:select_list) ? raw(render_rule_editor(args)) : super(args) )
  # end

  view :rule_editor do |_args|
    preference_name = [
      card.left.default_follow_set_card.name,
      Auth.current.name,
      Card[:follow].name
    ].join("+")
    rule_context = Card.fetch preference_name, new: { type_id: PointerID }

    wrap_with :div, class: "edit-rule" do
      follow_context = current_follow_rule_card || rule_context
      subformat(follow_context).render_edit_rule(
        rule_context: rule_context,
        success: { view: "status", id: card.name }
      )
    end
  end

  def current_follow_rule_card
    card.left.rule_card :follow, user: Auth.current
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
card-1.92.2 mod/notifications/set/right/following.rb
card-1.92.1 mod/notifications/set/right/following.rb
card-1.92 mod/notifications/set/right/following.rb
card-1.91 mod/notifications/set/right/following.rb