metadata_presenter 0.28.6 → 0.28.11

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: 4ea3e46c638a7106dfc7686c3b5116e9c53d18a2d3bcf3654a3bfb8b36875094
4
- data.tar.gz: ea7e5ffdf31633d8fd72b0bdca31c24161f9e1b6c6227502428952dbad00d08c
3
+ metadata.gz: f78817e09df43b22a08bde0ef895aab1dad0b5df6c832a4863d3acd65226edc1
4
+ data.tar.gz: 7abf811d72763e4c898a6f99b39cd0626b2cec3f1669f95c93a76a44cf7366c5
5
5
  SHA512:
6
- metadata.gz: 64d8e27ec3ab680aeaa2c7e92685ef0388282a62b010b79c100d5e5bc352a9f530dfe74c03cf1eda7a6ff723d09abe7a1f8d980a0dd59f08264667f0e6dd3822
7
- data.tar.gz: 53f666eaff835a7fe1668809917021037f986e516180ba6433e75df9a5bcd9b9d6bfd1b0b1787362f43cb9ba708a6541b3c86ff7e57fd418458fa75c3c9d52a1
6
+ metadata.gz: 1b97ab2f1943cd6606c46e1060bade9369c5153dbad518f7703ab9f2031b9c087b7c5c1c00b9e9c04d09ca56caf0249ebf8811ebdc5c3eafb87b1210dc743552
7
+ data.tar.gz: 8b5332c2a57fdc8c3008b1dba0017a0d858330d81b92ec8560dbee1f1a6f40bebf52965ee109bb8c2bff1019bef7855e3417539736765a226ee7936cc34f61e6
@@ -18,9 +18,5 @@ module MetadataPresenter
18
18
  def default_text(property)
19
19
  MetadataPresenter::DefaultText[property]
20
20
  end
21
-
22
- def meta_items
23
- service.meta.items
24
- end
25
21
  end
26
22
  end
@@ -13,6 +13,10 @@ class MetadataPresenter::Metadata
13
13
  to_h.to_json
14
14
  end
15
15
 
16
+ def uuid
17
+ metadata._uuid
18
+ end
19
+
16
20
  def id
17
21
  metadata._id
18
22
  end
@@ -5,16 +5,25 @@ module MetadataPresenter
5
5
  class Page < MetadataPresenter::Metadata
6
6
  include ActiveModel::Validations
7
7
 
8
- def uuid
8
+ NOT_EDITABLE = %i[
9
9
  _uuid
10
- end
10
+ _id
11
+ _type
12
+ steps
13
+ add_component
14
+ add_extra_component
15
+ ].freeze
11
16
 
12
17
  def ==(other)
13
18
  id == other.id if other.respond_to? :id
14
19
  end
15
20
 
16
21
  def editable_attributes
17
- to_h.reject { |k, _| k.in?(%i[_id _type steps]) }
22
+ to_h.reject { |k, _| k.in?(NOT_EDITABLE) }
23
+ end
24
+
25
+ def all_components
26
+ [components, extra_components].flatten.compact
18
27
  end
19
28
 
20
29
  def components
@@ -25,6 +34,14 @@ module MetadataPresenter
25
34
  to_components(metadata.extra_components, collection: :extra_components)
26
35
  end
27
36
 
37
+ def components_by_type(type)
38
+ supported_components = page_components(raw_type)[type]
39
+
40
+ all_components.select do |component|
41
+ supported_components.include?(component.type)
42
+ end
43
+ end
44
+
28
45
  def to_partial_path
29
46
  type.gsub('.', '/')
30
47
  end
@@ -34,11 +51,11 @@ module MetadataPresenter
34
51
  end
35
52
 
36
53
  def input_components
37
- page_components(raw_type)[:input_components]
54
+ page_components(raw_type)[:input]
38
55
  end
39
56
 
40
57
  def content_components
41
- page_components(raw_type)[:content_components]
58
+ page_components(raw_type)[:content]
42
59
  end
43
60
 
44
61
  private
@@ -1,11 +1,16 @@
1
1
  module MetadataPresenter
2
2
  class PageAnswersPresenter
3
3
  FIRST_ANSWER = 0
4
- NO_USER_INPUT = %w[page.checkanswers page.confirmation page.content].freeze
4
+ NO_USER_INPUT = %w[
5
+ page.checkanswers
6
+ page.confirmation
7
+ page.content
8
+ page.start
9
+ ].freeze
5
10
 
6
11
  def self.map(view:, pages:, answers:)
