metadata_presenter 0.28.4 → 0.28.9

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: d8c3355ccba26202ee64d0089665f0bf382d09cd0c237fa20b1f5394ef6dd691
4
- data.tar.gz: db0912f8e400e359536011a3795dde504dc56929e6563871139c0b0f52271586
3
+ metadata.gz: f4d5dbea9a24b8fae69170d03e8ff69dafd77a0b858013baee1c8c1434fdcca1
4
+ data.tar.gz: 415da25856e17541de78ece98f8539471e33ae8417285630ef00a55152982999
5
5
  SHA512:
6
- metadata.gz: f284a1cecff3d56e80e78ccbc69ecc59b33a26b72b0721e152df1598fb855c96678d8f9f97baa9b3af2aab63c0255db65bf51b10a895fc78bed3c048c4482d75
7
- data.tar.gz: bc156761cd98fab2d8599bcaa9c5337cd41cec9713238f7cd82536f96e861b9880f3e159532d54b55d155adf41c2c991c99209f5a9b36ca7c5887ac217603c33
6
+ metadata.gz: 770aed14f9470f3d1f0af53e0411e3f190aa92268a031eb0cfd8af5aea8822e1b9aed8544db21d494cd897ac48f43676ae35a1ac7ce6fefd2a7fc96be59151d7
7
+ data.tar.gz: c64ee626011dd6027f48c6a98e86309efc8b8671d1f52cb7ead124650a7cb23d1d3c9850a49f6e3dace01297f7a94b5ee8111e8bd98b931cd8f7933f8885183a
@@ -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,22 +5,29 @@ 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) }
18
23
  end
19
24
 
20
25
  def components
21
- metadata.components&.map do |component|
22
- MetadataPresenter::Component.new(component, editor: editor?)
23
- end
26
+ to_components(metadata.components, collection: :components)
27
+ end
28
+
29
+ def extra_components
30
+ to_components(metadata.extra_components, collection: :extra_components)
24
31
  end
25
32
 
26
33
  def to_partial_path
@@ -41,6 +48,15 @@ module MetadataPresenter
41
48
 
42
49
  private
43
50
 
51
+ def to_components(node_components, collection:)
52
+ node_components&.map do |component|
53
+ MetadataPresenter::Component.new(
54
+ component.merge(collection: collection),
55
+ editor: editor?
56
+ )
57
+ end
58
+ end
59
+
44
60
  def page_components(page_type)
45
61
  values = Rails.application.config.page_components[page_type]
46
62
  if values.blank?
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html>
2
- <html>
2
+ <html lang="en">
3
3
  <head>
4
4
  <title><%= service.service_name %></title>
5
5
  <%= csrf_meta_tags %>
@@ -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,7 +42,7 @@
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>
@@ -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.4'.freeze
2
+ VERSION = '0.28.9'.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.4
4
+ version: 0.28.9
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-14 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder