metadata_presenter 0.14.2 → 0.16.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e734af87f9a4682f32efe7a2b91aac95f11cbbb7ad64381fb8c65577618d6ebc
4
- data.tar.gz: 427c3c1799e4052526343ef30589ca289bd513fb6c80ad13c6f6e449783fae1b
3
+ metadata.gz: 15e470bd0e87527625fba6e246f2e9a43bf3523bc7689ecb1bfd18d760bca18c
4
+ data.tar.gz: 90dc8301fa94e80d07f7072f009ba44f79d4741e80539f5331bb27440d8672f6
5
5
  SHA512:
6
- metadata.gz: 0c34c9b019d624f74b8924f04a9a01d22891d86d5f3bb4f803c25f0a15c8d56cc59d58fe4a51c5f968946f435aeaecba24c235453853dca00e31d034109b113f
7
- data.tar.gz: 2df23b52496f0a3d37eab244b79d365f59d124fd46d390b5041fffea198709ecaf402d29a92cbce669055803c337c0809b8497d1e7d3967c24584764e5594165
6
+ metadata.gz: 873b081845358aa9569833889372ec358f034add8e6f6437b62c32ad8c3aa98d8292a86e605e7109f2d62a8ca5073a40e5354289b10369401f2975a5ff4cb89a
7
+ data.tar.gz: d3ffa82016eb6b56825ca39e9ef01b93f903a5488d2a1e5599474b2c04d0654a718dc6a3f1528fcb26ce69fc89dabcfcb757d206aceeb668163be4bff729ae6c
@@ -12,13 +12,13 @@ module MetadataPresenter
12
12
  end
13
13
  end
14
14
 
15
- def page_answers_presenters
15
+ def pages_presenters
16
16
  PageAnswersPresenter.map(
17
17
  view: view_context,
18
18
  pages: service.pages,
19
19
  answers: @user_data
20
20
  )
21
21
  end
22
- helper_method :page_answers_presenters
22
+ helper_method :pages_presenters
23
23
  end
24
24
  end
@@ -1,14 +1,14 @@
1
1
  module MetadataPresenter
2
2
  module ApplicationHelper
3
- def main_h1(component)
3
+ def main_title(component:, tag: :h1, classes: 'govuk-heading-xl')
4
4
  if component.legend.present?
5
5
  content_tag(:legend, class: 'govuk-fieldset__legend govuk-fieldset__legend--l') do
6
- content_tag(:h1, class: 'govuk-heading-xl') do
6
+ content_tag(tag, class: classes) do
7
7
  component.legend
8
8
  end
9
9
  end
10
10
  else
11
- content_tag(:h1, class: 'govuk-heading-xl') do
11
+ content_tag(tag, class: classes) do
12
12
  component.label
13
13
  end
14
14
  end
@@ -1,5 +1,7 @@
1
1
  module MetadataPresenter
2
2
  class PageAnswersPresenter
3
+ FIRST_ANSWER = 0.freeze
4
+
3
5
  def self.map(view:, pages:, answers:)
4
6
  pages.map do |page|
5
7
  Array(page.components).map do |component|
@@ -10,7 +12,7 @@ module MetadataPresenter
10
12
  answers: answers
11
13
  )
12
14
  end
13
- end.flatten
15
+ end.reject { |page| page.empty? }
14
16
  end
15
17
 
16
18
  attr_reader :view, :component, :page, :answers
@@ -37,6 +39,10 @@ module MetadataPresenter
37
39
  end
38
40
  end
39
41
 
42
+ def display_heading?(index)
43
+ page.type == 'page.multiplequestions' && index == FIRST_ANSWER
44
+ end
45
+
40
46
  private
41
47
 
42
48
  def date(value)
@@ -27,6 +27,8 @@
27
27
  <%= yield %>
28
28
  </main>
29
29
  </div>
30
+ <%= render template: 'metadata_presenter/footer/footer' %>
31
+
30
32
  <%= javascript_pack_tag 'application' %>
31
33
  <%= javascript_pack_tag 'govuk' %>
32
34
  </body>
