Module: Card::Set::Right::Following::HtmlFormat

Extended by:
AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb

Instance Method Summary collapse

Instance Method Details

#current_follow_rule_cardObject



56
57
58
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 56

def current_follow_rule_card
  card.left.preference :follow
end

#edit_rule_successObject



52
53
54
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 52

def edit_rule_success
  { view: "status", id: card.name.url_key }
end

#preference_nameObject



47
48
49
50
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 47

def preference_name
  set_name = card.left.follow_set_card.name
  Card::Name[set_name, Auth.current.name, :follow]
end

#view: coreObject



15
16
17
18
19
20
21
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 15

view :core do
  if card.left && Auth.signed_in?
    render_rule_editor
  else
    nest Card.fetch(card.name.left, :followers), view: :titled, items: { view: :link }
  end
end

#view: one_line_contentObject



35
36
37
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 35

view :one_line_content do
  ""
end

#view: rule_editorObject



39
40
41
42
43
44
45
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 39

view :rule_editor, cache: :never do
  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).rule_form :open, rule_context, :modal
  end
end

#view: statusObject



23
24
25
26
27
28
29
30
31
32
33
# File 'platypus/tmp/set/gem-defaults/mod028-follow/right/following.rb', line 23

view :status do
  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