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
#bsl_details ⇒ Object
68
69
70
71
72
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 68
def bsl_details
bsl_guidance = item[:bsl_guidance] || {}
render_govspeak(bsl_guidance[:value], root_class: "govuk-!-margin-bottom-0") if bsl_guidance[:show]
end
|
#call_charges_link ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 86
def call_charges_link
call_charges = item[:call_charges] || {}
if call_charges[:show_call_charges_info_url]
content_tag(:p) do
concat content_tag(:a,
call_charges[:label],
class: "govuk-link",
href: call_charges[:call_charges_info_url])
end
end
end
|
#description ⇒ Object
40
41
42
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 40
def description
render_govspeak(item[:description], root_class: "govuk-!-margin-top-1 govuk-!-margin-bottom-0")
end
|
#item_title ⇒ Object
36
37
38
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 36
def item_title
content_tag(:p, item[:title], { class: "govuk-!-margin-bottom-0" })
end
|
#number_list ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 44
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
52
53
54
55
56
57
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 52
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
74
75
76
77
78
79
80
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 74
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
82
83
84
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 82
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
20
21
|
# 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 video_relay_service
concat bsl_details
concat opening_hours_list if item[:opening_hours].present?
concat call_charges_link
end
end
end
|
#title_and_description ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 23
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
|
#video_relay_service ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb', line 59
def video_relay_service
video_relay_service = item[:video_relay_service] || {}
if video_relay_service[:show]
content = "#{video_relay_service[:prefix]} #{video_relay_service[:telephone_number]}"
render_govspeak(content, root_class: "govuk-!-margin-bottom-0")
end
end
|