@@ -0,0 +1,19 @@
1
+ <footer class="govuk-footer " role="contentinfo">
2
+ <div class="govuk-width-container ">
3
+ <div class="govuk-footer__meta">
4
+ <div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
5
+
6
+ <svg aria-hidden="true" focusable="false" class="govuk-footer__licence-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 483.2 195.7" height="17" width="41">
7
+ <path fill="currentColor" d="M421.5 142.8V.1l-50.7 32.3v161.1h112.4v-50.7zm-122.3-9.6A47.12 47.12 0 0 1 221 97.8c0-26 21.1-47.1 47.1-47.1 16.7 0 31.4 8.7 39.7 21.8l42.7-27.2A97.63 97.63 0 0 0 268.1 0c-36.5 0-68.3 20.1-85.1 49.7A98 98 0 0 0 97.8 0C43.9 0 0 43.9 0 97.8s43.9 97.8 97.8 97.8c36.5 0 68.3-20.1 85.1-49.7a97.76 97.76 0 0 0 149.6 25.4l19.4 22.2h3v-87.8h-80l24.3 27.5zM97.8 145c-26 0-47.1-21.1-47.1-47.1s21.1-47.1 47.1-47.1 47.2 21 47.2 47S123.8 145 97.8 145" />
8
+ </svg>
9
+ <span class="govuk-footer__licence-description">
10
+ All content is available under the
11
+ <a class="govuk-footer__link" href="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/" rel="license">Open Government Licence v3.0</a>, except where otherwise stated
12
+ </span>
13
+ </div>
14
+ <div class="govuk-footer__meta-item">
15
+ <a class="govuk-footer__link govuk-footer__copyright-logo" href="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/">© Crown copyright</a>
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </footer>
@@ -1,7 +1,7 @@
1
1
  <div class="govuk-grid-row">
2
2
  <div class="govuk-grid-column-two-thirds">
3
3
  <% if @page.section_heading.present? %>
4
- <p class="govuk-caption-l fb-section-heading"
4
+ <p class="fb-section-heading fb-editable govuk-caption-l"
5
5
  data-fb-content-type="element"
6
6
  data-fb-content-id="page[section_heading]">
7
7
  <%= @page.section_heading %>
@@ -9,7 +9,7 @@
9
9
  <% end %>
10
10
 
11
11
  <% if @page.heading.present? %>
12
- <h1 class="fb-editable fb-editable govuk-heading-xl"
12
+ <h1 class="fb-editable govuk-heading-xl"
13
13
  data-fb-content-type="element"
14
14
  data-fb-content-id="page[heading]">
15
15
  <%= @page.heading %>
@@ -25,41 +25,52 @@
25
25
  <% end %>
26
26
 
27
27
  <% if @page.body.present? %>
28
- <div class="fb-editable fb-body govuk-prose-scope"
28
+ <div class="fb-body fb-editable govuk-prose-scope"
29
29
  data-fb-content-type="content"
30
30
  data-fb-content-id="page[body]">
31
- <p><%= @page.body %></p>
31
+ <%= @page.body %>
32
32
  </div>
33
33
  <% end %>
34
34
 
35
35
  <%= form_for @page, url: reserved_submissions_path do |f| %>
36
36
  <div data-block-id="page.checkanswers.answers" data-block-type="answers">
37
37
  <dl class="fb-block fb-block-answers govuk-summary-list">
38
- <% page_answers_presenters.each do |page_answers_presenter| %>
39
- <div class="govuk-summary-list__row">
40
- <dt class="govuk-summary-list__key">
41
- <%= page_answers_presenter.humanised_title %>
42
- </dt>
38
+ <% pages_presenters.each do |page_answers_presenters| %>
39
+ <% page_answers_presenters.each_with_index do |page_answers_presenter, index| %>
43
40
 
44
- <dd class="govuk-summary-list__value">
45
- <%= page_answers_presenter.answer %>
46
- </dd>
47
- <dd class="govuk-summary-list__actions">
48
- <%= link_to(
49
- change_answer_path(url: page_answers_presenter.url),
50
- class: 'govuk-link'
51
- ) do %>
52
- Change<span class="govuk-visually-hidden"> Your answer for <%= page_answers_presenter.humanised_title %></span>
53
- <% end %>
54
- </a>
55
- </dd>
56
- </div>
41
+ <% if page_answers_presenter.display_heading?(index) %>
42
+ </dl>
43
+
44
+ <h3 class="govuk-heading-m"><%= page_answers_presenter.page.heading %></h3>
45
+
46
+ <dl class="fb-block fb-block-answers govuk-summary-list">
47
+ <% end %>
48
+
49
+ <div class="govuk-summary-list__row">
50
+ <dt class="govuk-summary-list__key">
51
+ <%= page_answers_presenter.humanised_title %>
52
+ </dt>
53
+
54
+ <dd class="govuk-summary-list__value">
55
+ <%= page_answers_presenter.answer %>
56
+ </dd>
57
+ <dd class="govuk-summary-list__actions">
58
+ <%= link_to(
59
+ change_answer_path(url: page_answers_presenter.url),
60
+ class: 'govuk-link'
61
+ ) do %>
62
+ Change<span class="govuk-visually-hidden"> Your answer for <%= page_answers_presenter.humanised_title %></span>
63
+ <% end %>
64
+ </a>
65
+ </dd>
66
+ </div>
67
+ <% end %>
57
68
  <% end %>
