Module: MailyHerald::Webui::MailingsHelper

Defined in:
app/helpers/maily_herald/webui/mailings_helper.rb

Instance Method Summary collapse

Instance Method Details

#display_mailing_absolute_delay(mailing) ⇒ Object



59
60
61
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 59

def display_mailing_absolute_delay mailing
  distance_of_time_in_words mailing.absolute_delay
end

#display_mailing_from(mailing) ⇒ Object



50
51
52
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 50

def display_mailing_from mailing
  tw("mailings.from.default", email: mailing.mailer.default[:from])
end

#display_mailing_mailer(mailer) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 4

def display_mailing_mailer mailer
  (:code, class: "mailing-mailer") do
    if mailer == :generic
      icon(:cubes, tw(:label_generic_mailer))
    else
      icon("file-code-o", mailer)
    end
  end
end

#display_mailing_period(mailing) ⇒ Object



54
55
56
57
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 54

def display_mailing_period mailing
  #tw("commons.day", count: mailing.period_in_days)
  distance_of_time_in_words mailing.period
end


46
47
48
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 46

def link_to_mailing mailing
  link_to friendly_name(mailing), url_for_mailing(mailing)
end

#mailing_subscriber_actions(mailing, entity) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 14

def mailing_subscriber_actions mailing, entity
  actions = []
  actions << {
    name:      :custom, 
    url:       deliver_one_time_mailing_path(mailing, entity),
    icon:      "fa fa-paper-plane",
    title:     tw("mailings.list.deliver"),
    if:        mailing.processable?(entity),
    remote:    true,
    method:    :post,
    confirm:   tw("mailings.list.deliver_confirm")
  } if mailing.one_time?
  actions << {
    name:      :custom, 
    url:       {action: :preview, id: mailing, entity_id: entity},
    icon:      "fa fa-search",
    title:     tw("mailings.list.preview"),
    data: {
      toggle: "modal", 
      target: "#modal-generic"
    }
  }
end

#url_for_mailing(mailing) ⇒ Object



38
39
40
41
42
43
44
# File 'app/helpers/maily_herald/webui/mailings_helper.rb', line 38

def url_for_mailing mailing
  if mailing.sequence?
    sequence_mailing_path(mailing.sequence_id, mailing)
  else
    url_for(mailing)
  end
end