metadata_presenter 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/metadata_presenter/page.rb +26 -0
- data/app/views/metadata_presenter/component/_components.html.erb +20 -0
- data/app/views/metadata_presenter/page/checkanswers.html.erb +14 -1
- data/app/views/metadata_presenter/page/confirmation.html.erb +3 -1
- data/app/views/metadata_presenter/page/content.html.erb +3 -1
- data/app/views/metadata_presenter/page/multiplequestions.html.erb +3 -1
- data/config/initializers/page_components.rb +19 -0
- data/default_metadata/page/checkanswers.json +2 -1
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/page/checkanswers.json +8 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0229789953adde481420a7894d10b46a960c916743ccad833e3478d7750f5f52'
|
4
|
+
data.tar.gz: 186e22679a9def093e40479662f4c9417251d18f63c10edb17a20a0555dc6b74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da02ebfa513bb1f68f74a682d292fb67502f74a29f9cd2f9d3524f92a2a21a87ad157c2d717e01c8e462fac0ea26a05cb00d4aa6c7c3a2aedc228b7e5735ee19
|
7
|
+
data.tar.gz: 0ea7f87eb28078007c0500e047856793ac5cdcd8a239d1934c798b279c90903a9f1197d4e5ee89e6d489b8b218ad9c64fe78d9d28b2d1189a5dcef89763b23b5
|
@@ -1,4 +1,7 @@
|
|
1
1
|
module MetadataPresenter
|
2
|
+
class PageComponentsNotDefinedError < StandardError
|
3
|
+
end
|
4
|
+
|
2
5
|
class Page < MetadataPresenter::Metadata
|
3
6
|
include ActiveModel::Validations
|
4
7
|
|
@@ -27,5 +30,28 @@ module MetadataPresenter
|
|
27
30
|
def template
|
28
31
|
"metadata_presenter/#{type.gsub('.', '/')}"
|
29
32
|
end
|
33
|
+
|
34
|
+
def input_components
|
35
|
+
page_components(raw_type)[:input_components]
|
36
|
+
end
|
37
|
+
|
38
|
+
def content_components
|
39
|
+
page_components(raw_type)[:content_components]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def page_components(page_type)
|
45
|
+
values = Rails.application.config.page_components[page_type]
|
46
|
+
if values.blank?
|
47
|
+
raise PageComponentsNotDefinedError, "No page components defined for #{page_type} in config initialiser"
|
48
|
+
end
|
49
|
+
|
50
|
+
values
|
51
|
+
end
|
52
|
+
|
53
|
+
def raw_type
|
54
|
+
type.gsub('page.', '')
|
55
|
+
end
|
30
56
|
end
|
31
57
|
end
|
@@ -18,3 +18,23 @@
|
|
18
18
|
%>
|
19
19
|
</div>
|
20
20
|
<% end %>
|
21
|
+
|
22
|
+
<% if editable? %>
|
23
|
+
<ul class="component-activated-menu govuk-navigation editor-button govuk-button fb-govuk-button">
|
24
|
+
<% if input_components.present? %>
|
25
|
+
<ul>
|
26
|
+
<% input_components.each do |component| %>
|
27
|
+
<li><a href="#add-input-component" data-component-type="<%= component %>"></a>+ Add <%= component %> component</li>
|
28
|
+
<% end %>
|
29
|
+
</ul>
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
<% if content_components.present? %>
|
33
|
+
<ul>
|
34
|
+
<% content_components.each do |component| %>
|
35
|
+
<li><a href="#add-content-component" data-component-type="<%= component %>">+ Add <%= component %> component</a></li>
|
36
|
+
<% end %>
|
37
|
+
</ul>
|
38
|
+
<% end %>
|
39
|
+
</ul>
|
40
|
+
<% end %>
|
@@ -12,6 +12,17 @@
|
|
12
12
|
<% end %>
|
13
13
|
|
14
14
|
<%= form_for @page, url: reserved_submissions_path do |f| %>
|
15
|
+
|
16
|
+
<%= render partial: 'metadata_presenter/component/components',
|
17
|
+
locals: {
|
18
|
+
f: f,
|
19
|
+
components: @page.extra_components,
|
20
|
+
tag: nil,
|
21
|
+
classes: nil,
|
22
|
+
input_components: @page.input_components,
|
23
|
+
content_components: @page.content_components
|
24
|
+
} %>
|
25
|
+
|
15
26
|
<div data-block-id="page.checkanswers.answers" data-block-type="answers">
|
16
27
|
<dl class="fb-block fb-block-answers govuk-summary-list">
|
17
28
|
<% pages_presenters.each do |page_answers_presenters| %>
|
@@ -69,7 +80,9 @@
|
|
69
80
|
f: f,
|
70
81
|
components: @page.components,
|
71
82
|
tag: nil,
|
72
|
-
classes: nil
|
83
|
+
classes: nil,
|
84
|
+
input_components: @page.input_components,
|
85
|
+
content_components: @page.content_components
|
73
86
|
} %>
|
74
87
|
|
75
88
|
<button <%= 'disabled' if editable? %> 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">
|
@@ -12,7 +12,9 @@
|
|
12
12
|
f: f,
|
13
13
|
components: @page.components,
|
14
14
|
tag: :h2,
|
15
|
-
classes: 'govuk-heading-m govuk-!-margin-top-8'
|
15
|
+
classes: 'govuk-heading-m govuk-!-margin-top-8',
|
16
|
+
input_components: @page.input_components,
|
17
|
+
content_components: @page.content_components
|
16
18
|
}
|
17
19
|
%>
|
18
20
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Rails.application.config.page_components =
|
2
|
+
ActiveSupport::HashWithIndifferentAccess.new({
|
3
|
+
checkanswers: {
|
4
|
+
input_components: %w(),
|
5
|
+
content_components: %w(content)
|
6
|
+
},
|
7
|
+
confirmation: {
|
8
|
+
input_components: %w(),
|
9
|
+
content_components: %w(content)
|
10
|
+
},
|
11
|
+
content: {
|
12
|
+
input_components: %w(),
|
13
|
+
content_components: %w(content)
|
14
|
+
},
|
15
|
+
multiplequestions: {
|
16
|
+
input_components: %w(text textarea number date radios checkboxes),
|
17
|
+
content_components: %w(content)
|
18
|
+
}
|
19
|
+
})
|
@@ -4,5 +4,6 @@
|
|
4
4
|
"heading": "Check your answers",
|
5
5
|
"send_heading": "Now send your application",
|
6
6
|
"send_body": "By submitting this application you confirm that, to the best of your knowledge, the details you are providing are correct.",
|
7
|
-
"components": []
|
7
|
+
"components": [],
|
8
|
+
"extra_components": []
|
8
9
|
}
|
@@ -43,6 +43,14 @@
|
|
43
43
|
"items": {
|
44
44
|
"$ref": "component.content"
|
45
45
|
}
|
46
|
+
},
|
47
|
+
"extra_components": {
|
48
|
+
"title": "Extra Components",
|
49
|
+
"description": "More form or content elements used on the page",
|
50
|
+
"type": "array",
|
51
|
+
"items": {
|
52
|
+
"$ref": "component.content"
|
53
|
+
}
|
46
54
|
}
|
47
55
|
},
|
48
56
|
"required": [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata_presenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MoJ Online
|
@@ -303,6 +303,7 @@ files:
|
|
303
303
|
- app/views/metadata_presenter/page/start.html.erb
|
304
304
|
- config/initializers/default_metadata.rb
|
305
305
|
- config/initializers/default_text.rb
|
306
|
+
- config/initializers/page_components.rb
|
306
307
|
- config/initializers/schemas.rb
|
307
308
|
- config/routes.rb
|
308
309
|
- default_metadata/component/checkboxes.json
|