58
69
  </dl>
59
70
  </div>
60
71
 
61
72
  <% if @page.send_heading.present? %>
62
- <h2 class="fb-editable fb-send-heading govuk-heading-m"
73
+ <h2 class="fb-send-heading fb-editable govuk-heading-m"
63
74
  data-fb-content-type="element"
64
75
  data-fb-content-id="page[send_heading]">
65
76
  <%= @page.send_heading %>
@@ -67,7 +78,7 @@
67
78
  <% end %>
68
79
 
69
80
  <% if @page.send_body.present? %>
70
- <div class="fb-editable fb-send-body"
81
+ <div class="fb-send-body fb-editable"
71
82
  data-fb-content-type="content"
72
83
  data-fb-content-id="page[send_body]">
73
84
  <%= @page.send_body %>
@@ -1,19 +1,25 @@
1
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">
2
+ <h1 class="fb-editable govuk-panel__title"
3
+ data-fb-content-type="element"
4
+ data-fb-content-id="page[heading]">
3
5
  <%= @page.heading %>
4
6
  </h1>
5
7
 
6
8
  <% if @page.lede %>
7
- <div class="govuk-panel__body">
8
- <p><%= @page.lede %></p>
9
- </div>
9
+ <p class="fb-editable govuk-panel__body"
10
+ data-fb-content-type="element"
11
+ data-fb-content-id="page[lede]">
12
+ <%= @page.lede %>
13
+ </p>
10
14
  <% end %>
11
15
  </div>
12
16
 
13
17
  <% if @page.body %>
14
18
  <div class="govuk-grid-row">
15
19
  <div class="govuk-grid-column-two-thirds">
16
- <div class="fb-body govuk-prose-scope" data-block-id="<%= @page.id %>" data-block-property="body">
20
+ <div class="fb-editable fb-body govuk-prose-scope"
21
+ data-fb-content-type="content"
22
+ data-fb-content-id="page[body]">
17
23
  <%= @page.body %>
18
24
  </div>
19
25
  </div>
@@ -0,0 +1,33 @@
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="fb-editable govuk-caption-l fb-section_heading"
6
+ data-fb-content-type="element"
7
+ data-fb-content-id="page[section_heading]">
8
+ <%= @page.section_heading.html_safe %>
9
+ </p>
10
+ <%- end %>
11
+
12
+ <h1 class="govuk-heading-xl"><%= @page.heading %></h1>
13
+
14
+ <%= form_for @page_answers, as: :answers, url: @page.url, method: :post do |f| %>
15
+ <%= f.govuk_error_summary %>
16
+ <% @page.components.each_with_index do |component, index| %>
17
+ <%= render partial: component, locals: {
18
+ component: component,
19
+ component_id: "page[components[#{index}]]",
20
+ f: f,
21
+ input_title: main_title(
22
+ component: component,
23
+ tag: :h2,
24
+ classes: 'govuk-heading-m govuk-!-margin-top-8'
25
+ ) }
26
+ %>
27
+ <% end %>
28
+
29
+ <%= f.govuk_submit(disabled: editable?) %>
30
+ <% end %>
31
+ </div>
32
+ </div>
33
+ </div>
@@ -8,7 +8,7 @@
8
8
  component: component,
9
9
  component_id: "page[components[#{index}]]",
10
10
  f: f,
11
- input_title: main_h1(component) }
11
+ input_title: main_title(component: component) }
12
12
  %>
13
13
  <% end %>
14
14
 
@@ -2,8 +2,8 @@
2
2
  "_id": "component.text",
3
3
  "_type": "text",
4
4
  "errors": {},
5
- "hint": "Component hint",
6
- "label": "Component label",
5
+ "label": "Question",
6
+ "hint": "Hint (optional)",
7
7
  "name": "component-name",
8
8
  "validation": {
9
9
  "required": true
@@ -0,0 +1,8 @@
1
+ {
2
+ "_id": "page.multiplequestions",
3
+ "_type": "page.multiplequestions",
4
+ "section_heading": "[Section heading (optional)]",
5
+ "heading": "Question",
6
+ "components": [],
7
+ "url": ""
8
+ }
@@ -266,6 +266,59 @@
266
266
  "heading": "Checkboxes",
267
267
  "url": "/burgers"
268
268
  },
