metadata_presenter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +68 -0
- data/Rakefile +29 -0
- data/app/assets/config/metadata_presenter_manifest.js +1 -0
- data/app/assets/stylesheets/metadata_presenter/application.css +15 -0
- data/app/controllers/metadata_presenter/answers_controller.rb +42 -0
- data/app/controllers/metadata_presenter/change_answer_controller.rb +8 -0
- data/app/controllers/metadata_presenter/engine_controller.rb +25 -0
- data/app/controllers/metadata_presenter/pages_controller.rb +14 -0
- data/app/controllers/metadata_presenter/service_controller.rb +8 -0
- data/app/controllers/metadata_presenter/submissions_controller.rb +13 -0
- data/app/helpers/metadata_presenter/application_helper.rb +7 -0
- data/app/jobs/metadata_presenter/application_job.rb +4 -0
- data/app/models/metadata_presenter/component.rb +5 -0
- data/app/models/metadata_presenter/metadata.rb +26 -0
- data/app/models/metadata_presenter/next_page.rb +18 -0
- data/app/models/metadata_presenter/page.rb +27 -0
- data/app/models/metadata_presenter/service.rb +28 -0
- data/app/validators/metadata_presenter/base_validator.rb +119 -0
- data/app/validators/metadata_presenter/max_length_validator.rb +7 -0
- data/app/validators/metadata_presenter/min_length_validator.rb +7 -0
- data/app/validators/metadata_presenter/required_validator.rb +7 -0
- data/app/validators/metadata_presenter/validate_answers.rb +48 -0
- data/app/validators/metadata_presenter/validate_schema.rb +39 -0
- data/app/views/errors/404.html +67 -0
- data/app/views/layouts/metadata_presenter/application.html.erb +33 -0
- data/app/views/metadata_presenter/component/_text.html.erb +7 -0
- data/app/views/metadata_presenter/header/show.html.erb +35 -0
- data/app/views/metadata_presenter/page/confirmation.html.erb +21 -0
- data/app/views/metadata_presenter/page/form.html.erb +19 -0
- data/app/views/metadata_presenter/page/singlequestion.html.erb +18 -0
- data/app/views/metadata_presenter/page/start.html.erb +38 -0
- data/app/views/metadata_presenter/page/summary.html.erb +73 -0
- data/config/initializers/default_metadata.rb +15 -0
- data/config/initializers/schemas.rb +13 -0
- data/config/routes.rb +8 -0
- data/lib/metadata_presenter.rb +4 -0
- data/lib/metadata_presenter/engine.rb +9 -0
- data/lib/metadata_presenter/version.rb +3 -0
- data/lib/tasks/metadata_presenter_tasks.rake +4 -0
- metadata +285 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
module MetadataPresenter
|
2
|
+
class ValidateAnswers
|
3
|
+
attr_reader :page, :components, :answers
|
4
|
+
|
5
|
+
def initialize(page:, answers:)
|
6
|
+
@page = page
|
7
|
+
@answers = answers
|
8
|
+
@components = Array(page.components)
|
9
|
+
end
|
10
|
+
|
11
|
+
def valid?
|
12
|
+
validators.map { |validator| validator.valid? }.all?
|
13
|
+
end
|
14
|
+
|
15
|
+
def invalid?
|
16
|
+
!valid?
|
17
|
+
end
|
18
|
+
|
19
|
+
def validators
|
20
|
+
components.map do |component|
|
21
|
+
component_validations(component).map do |key|
|
22
|
+
"MetadataPresenter::#{key.classify}Validator".constantize.new(
|
23
|
+
page: page,
|
24
|
+
answers: answers,
|
25
|
+
component: component
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end.compact.flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
def component_validations(component)
|
32
|
+
return [] if component.validation.blank?
|
33
|
+
|
34
|
+
component.validation.reject do |_, value|
|
35
|
+
value.blank? ||
|
36
|
+
(optional_question?(component) && question_not_answered?)
|
37
|
+
end.keys
|
38
|
+
end
|
39
|
+
|
40
|
+
def optional_question?(component)
|
41
|
+
component.validation['required'] == false
|
42
|
+
end
|
43
|
+
|
44
|
+
def question_not_answered?
|
45
|
+
answers.values.any?(&:blank?)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class SchemaNotFoundError < StandardError
|
2
|
+
end
|
3
|
+
|
4
|
+
class MetadataPresenter::ValidateSchema
|
5
|
+
class << self
|
6
|
+
def before(controller)
|
7
|
+
return unless controller.request.post?
|
8
|
+
|
9
|
+
schema_name = "request.#{controller.request.params['controller']}"
|
10
|
+
validate(controller.request.params, schema_name)
|
11
|
+
rescue JSON::Schema::ValidationError, JSON::Schema::SchemaError, SchemaNotFoundError => e
|
12
|
+
controller.render(
|
13
|
+
json: ErrorsSerializer.new(message: e.message).attributes,
|
14
|
+
status: :unprocessable_entity
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def validate(metadata, schema_name)
|
19
|
+
schema = JSON::Validator.schema_for_uri(schema_name)&.schema || find(schema_name)
|
20
|
+
JSON::Validator.validate!(schema, metadata)
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(schema_name)
|
24
|
+
schema_file = schema_name.gsub('.', '/')
|
25
|
+
schema = JSON.parse(
|
26
|
+
File.read(
|
27
|
+
File.join(
|
28
|
+
Rails.application.config.schemas_directory, "#{schema_file}.json"
|
29
|
+
)
|
30
|
+
)
|
31
|
+
)
|
32
|
+
jschema = JSON::Schema.new(schema, Addressable::URI.parse(schema['_name']))
|
33
|
+
JSON::Validator.add_schema(jschema)
|
34
|
+
JSON::Validator.schema_for_uri(schema_name).schema
|
35
|
+
rescue Errno::ENOENT
|
36
|
+
raise SchemaNotFoundError.new("Schema not found => #{schema_name}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
.rails-default-error-page {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
.rails-default-error-page div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
.rails-default-error-page h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body class="rails-default-error-page">
|
58
|
+
<!-- This file lives in public/404.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
65
|
+
</div>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= service.service_name %></title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<link rel="shortcut icon" sizes="16x16 32x32 48x48" href="<%= asset_pack_url('media/images/favicon.ico') %>" type="image/x-icon" />
|
9
|
+
<link rel="mask-icon" href="<%= asset_pack_url('media/images/govuk-mask-icon.svg') %>" color="blue">
|
10
|
+
<link rel="apple-touch-icon" sizes="180x180" href="<%= asset_pack_url('media/images/govuk-apple-touch-icon-180x180.png') %>">
|
11
|
+
<link rel="apple-touch-icon" sizes="167x167" href="<%= asset_pack_url('media/images/govuk-apple-touch-icon-167x167.png') %>">
|
12
|
+
<link rel="apple-touch-icon" sizes="152x152" href="<%= asset_pack_url('media/images/govuk-apple-touch-icon-152x152.png') %>">
|
13
|
+
<link rel="apple-touch-icon" href="<%= asset_pack_url('media/images/govuk-apple-touch-icon.png') %>">
|
14
|
+
|
15
|
+
<%= stylesheet_pack_tag 'govuk' %>
|
16
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
17
|
+
<%= javascript_pack_tag 'application' %>
|
18
|
+
</head>
|
19
|
+
|
20
|
+
<body class="govuk-template__body">
|
21
|
+
<%= render template: 'metadata_presenter/header/show' %>
|
22
|
+
<div class="govuk-width-container govuk-body-m">
|
23
|
+
<main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing" id="main-content" role="main">
|
24
|
+
<% if back_link.present? %>
|
25
|
+
<a class="govuk-back-link" href="<%= back_link %>">Back</a>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<%= yield %>
|
29
|
+
</main>
|
30
|
+
</div>
|
31
|
+
<%= javascript_pack_tag 'govuk' %>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<header class="govuk-header" role="banner" data-module="govuk-header">
|
2
|
+
<div class="govuk-header__container govuk-width-container">
|
3
|
+
<div class="govuk-header__logo">
|
4
|
+
<a href="/" class="govuk-header__link govuk-header__link--homepage">
|
5
|
+
<span class="govuk-header__logotype">
|
6
|
+
<svg
|
7
|
+
aria-hidden="true"
|
8
|
+
focusable="false"
|
9
|
+
class="govuk-header__logotype-crown"
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
11
|
+
viewbox="0 0 132 97"
|
12
|
+
height="30"
|
13
|
+
width="36"
|
14
|
+
>
|
15
|
+
<path
|
16
|
+
fill="currentColor" fill-rule="evenodd"
|
17
|
+
d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.4 3.6-.3 7.7-3.9 9.1zM69.7 17.7l8.9 4.7V9.3l-8.9 2.8c-.2-.3-.5-.6-.9-.9L72.4 0H59.6l3.5 11.2c-.3.3-.6.5-.9.9l-8.8-2.8v13.1l8.8-4.7c.3.3.6.7.9.9l-5 15.4v.1c-.2.8-.4 1.6-.4 2.4 0 4.1 3.1 7.5 7 8.1h.2c.3 0 .7.1 1 .1.4 0 .7 0 1-.1h.2c4-.6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"
|
18
|
+
></path>
|
19
|
+
<image src="{{ params.assetsPath | default('/assets/images') }}/govuk-logotype-crown.png" xlink:href="" class="govuk-header__logotype-crown-fallback-image" width="36" height="32"></image>
|
20
|
+
</svg>
|
21
|
+
<span class="govuk-header__logotype-text">
|
22
|
+
GOV.UK
|
23
|
+
</span>
|
24
|
+
</span>
|
25
|
+
</a>
|
26
|
+
</div>
|
27
|
+
<% if service.service_name.present? %>
|
28
|
+
<div class="govuk-header__content">
|
29
|
+
<a href="/" class="govuk-header__link govuk-header__link--service-name">
|
30
|
+
<%= service.service_name %>
|
31
|
+
</a>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</header>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<div class="govuk-panel govuk-panel--confirmation" data-block-id="<%= @page.id %>" data-block-property="heading" data-block-property-class="govuk-panel__body:lede">
|
2
|
+
<h1 class="govuk-panel__title">
|
3
|
+
<%= @page.heading %>
|
4
|
+
</h1>
|
5
|
+
|
6
|
+
<% if @page.lede %>
|
7
|
+
<div class="govuk-panel__body">
|
8
|
+
<p><%= @page.lede %></p>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<% if @page.body %>
|
14
|
+
<div class="govuk-grid-row">
|
15
|
+
<div class="govuk-grid-column-two-thirds">
|
16
|
+
<div class="fb-body govuk-prose-scope" data-block-id="<%= @page.id %>" data-block-property="body">
|
17
|
+
<%= @page.body %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div class="fb-main-grid-wrapper" data-block-id="<%= @page.id %>" data-block-type="page" data-block-pagetype="<%= @page.type %>">
|
2
|
+
<div class="govuk-grid-row">
|
3
|
+
<div class="govuk-grid-column-two-thirds">
|
4
|
+
<% if @page.body %>
|
5
|
+
<p class="govuk-body-l" data-block-id="<%= @page.id %>" data-block-property="lede">
|
6
|
+
<%= to_markdown(@page.body) %>
|
7
|
+
</p>
|
8
|
+
<%- end %>
|
9
|
+
<%= form_tag(reserved_answers_path, method: :post) do %>
|
10
|
+
<button class='govuk-button govuk-button--start govuk-!-margin-top-2'>
|
11
|
+
Continue
|
12
|
+
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
|
13
|
+
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
|
14
|
+
</svg>
|
15
|
+
</button>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div class="fb-main-grid-wrapper" data-block-id="<%= @page.id %>" data-block-type="page" data-block-pagetype="<%= @page.type %>">
|
2
|
+
<div class="govuk-grid-row">
|
3
|
+
<div class="govuk-grid-column-two-thirds">
|
4
|
+
<h1 class="<%= @page.heading_class %>" data-block-id="<%= @page.id %>" data-block-property="heading">
|
5
|
+
<%= @page.heading.html_safe %>
|
6
|
+
</h1>
|
7
|
+
|
8
|
+
<%= form_for @page, url: reserved_answers_path(@page.url) do |f| %>
|
9
|
+
<%= f.govuk_error_summary %>
|
10
|
+
<% @page.components.each do |component| %>
|
11
|
+
<%= render partial: component, locals: { component: component, f: f } %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= f.govuk_submit %>
|
15
|
+
<% end %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</div>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<div class="fb-main-grid-wrapper" data-block-id="<%= @page.id %>" data-block-type="page" data-block-pagetype="<%= @page.type %>">
|
2
|
+
<div class="govuk-grid-row">
|
3
|
+
<div class="govuk-grid-column-two-thirds">
|
4
|
+
<% if @page.section_heading -%>
|
5
|
+
<p class="govuk-caption-l fb-section_heading" data-block-id="<%= @page.id %>" data-block-property="section_heading">
|
6
|
+
<%= @page.section_heading.html_safe %>
|
7
|
+
</p>
|
8
|
+
<%- end %>
|
9
|
+
|
10
|
+
<% if @page.heading %>
|
11
|
+
<h1 class="<%= @page.heading_class %>" data-block-id="<%= @page.id %>" data-block-property="heading">
|
12
|
+
<%= @page.heading.html_safe %>
|
13
|
+
</h1>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% if @page.lede %>
|
17
|
+
<p class="govuk-body-l" data-block-id="<%= @page.id %>" data-block-property="lede">
|
18
|
+
<%= @page.lede.html_safe %>
|
19
|
+
</p>
|
20
|
+
<%- end %>
|
21
|
+
|
22
|
+
<% if @page.body %>
|
23
|
+
<p class="govuk-body-l" data-block-id="<%= @page.id %>" data-block-property="lede">
|
24
|
+
<%= to_markdown(@page.body) %>
|
25
|
+
</p>
|
26
|
+
<%- end %>
|
27
|
+
|
28
|
+
<%= form_tag(reserved_answers_path(@page.url), method: :post) do %>
|
29
|
+
<button class='govuk-button govuk-button--start govuk-!-margin-top-2'>
|
30
|
+
Start
|
31
|
+
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
|
32
|
+
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
|
33
|
+
</svg>
|
34
|
+
</button>
|
35
|
+
<% end %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
@@ -0,0 +1,73 @@
|
|
1
|
+
<div class="govuk-grid-row">
|
2
|
+
<div class="govuk-grid-column-two-thirds">
|
3
|
+
<% if @page.section_heading.present? %>
|
4
|
+
<p class="govuk-caption-l fb-section-heading" data-block-id="<%= @page.id %>" data-block-property="section_heading">
|
5
|
+
<%= @page.section_heading %>
|
6
|
+
</p>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if @page.heading.present? %>
|
10
|
+
<h1 class="govuk-heading-xl" data-block-id="<%= @page.id %>" data-block-property="heading">
|
11
|
+
<%= @page.heading %>
|
12
|
+
</h1>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% if @page.lede.present? %>
|
16
|
+
<p class="govuk-body-l" data-block-id="<%= @page.id %>" data-block-property="lede">
|
17
|
+
<%= @page.lede %>
|
18
|
+
</p>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if @page.body.present? %>
|
22
|
+
<div class="fb-body govuk-prose-scope" data-block-id="<%= @page.id %>" data-block-property="body">
|
23
|
+
<p><%= @page.body %></p>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<%= form_for @page, url: reserved_submissions_path do |f| %>
|
28
|
+
<div data-block-id="page.summary.answers" data-block-type="answers">
|
29
|
+
<dl class="fb-block fb-block-answers govuk-summary-list">
|
30
|
+
<% @service.pages.each do |page| %>
|
31
|
+
<% Array(page.components).each do |component| %>
|
32
|
+
<div class="govuk-summary-list__row">
|
33
|
+
<dt class="govuk-summary-list__key">
|
34
|
+
<%= component.label %>
|
35
|
+
</dt>
|
36
|
+
|
37
|
+
<dd class="govuk-summary-list__value">
|
38
|
+
<%= @user_data[component.name] %>
|
39
|
+
</dd>
|
40
|
+
<dd class="govuk-summary-list__actions">
|
41
|
+
<%= link_to(change_answer_path(url: page.url),
|
42
|
+
class: 'govuk-link',
|
43
|
+
method: :post) do %>
|
44
|
+
Change<span class="govuk-visually-hidden"> Your answer for <%= component.label %></span>
|
45
|
+
<% end %>
|
46
|
+
</a>
|
47
|
+
</dd>
|
48
|
+
</div>
|
49
|
+
<% end %>
|
50
|
+
<% end %>
|
51
|
+
</dl>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<% if @page.send_heading.present? %>
|
55
|
+
<h2 class="fb-send-heading govuk-heading-m" data-block-id="<%= @page.id %>" data-block-property="send_heading">
|
56
|
+
<%= @page.send_heading %>
|
57
|
+
</h2>
|
58
|
+
<% end %>
|
59
|
+
|
60
|
+
<% if @page.send_body.present? %>
|
61
|
+
<div class="fb-send-body" data-block-id="<%= @page.id %>" data-block-property="send_body">
|
62
|
+
<p>
|
63
|
+
<%= @page.send_body %>
|
64
|
+
</p>
|
65
|
+
</div>
|
66
|
+
<% end %>
|
67
|
+
|
68
|
+
<button data-prevent-double-click="true" class="fb-block fb-block-actions govuk-button" data-module="govuk-button" data-block-id="actions" data-block-type="actions">
|
69
|
+
Accept and send application
|
70
|
+
</button>
|
71
|
+
<% end %>
|
72
|
+
</div>
|
73
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Rails.application.config.default_metadata_directory = MetadataPresenter::Engine.root.join('default_metadata')
|
2
|
+
|
3
|
+
Rails.application.config.default_metadata = {}
|
4
|
+
|
5
|
+
Rails.logger.info('Loading default metadata')
|
6
|
+
default_metadata = Dir.glob("#{Rails.application.config.default_metadata_directory}/*/**")
|
7
|
+
default_metadata.each do |metadata_file|
|
8
|
+
metadata = JSON.parse(File.read(metadata_file))
|
9
|
+
Rails.logger.info(metadata['_id'])
|
10
|
+
Rails.application.config.default_metadata[metadata['_id']] = metadata
|
11
|
+
end
|
12
|
+
|
13
|
+
Rails.logger.info(
|
14
|
+
"Total loaded default metadata => #{Rails.application.config.default_metadata.count}"
|
15
|
+
)
|