metadata_presenter 0.28.5 → 0.28.10

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: 2a26379b45ed9982427ad0bc57cc742a632ad586731974f405aa8471c8d3f0cb
4
- data.tar.gz: 244f8e39ec507882de9c31aae45ea607f9e4093b3fb8f4705683f1a04caa9901
3
+ metadata.gz: ab52764aea2d132a57111ec99a9d7523362e8163a4d78a6254667c47cbb35f2a
4
+ data.tar.gz: bc5f21431c95fbd7ca139adb76376879eb712b31b360694ed98cf3941dfcb318
5
5
  SHA512:
6
- metadata.gz: 87dcb1e44ccbfa18cc3e1991a782c69dc58eb5e902ad9dbfd762a4f9a20654a8c8d80e6e108c22a413a7fbd4b6a4ff65bda0504e5a0ad02433f4f755d08b53d1
7
- data.tar.gz: a0bcb5182fc957f5d32836cdc98d53667ceac478dd394ba1ca8fba9a9c839a04681f23d749b53fc9b69b7546ef0258866910ce6bedec739b993a3eae4a3bab9d
6
+ metadata.gz: ebd89e1970ddaad3e8062c9c5e5815ac3095c3a1b0897645bcb5c307f95dd3a38f39fcf37ee2c405a6e954f8383cc1b339c74af6926b7d47f38094aa153e88dd
7
+ data.tar.gz: aaf3a97b00bd56921805985eb06a6dbbc9109281d7d96e6e9a7ae1924c967edaed4d0b8f7a6118a2128189bc4ca3f52648df7b72c634d2462e5c967d262f8fa7
@@ -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,21 +5,40 @@ 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
21
- metadata.components&.map do |component|
22
- MetadataPresenter::Component.new(component, editor: editor?)
30
+ to_components(metadata.components, collection: :components)
31
+ end
32
+
33
+ def extra_components
34
+ to_components(metadata.extra_components, collection: :extra_components)
35
+ end
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)
23
42
  end
24
43
  end
25
44
 
@@ -32,15 +51,24 @@ module MetadataPresenter
32
51
  end
33
52
 
34
53
  def input_components
35
- page_components(raw_type)[:input_components]
54
+ page_components(raw_type)[:input]
36
55
  end
37
56
 
38
57
  def content_components
39
- page_components(raw_type)[:content_components]
58
+ page_components(raw_type)[:content]
40
59
  end
41
60
 
42
61
  private
43
62
 
63
+ def to_components(node_components, collection:)
64
+ node_components&.map do |component|
65
+ MetadataPresenter::Component.new(
66
+ component.merge(collection: collection),
67
+ editor: editor?
68
+ )
69
+ end
70
+ end
71
+
44
72
  def page_components(page_type)
45
73
  values = Rails.application.config.page_components[page_type]
46
74
  if values.blank?
@@ -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,14 +1,14 @@
1
- <% @page.components.each_with_index do |component, index| %>
1
+ <% components.each_with_index do |component, index| %>
2
2
  <div class="fb-editable"
3
3
  id="<%= component.id %>"
4
4
  data-fb-content-type="<%= component.type %>"
5
- data-fb-content-id="<%= "page[components[#{index}]]" %>"
5
+ data-fb-content-id="<%= "page[#{component.collection}[#{index}]]" %>"
6
6
  data-fb-content-data="<%= component.to_json %>">
7
7
 
8
8
  <%= render partial: component, locals: {
9
9
  f: f,
10
10
  component: component,
11
- component_id: "page[components[#{index}]]",
11
+ component_id: "page[#{component.collection}[#{index}]]",
12
12
  input_title: main_title(
13
13
  component: component,
14
14
  tag: :h2,
@@ -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]">
@@ -44,13 +42,18 @@
44
42
  </dd>
45
43
  <dd class="govuk-summary-list__actions">
46
44
  <%= link_to(
47
- change_answer_path(url: page_answers_presenter.url),
45
+ editable? ? '#' : change_answer_path(url: page_answers_presenter.url),
48
46
  class: 'govuk-link'
49
47
  ) do %>
50
48
  Change<span class="govuk-visually-hidden"> Your answer for <%= page_answers_presenter.humanised_title %></span>
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": [],
@@ -340,18 +340,25 @@
340
340
  "_id": "page._check-answers",
341
341
  "_type": "page.checkanswers",
342
342
  "heading": "Review your answer",
343
- "section_heading": "This section is optional",
344
343
  "send_body": "By submitting this answer you confirm all your answers",
345
344
  "send_heading": "Send your answer",
346
345
  "url": "/check-answers",
347
346
  "components": [
348
347
  {
348
+ "_uuid": "256291c2-8ffa-4bda-8282-88e0724ccd10",
349
349
  "_id": "check-answers_content_1",
350
350
  "_type": "content",
351
351
  "content": "Check yourself before you wreck yourself."
352
352
  }
353
353
  ],
354
- "extra_components": []
354
+ "extra_components": [
355
+ {
356
+ "_uuid": "09961c6a-29f8-4d4f-a6d2-af00cff15536",
357
+ "_id": "check-answers_content_1",
358
+ "_type": "content",
359
+ "content": "Take the cannoli."
360
+ }
361
+ ]
355
362
  },
356
363
  {
357
364
  "_uuid": "b238a22f-c180-48d0-a7d9-8aad2036f1f2",
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '0.28.5'.freeze
2
+ VERSION = '0.28.10'.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.5
4
+ version: 0.28.10
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-15 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