Class: MetadataPresenter::EngineController
- Inherits:
-
Object
- Object
- MetadataPresenter::EngineController
show all
- Defined in:
- app/controllers/metadata_presenter/engine_controller.rb
Instance Method Summary
collapse
Instance Method Details
#allow_analytics? ⇒ Boolean
69
70
71
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 69
def allow_analytics?
cookies[analytics_cookie_name] == 'accepted'
end
|
#analytics_cookie_name ⇒ Object
64
65
66
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 64
def analytics_cookie_name
@analytics_cookie_name ||= "analytics-#{service.service_name.parameterize}"
end
|
86
87
88
89
90
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 86
def analytics_tags_present?
Rails.application.config.supported_analytics.values.flatten.any? do |analytic|
ENV[analytic].present?
end
end
|
#answered?(component_id) ⇒ Boolean
59
60
61
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 59
def answered?(component_id)
@page_answers.send(component_id).present?
end
|
#back_link ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 42
def back_link
previous_page = PreviousPage.new(
service:,
user_data: load_user_data,
current_page: @page,
referrer: request.referrer
).page
if previous_page
@back_link ||= File.join(
request.script_name,
previous_page.url
)
end
end
|
#external_or_relative_link(link) ⇒ Object
104
105
106
107
108
109
110
111
112
113
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 104
def external_or_relative_link(link)
uri = URI.parse(link)
return link if uri.scheme.present? && uri.host.present?
if editor_preview?
File.join(request.script_name, link)
else
link.starts_with?('/') ? link : link.prepend('/')
end
end
|
#get_saved_progress(uuid) ⇒ Object
24
25
26
27
28
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 24
def get_saved_progress(uuid)
if defined? super
super(uuid)
end
end
|
#increment_record_counter(uuid) ⇒ Object
30
31
32
33
34
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 30
def increment_record_counter(uuid)
if defined? super
super(uuid)
end
end
|
#invalidate_record(uuid) ⇒ Object
36
37
38
39
40
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 36
def invalidate_record(uuid)
if defined? super
super(uuid)
end
end
|
#load_autocomplete_items ⇒ Object
93
94
95
96
97
98
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 93
def load_autocomplete_items
if @page.autocomplete_component_present?
items = autocomplete_items(@page.components)
@page.assign_autocomplete_items(items)
end
end
|
#maintenance_mode? ⇒ Boolean
100
101
102
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 100
def maintenance_mode?
ENV['MAINTENANCE_MODE'].present? && ENV['MAINTENANCE_MODE'] == '1'
end
|
#reload_user_data ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 10
def reload_user_data
if defined? super
super
else
load_user_data
end
end
|
18
19
20
21
22
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 18
def save_form_progress
if defined? super
super
end
end
|
#show_cookie_confirmation? ⇒ Boolean
79
80
81
82
83
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 79
def show_cookie_confirmation?
unless no_analytics_cookie?
(Rails.application.config.respond_to?(:global_ga4) || analytics_tags_present?) && params[:analytics].present?
end
end
|
#show_cookie_request? ⇒ Boolean
74
75
76
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 74
def show_cookie_request?
(Rails.application.config.respond_to?(:global_ga4) || analytics_tags_present?) && no_analytics_cookie?
end
|