Module: MailyHeraldHelper

Defined in:
app/helpers/maily_herald_helper.rb

Instance Method Summary collapse

Instance Method Details



120
121
122
123
124
125
# File 'app/helpers/maily_herald_helper.rb', line 120

def context_attributes_link options = {}
  link_to context_attributes_webui_mailings_path(:context_name => options[:context]), :role => "button", :data => {:toggle => "modal", :target => "#context-attributes"}, :class => "show-context-attributes" do
      concat((:i, "", :class => "glyphicon glyphicon-th-list"))
      concat(" show") unless options[:notext]
  end
end

#delivery_log_list_actions(delivery_log) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'app/helpers/maily_herald_helper.rb', line 81

def delivery_log_list_actions delivery_log
  mailing = delivery_log.mailing
  entity = delivery_log.entity

  actions = []
  actions.push({
    :name => :custom,
    :url => webui_dashboard_path(delivery_log),
    :icon => "icon-search",
    :title => "Show log details"
  })
  actions.push({
    :name => :custom,
    :url => mailing.sequence? ? subscription_webui_sequence_path(:id => mailing.sequence, :entity_id => entity) : subscription_webui_mailing_path(:id => mailing, :entity_id => entity),
    :icon => "icon-hand-right",
    :title => "Subscription"
  }) unless @subscription
  actions
end

#mailing_entity_list_actions(mailing, entity) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/maily_herald_helper.rb', line 45

def mailing_entity_list_actions mailing, entity
  actions = []
  actions.push({
    :name => :custom,
    :url => preview_webui_mailing_path(:subscription_id => mailing.subscription_for(entity)),
    :icon => "glyphicon glyphicon-search",
    :title => "Preview template below",
    :remote => true
  })
  actions.push({
    :name => :custom,
    :url => mailing.sequence? ? subscription_webui_sequence_path(:id => mailing.sequence, :entity_id => entity) : subscription_webui_mailing_path(:entity_id => entity),
    :icon => "glyphicon glyphicon-hand-right",
    :title => "Show"
  })
  actions
end

#maily_herald_context_attributes_list(name) ⇒ Object



137
138
139
# File 'app/helpers/maily_herald_helper.rb', line 137

def maily_herald_context_attributes_list name
  MailyHerald.context(name).each
end

#maily_herald_context_options_for_select(selected = nil, options = {}) ⇒ Object



127
128
129
# File 'app/helpers/maily_herald_helper.rb', line 127

def maily_herald_context_options_for_select selected = nil, options = {}
  MailyHerald.contexts.keys.collect {|c| [c, c] }
end

#maily_herald_mailer_options_for_select(selected = nil, options = {}) ⇒ Object



131
132
133
134
135
# File 'app/helpers/maily_herald_helper.rb', line 131

def maily_herald_mailer_options_for_select selected = nil, options = {}
  [
    ['generic', 'generic']
  ]
end

#maily_herald_subscription_group_options_for_select(selected = nil, options = {}) ⇒ Object



148
149
150
# File 'app/helpers/maily_herald_helper.rb', line 148

def maily_herald_subscription_group_options_for_select selected = nil, options = {}
  [["none", ""]] + MailyHerald::SubscriptionGroup.all.collect {|sg| [sg.title, sg.name] }
end

#maily_herald_token_action_options_for_select(selected = nil, options = {}) ⇒ Object



141
142
143
144
145
146
# File 'app/helpers/maily_herald_helper.rb', line 141

def maily_herald_token_action_options_for_select selected = nil, options = {}
  [
    ['Unsubscribe', 'unsubscribe'],
    ['Custom', 'custom'],
  ]
end

#sequence_entity_list_actions(entity) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'app/helpers/maily_herald_helper.rb', line 35

def sequence_entity_list_actions entity
  [
    {
      :name => :custom,
      :url => subscription_webui_sequence_path(:entity_id      => entity),
      :icon => "glyphicon glyphicon-hand-right",
      :title => "Show"
    }
  ]
end

#sequence_mailing_list_actions(mailing) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/maily_herald_helper.rb', line 2

def sequence_mailing_list_actions mailing
  actions = [
   {
      :name => :custom,
      :url => webui_mailing_path(mailing),
      :icon => "glyphicon glyphicon-hand-right",
      :title => "Show"
    },
    {
      :name => :custom,
      :url => edit_webui_mailing_path(mailing),
      :icon => "glyphicon glyphicon-pencil",
      :title => "Edit"
    },
    { 
   :name => :custom,
      :url => webui_mailing_path(mailing),
      :method => :delete,
      :confirm => "Are you sure you want to remove this mailing?",
      :icon => "glyphicon glyphicon-trash",
      :title => "Remove"
    }
 ]
  actions.insert(0, {
    :name => :custom,
   :url => "#mailing-#{mailing.id}",
    :class => "show-preview",
   :icon => "glyphicon glyphicon-search",
    :title => "Preview"
  }) if @sequence && @subscription
  actions
end

#subscription_group_subscription_actions(subscription) ⇒ Object



101
102
103
104
105
106
107
108
109
110
# File 'app/helpers/maily_herald_helper.rb', line 101

def subscription_group_subscription_actions subscription
  [{
    :name => :custom,
    :url => toggle_subscription_webui_subscription_group_path(:subscription_id => subscription),
    :method => :get,
    :confirm => "Are you sure you want to change this subscription?",
    :icon => "icon-refresh",
    :title => "Toggle subscription"
  }]
end

#time_tag(time) ⇒ Object



63
64
65
66
67
# File 'app/helpers/maily_herald_helper.rb', line 63

def time_tag(time)
  return unless time
  text = distance_of_time_in_words(Time.now, time)
  ('abbr', text, :title => format_time(time))
end

#time_tag_ago(time) ⇒ Object



69
70
71
72
73
# File 'app/helpers/maily_herald_helper.rb', line 69

def time_tag_ago(time)
return unless time
text = distance_of_time_in_words(Time.now, time)
 ('abbr', t('time_distance.ago', :text => text), :title => time)
end

#time_tag_relative(time) ⇒ Object



112
113
114
115
116
117
118
# File 'app/helpers/maily_herald_helper.rb', line 112

def time_tag_relative(time)
  if time > Time.now
     time_tag_to time
  else
     time_tag_ago time
  end
end

#time_tag_to(time) ⇒ Object



75
76
77
78
79
# File 'app/helpers/maily_herald_helper.rb', line 75

def time_tag_to(time)
  return unless time
  text = distance_of_time_in_words(Time.now, time)
  ('abbr', t('time_distance.in', :text => text), :title => time)
end