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

Extended by:
AbstractFormat
Defined in:
card/tmpsets/set/mod025-card-mod-follow/right/following.rb,
card/tmpsets/set/mod026-card-mod-follow/right/following.rb

Instance Method Summary collapse

Instance Method Details

#current_follow_rule_cardObject



54
55
56
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 54

def current_follow_rule_card
  card.left.preference :follow
end

#edit_rule_successObject



50
51
52
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 50

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

#preference_nameObject



45
46
47
48
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 45

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

#view: coreObject



13
14
15
16
17
18
19
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 13

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



33
34
35
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 33

view :one_line_content do
  ""
end

#view: rule_editorObject



37
38
39
40
41
42
43
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 37

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



21
22
23
24
25
26
27
28
29
30
31
# File 'card/tmpsets/set/mod025-card-mod-follow/right/following.rb', line 21

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