metadata_presenter 0.15.0 → 0.16.1

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: a57847bf1b54066efd54ee0b129eb32c6cceb29251f0a8e59a9b5b762a78b240
4
- data.tar.gz: a871cd1bc5356662288a8f48e48fce9c965080ef9fba3e93837a322c1ee49d58
3
+ metadata.gz: 5a8b044a284008931b778a50a1940563f749100928b63e7bd524fee9d084f636
4
+ data.tar.gz: 59c2ce2dd991b6626a5e31064e6e0e7467987ce0eb378de628a98e08d33f44ba
5
5
  SHA512:
6
- metadata.gz: c33ac7743bcabc8a970cdbfde9ee5cbc9ceafd57de3bb2dd0e109230faa907d7ac3b537c48ee3f5ebcdfbbac112953b775ba1adae57b7882da4ee3017e1092d7
7
- data.tar.gz: 450f0e38ba04a8f341d5fca108d597d5ecc5846019fb102098d0bcab6b36419c84e98bdded8bde440db6882f8928af5f7163cc6e08c62198f55bf6dc14e4f728
6
+ metadata.gz: d3b9083adba3e4c7a4c5391c89cb3da1b7f77cbfb08f308a1a2ec902072c02f22e07e53f6f4fbf3f3c3cf2d2afce5911230ba010c05454126706c5ed0797545a
7
+ data.tar.gz: c54ca229a2a4af58d4a7fc07f6943cef91bfe327912e35afcbd79e4dbde04d0efd70f0abfd61da8261c1343a5fc9e7c1ab5fc427abd8d0fa0aff240139042ebb
@@ -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)
@@ -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,20 +2,20 @@
2
2
  "_id": "component.checkboxes",
3
3
  "_type": "checkboxes",
4
4
  "errors": {},
5
- "hint": "[Hint text (optional)]",
5
+ "hint": "[Optional hint text]",
6
6
  "items": [
7
7
  {
8
8
  "_id": "component_checkbox_1",
9
9
  "_type": "checkbox",
10
10
  "label": "Option",
11
- "hint": "[Hint text (optional)]",
11
+ "hint": "[Optional hint text]",
12
12
  "value": "value-1"
13
13
  },
14
14
  {
15
15
  "_id": "component_checkbox_2",
16
16
  "_type": "checkbox",
17
17
  "label": "Option",
18
- "hint": "[Hint text (optional)]",
18
+ "hint": "[Optional hint text]",
19
19
  "value": "value-2"
20
20
  }
21
21
  ],
@@ -2,8 +2,8 @@
2
2
  "_id": "component.date",
3
3
  "_type": "date",
4
4
  "errors": {},
5
- "hint": "Component hint",
6
- "legend": "Component legend",
5
+ "hint": "[Optional hint text]",
6
+ "legend": "Question",
7
7
  "name": "component-name",
8
8
  "date_type": "day-month-year",
9
9
  "validation": {
@@ -2,8 +2,8 @@
2
2
  "_id": "component.number",
3
3
  "_type": "number",
4
4
  "errors": {},
5
- "hint": "Component hint",
6
- "label": "Component label",
5
+ "hint": "[Optional hint text]",
6
+ "label": "Question",
7
7
  "name": "component-name",
8
8
  "width_class_input": "10",
9
9
  "validation": {
@@ -2,20 +2,20 @@
2
2
  "_id": "component.radios",
3
3
  "_type": "radios",
4
4
  "errors": {},
5
- "hint": "[Hint text (optional)]",
5
+ "hint": "[Optional hint text]",
6
6
  "items": [
7
7
  {
8
8
  "_id": "component_radio_1",
9
9
  "_type": "radio",
10
10
  "label": "Option",
11
- "hint": "[Hint text (optional)]",
11
+ "hint": "[Optional hint text]",
12
12
  "value": "value-1"
13
13
  },
14
14
  {
15
15
  "_id": "component_radio_2",
16
16
  "_type": "radio",
17
17
  "label": "Option",
18
- "hint": "[Hint text (optional)]",
18
+ "hint": "[Optional hint text]",
19
19
  "value": "value-2"
20
20
  }
21
21
  ],
@@ -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": "[Optional hint text]",
7
7
  "name": "component-name",
8
8
  "validation": {
9
9
  "required": true
@@ -2,8 +2,8 @@
2
2
  "_id": "component.textarea",
3
3
  "_type": "textarea",
4
4
  "errors": {},
5
- "hint": "Component hint",
6
- "label": "Component label",
5
+ "hint": "[Optional hint text]",
6
+ "label": "Question",
7
7
  "name": "component-name",
8
8
  "rows": 5,
9
9
  "validation": {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "_id": "page.confirmation",
3
3
  "_type": "page.confirmation",
4
- "heading": "Required - Confirmation"
4
+ "heading": "Application complete"
5
5
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "_id": "page.multiplequestions",
3
+ "_type": "page.multiplequestions",
4
+ "section_heading": "[Optional section heading]",
5
+ "heading": "Title",
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.15.0'
2
+ VERSION = '0.16.1'
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.15.0
4
+ version: 0.16.1
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-02 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -261,6 +261,7 @@ files:
261
261
  - app/views/metadata_presenter/page/checkanswers.html.erb
262
262
  - app/views/metadata_presenter/page/confirmation.html.erb
263
263
  - app/views/metadata_presenter/page/form.html.erb
264
+ - app/views/metadata_presenter/page/multiplequestions.html.erb
264
265
  - app/views/metadata_presenter/page/singlequestion.html.erb
265
266
  - app/views/metadata_presenter/page/start.html.erb
266
267
  - config/initializers/default_metadata.rb
@@ -278,6 +279,7 @@ files:
278
279
  - default_metadata/definition/radio.json
279
280
  - default_metadata/page/checkanswers.json
280
281
  - default_metadata/page/confirmation.json
282
+ - default_metadata/page/multiplequestions.json
281
283
  - default_metadata/page/singlequestion.json
282
284
  - default_metadata/page/start.json
283
285
  - default_metadata/service/base.json
@@ -342,6 +344,7 @@ files:
342
344
  - schemas/link/link.json
343
345
  - schemas/page/checkanswers.json
344
346
  - schemas/page/confirmation.json
347
+ - schemas/page/multiplequestions.json
345
348
  - schemas/page/singlequestion.json
346
349
  - schemas/page/start.json
347
350
  - schemas/request/service.json