269
+ {
270
+ "_uuid": "9403b67a-19b5-4422-a91d-0774537e4c96",
271
+ "_id": "page.star-wars-knowledge",
272
+ "_type": "page.multiplequestions",
273
+ "components": [
274
+ {
275
+ "_id": "star-wars-knowledge_text_1",
276
+ "_type": "text",
277
+ "label": "What was the name of the band playing in Jabba's palace?",
278
+ "name": "star-wars-knowledge_text_1",
279
+ "validation": {
280
+ "required": true
281
+ }
282
+ },
283
+ {
284
+ "_id": "star-wars-knowledge_radios_1",
285
+ "_type": "radios",
286
+ "errors": {},
287
+ "hint": "Component hint",
288
+ "legend": "What is The Mandalorian's real name?",
289
+ "items": [
290
+ {
291
+ "_id": "star-wars-knowledge_radio_1",
292
+ "_type": "radio",
293
+ "label": "Harry Potter",
294
+ "hint": "Optional item hint",
295
+ "value": "harry-potter"
296
+ },
297
+ {
298
+ "_id": "star-wars-knowledge_radio_2",
299
+ "_type": "radio",
300
+ "label": "Din Jarrin",
301
+ "hint": "Optional item hint",
302
+ "value": "din-jarrin"
303
+ },
304
+ {
305
+ "_id": "star-wars-knowledge_radio_3",
306
+ "_type": "radio",
307
+ "label": "Tony Stark",
308
+ "hint": "Optional item hint",
309
+ "value": "tony-stark"
310
+ }
311
+ ],
312
+ "name": "star-wars-knowledge_radios_1",
313
+ "validation": {
314
+ "required": true
315
+ }
316
+ }
317
+ ],
318
+ "heading": "How well do you know Star Wars?",
319
+ "section_heading": "That's no moon",
320
+ "url": "/star-wars-knowledge"
321
+ },
269
322
  {
270
323
  "_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
271
324
  "_id": "page._check-answers",
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '0.14.2'
2
+ VERSION = '0.16.0'
3
3
  end
@@ -0,0 +1,20 @@
1
+ {
2
+ "$id": "http://gov.uk/schema/v1.0.0/page/multiplequestions",
3
+ "_name": "page.multiplequestions",
4
+ "title": "Multiple questions",
5
+ "description": "Ask users more than one question on a page",
6
+ "type": "object",
7
+ "properties": {
8
+ "_type": {
9
+ "const": "page.multiplequestions"
10
+ }
11
+ },
12
+ "allOf": [
13
+ {
14
+ "$ref": "definition.page.form"
15
+ }
16
+ ],
17
+ "required": [
18
+ "heading"
19
+ ]
20
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoJ Online
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -256,10 +256,12 @@ files:
256
256
  - app/views/metadata_presenter/component/_radios.html.erb
257
257
  - app/views/metadata_presenter/component/_text.html.erb
258
258
  - app/views/metadata_presenter/component/_textarea.html.erb
259
+ - app/views/metadata_presenter/footer/footer.html.erb
259
260
  - app/views/metadata_presenter/header/show.html.erb
260
261
  - app/views/metadata_presenter/page/checkanswers.html.erb
261
262
  - app/views/metadata_presenter/page/confirmation.html.erb
262
263
  - app/views/metadata_presenter/page/form.html.erb
264
+ - app/views/metadata_presenter/page/multiplequestions.html.erb
263
265
  - app/views/metadata_presenter/page/singlequestion.html.erb
264
266
  - app/views/metadata_presenter/page/start.html.erb
265
267
  - config/initializers/default_metadata.rb
@@ -277,6 +279,7 @@ files:
277
279
  - default_metadata/definition/radio.json
278
280
  - default_metadata/page/checkanswers.json
279
281
  - default_metadata/page/confirmation.json
282
+ - default_metadata/page/multiplequestions.json
280
283
  - default_metadata/page/singlequestion.json
281
284
  - default_metadata/page/start.json
282
285
  - default_metadata/service/base.json
@@ -341,6 +344,7 @@ files:
341
344
  - schemas/link/link.json
342
345
  - schemas/page/checkanswers.json
343
346
  - schemas/page/confirmation.json
347
+ - schemas/page/multiplequestions.json
344
348
  - schemas/page/singlequestion.json
345
349
  - schemas/page/start.json
346
350
  - schemas/request/service.json