Module: Card::Set::All::Notify::BaseViews::Format

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb

Instance Method Summary collapse

Instance Method Details

#active_notice(key) ⇒ Object



82
83
84
85
86
87
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 82

def active_notice key
  @active_notice ||= inherit :active_notice
  return unless @active_notice

  @active_notice[key]
end

#edit_info_for(field, action) ⇒ Object



95
96
97
98
99
100
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 95

def edit_info_for field, action
  return nil unless (value = action.value field)

  value = action.previous_value(field) if action.action_type == :delete
  wrap_list_item "  #{notification_action_label action} #{field}: #{value}"
end

#follow_option_cardObject



76
77
78
79
80
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 76

def follow_option_card
  return unless (option_name = active_notice(:follow_option))

  Card.fetch option_name
end

#followed_set_cardObject



72
73
74
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 72

def followed_set_card
  (set_name = active_notice(:followed_set)) && Card.fetch(set_name)
end

#live_follow_rule_nameObject



89
90
91
92
93
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 89

def live_follow_rule_name
  return unless (set_card = followed_set_card) && (follower = active_notice(:follower))

  set_card.follow_rule_name follower
end

#name_before_action(action) ⇒ Object



68
69
70
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 68

def name_before_action action
  (action.value(:name) && action.previous_value(:name)) || card.name
end

#notification_act(act = nil) ⇒ Object



128
129
130
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 128

def notification_act act=nil
  @notification_act ||= act || card.acts.last
end

#notification_action(action_id) ⇒ Object



132
133
134
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 132

def notification_action action_id
  action_id ? Action.fetch(action_id) : card.last_action
end

#notification_action_label(action) ⇒ Object



102
103
104
105
106
107
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 102

def notification_action_label action
  case action.action_type
  when :update then "new"
  when :delete then "deleted"
  end
end

#relevant_fields(action) ⇒ Object



60
61
62
63
64
65
66
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 60

def relevant_fields action
  case action.action_type
  when :create then %i[cardtype content]
  when :update then %i[name cardtype content]
  when :delete then %i[content]
  end
end

#view: followedObject



36
37
38
39
40
41
42
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 36

view :followed, perms: :none, compact: true do
  if (set_card = followed_set_card) && (option_card = follow_option_card)
    option_card.description set_card
  else
    "*followed set of cards*"
  end
end

#view: followerObject



44
45
46
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 44

view :follower, perms: :none, compact: true do
  active_notice(:follower) || "follower"
end

#view: last_action_verbObject



48
49
50
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 48

view :last_action_verb, cache: :never do
  "#{notification_act&.main_action&.action_type || 'edite'}d"
end

#view: list_of_changesObject



9
10
11
12
13
14
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 9

view :list_of_changes, denial: :blank, cache: :never do
  action = notification_action voo.action_id
  relevant_fields(action).map do |type|
    edit_info_for(type, action)
  end.compact.join
end

#view: subedit_noticeObject



28
29
30
31
32
33
34
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 28

view :subedit_notice, cache: :never do
  action = notification_action voo.action_id
  wrap_subedit_item do
    %(#{name_before_action action} #{action.action_type}d\n) +
      render_list_of_changes(action_id: action.id)
  end
end

#view: subeditsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 16

view :subedits, perms: :none, cache: :never do
  return unless notification_act

  wrap_subedits do
    notification_act.actions_affecting(card).map do |action|
      next if action.card_id == card.id

      action.card.format(format: @format).render_subedit_notice action_id: action.id
    end
  end
end

#view: unfollow_urlObject



52
53
54
55
56
57
58
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 52

view :unfollow_url, perms: :none, compact: true, cache: :never do
  return "" unless (rule_name = live_follow_rule_name)

  card_url path(mark: [active_notice(:follower), :follow].cardname,
                action: :update,
                card: { subcards: { rule_name => :never.cardname } })
end

#wrap_list(list) ⇒ Object



116
117
118
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 116

def wrap_list list
  "\n#{list}\n"
end

#wrap_list_item(item) ⇒ Object



120
121
122
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 120

def wrap_list_item item
  "#{item}\n"
end

#wrap_subedit_itemObject



124
125
126
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 124

def wrap_subedit_item
  "\n#{yield}\n"
end

#wrap_subeditsObject



109
110
111
112
113
114
# File 'platypus/tmp/set/gem-defaults/mod028-follow/all/notify/base_views.rb', line 109

def wrap_subedits
  subedits = yield.compact.join
  return "" if subedits.blank?

  "\nThis update included the following changes:\n#{wrap_list subedits}"
end