7
12
  user_input_pages(pages).map { |page|
8
- Array(page.components).map do |component|
13
+ Array(page.components_by_type(:input)).map do |component|
9
14
  new(
10
15
  view: view,
11
16
  component: component,
@@ -47,11 +52,19 @@ module MetadataPresenter
47
52
  end
48
53
 
49
54
  def display_heading?(index)
50
- page.type == 'page.multiplequestions' && index == FIRST_ANSWER
55
+ multiplequestions_page? && index == FIRST_ANSWER
56
+ end
57
+
58
+ def last_multiple_question?(index, presenters_count_for_page)
59
+ multiplequestions_page? && index == presenters_count_for_page - 1
51
60
  end
52
61
 
53
62
  private
54
63
 
64
+ def multiplequestions_page?
65
+ page.type == 'page.multiplequestions'
66
+ end
67
+
55
68
  def date(value)
56
69
  I18n.l(
57
70
  Date.civil(value.year.to_i, value.month.to_i, value.day.to_i),
@@ -1,6 +1,6 @@
1
1
  <h2 class="govuk-visually-hidden">Support links</h2>
2
2
  <ul class="govuk-footer__inline-list">
3
- <% meta_items.each do |item| %>
3
+ <% service.meta.items.each do |item| %>
4
4
  <li class="govuk-footer__inline-list-item">
5
5
  <a class="govuk-footer__link" href=<%= File.join(request.script_name, item.href) %>><%= item.text %></a>
6
6
  </li>
@@ -2,8 +2,6 @@
2
2
  <div class="govuk-grid-row">
3
3
  <div class="govuk-grid-column-two-thirds">
4
4
 
5
- <%= render partial: 'metadata_presenter/attribute/section_heading' %>
6
-
7
5
  <h1 class="fb-editable govuk-heading-xl"
8
6
  data-fb-content-type="element"
9
7
  data-fb-content-id="page[heading]">
@@ -51,6 +49,11 @@
51
49
  <% end %>
52
50
  </dd>
53
51
  </div>
52
+
53
+ <% if page_answers_presenter.last_multiple_question?(index, page_answers_presenters.size) %>
54
+ </dl>
55
+ <dl class="fb-block fb-block-answers govuk-summary-list">
56
+ <% end %>
54
57
  <% end %>
55
58
  <% end %>
56
59
  </dl>
@@ -1,19 +1,23 @@
1
1
  Rails.application.config.page_components =
2
2
  ActiveSupport::HashWithIndifferentAccess.new({
3
3
  checkanswers: {
4
- input_components: %w(),
5
- content_components: %w(content)
4
+ input: %w(),
5
+ content: %w(content)
6
6
  },
7
7
  confirmation: {
8
- input_components: %w(),
9
- content_components: %w(content)
8
+ input: %w(),
9
+ content: %w(content)
10
10
  },
11
11
  content: {
12
- input_components: %w(),
13
- content_components: %w(content)
12
+ input: %w(),
13
+ content: %w(content)
14
14
  },
15
15
  multiplequestions: {
16
- input_components: %w(text textarea number date radios checkboxes),
17
- content_components: %w(content)
18
- }
16
+ input: %w(text textarea number date radios checkboxes),
17
+ content: %w(content)
18
+ },
19
+ singlequestion: {
20
+ input: %w(text textarea number date radios checkboxes),
21
+ content: %w()
22
+ }
19
23
  })
@@ -2,7 +2,7 @@
2
2
  "_id": "page.start",
3
3
  "_type": "page.start",
4
4
  "heading": "Service name goes here",
5
- "lede": "This is your start page first paragraph. You can only have one paragraph here.",
5
+ "lede": "",
6
6
  "body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
7
7
  "before_you_start": "###Before you start\r\nYou can also register by post.\r\n\r\nThe online service is also available in Welsh (Cymraeg).\r\n\r\nYou cannot register for this service if you’re in the UK illegally.",
8
8
  "steps": [],
@@ -280,6 +280,11 @@
280
280
  "required": true
281
281
  }
282
282
  },
283
+ {
284
+ "_id": "star-wars-knowledge_content_1",
285
+ "_type": "content",
286
+ "content": "Stay on target"
287
+ },
283
288
  {
284
289
  "_id": "star-wars-knowledge_radios_1",
285
290
  "_type": "radios",
@@ -340,12 +345,12 @@
340
345
  "_id": "page._check-answers",
341
346
  "_type": "page.checkanswers",
342
347
  "heading": "Review your answer",
343
- "section_heading": "This section is optional",
344
348
  "send_body": "By submitting this answer you confirm all your answers",
345
349
  "send_heading": "Send your answer",
346
350
  "url": "/check-answers",
347
351
  "components": [
348
352
  {
353
+ "_uuid": "256291c2-8ffa-4bda-8282-88e0724ccd10",
349
354
  "_id": "check-answers_content_1",
350
355
  "_type": "content",
351
356
  "content": "Check yourself before you wreck yourself."
@@ -353,6 +358,7 @@
353
358
  ],
354
359
  "extra_components": [
355
360
  {
361
+ "_uuid": "09961c6a-29f8-4d4f-a6d2-af00cff15536",
356
362
  "_id": "check-answers_content_1",
357
363
  "_type": "content",
358
364
  "content": "Take the cannoli."
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '0.28.6'.freeze
2
+ VERSION = '0.28.11'.freeze
3
3
  end
@@ -8,11 +8,6 @@
8
8
  "_type": {
9
9
  "const": "page.checkanswers"
10
10
  },
11
- "section_heading": {
12
- "title": "Section heading",
13
- "type": "string",
14
- "description": "Section to display before the heading"
15
- },
16
11
  "heading": {
17
12
  "type": "string",
18
13
  "default": "Check your answers"
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.28.6
4
+ version: 0.28.11
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-04-16 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder