Class: ContentBlockTools::Presenters::BlockPresenters::Contact::TelephonePresenter
Constant Summary
BlockLevelContactItem::BASE_TAG_TYPE
BasePresenter::BASE_TAG_TYPE
Instance Attribute Summary
#item
Instance Method Summary
collapse
#initialize, #title, #wrapper
#initialize
Methods included from Govspeak
#render_govspeak
Instance Method Details
#call_charges_link ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 69
def call_charges_link
if item[:show_uk_call_charges] == "true"
content_tag(:p) do
concat content_tag(:a,
"Find out about call charges",
class: "govuk-link",
href: "https://www.gov.uk/call-charges")
end
end
end
|
#description ⇒ Object
38
39
40
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 38
def description
render_govspeak(item[:description], root_class: "govuk-!-margin-top-1 govuk-!-margin-bottom-0")
end
|
#item_title ⇒ Object
34
35
36
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 34
def item_title
content_tag(:p, item[:title], { class: "govuk-!-margin-bottom-0" })
end
|
#number_list ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 42
def number_list
content_tag(:ul) do
item[:telephone_numbers].each do |number|
concat number_list_item(number)
end
end
end
|
#number_list_item(number) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 50
def number_list_item(number)
content_tag(:li) do
concat content_tag(:span, number[:label])
concat content_tag(:span, number[:telephone_number], { class: "tel" })
end
end
|
#opening_hours_list ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 57
def opening_hours_list
content_tag(:ul) do
item[:opening_hours].each do |item|
concat opening_hours_list_item(item)
end
end
end
|
#opening_hours_list_item(item) ⇒ Object
65
66
67
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 65
def opening_hours_list_item(item)
content_tag(:li, "#{item[:day_from]} to #{item[:day_to]}, #{item[:time_from]} to #{item[:time_to]}")
end
|
#render ⇒ Object
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 10
def render
wrapper do
content_tag(:div, class: "email-url-number") do
concat title_and_description
concat number_list
concat opening_hours_list if item[:opening_hours].present?
concat call_charges_link
end
end
end
|
#title_and_description ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 21
def title_and_description
items = [
(item_title if item[:title].present?),
(description if item[:description].present?),
].compact
if items.any?
content_tag(:div, class: "govuk-!-margin-bottom-3") do
concat items.join("").html_safe
end
end
end
|