metadata_presenter 2.1.1 → 2.3.2

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: 406a99897f2deb6565befd01bdc1fd12f67b3bf9cb71e77fc36b8ab3550c3e31
4
- data.tar.gz: c2b1e8bdbc48df0357c1f0107f4a619e96bedf17dd110322f43b38e93239685a
3
+ metadata.gz: a37e17a557bd814c79d294f394f8d2d7a4013b12bbd113f7c3f050c4854bb8b1
4
+ data.tar.gz: eed17391e7ffbcd4a42bc5763cf32f34946f592a2d907fb8356e6f52fd832267
5
5
  SHA512:
6
- metadata.gz: 7b80e8327eac16728d8c918f5f32d87a56e4cb506ccd043cfa13e48819ded49da44ec6782e9460872239e7bb7443975dc5a7f1aa36a9d34100a71fa08b3b1d03
7
- data.tar.gz: dfaf82d1c09c14edaf1e11b382401ef9394fc35686b9e53875263a43516ad6b1735e30d3dcd9201c18e189956898da4b3c1286ccb170369a1db3b7c43609a7cf
6
+ metadata.gz: 6f35bbefeff65553c2d32efa3ec0f831765e0776291246d6c2208de59e35886973a2db126ff059e5c4862d5ec50fb19807e4e0e6ba5d725f64996b0cbccd9367
7
+ data.tar.gz: 78985c06bdc8d187c25cdc459f0db742e80bb236520b326579224b8f31a6be474b3d2b3125e0a0fb391bdec4f3d40f19206e4b1b4dfc00368d7348dd6b988a02
@@ -1,5 +1,13 @@
1
1
  module MetadataPresenter
2
2
  class Flow < MetadataPresenter::Metadata
3
+ attr_reader :uuid
4
+
5
+ def initialize(uuid, flow)
6
+ @uuid = uuid
7
+
8
+ super(flow)
9
+ end
10
+
3
11
  def branch?
4
12
  type == 'flow.branch'
5
13
  end
@@ -12,6 +12,7 @@ module MetadataPresenter
12
12
  add_component
13
13
  add_extra_component
14
14
  ].freeze
15
+ QUESTION_PAGES = %w[page.singlequestion page.multiplequestions].freeze
15
16
 
16
17
  def editable_attributes
17
18
  to_h.reject { |k, _| k.in?(NOT_EDITABLE) }
@@ -33,11 +34,19 @@ module MetadataPresenter
33
34
  to_components(metadata.extra_components, collection: :extra_components)
34
35
  end
35
36
 
36
- def components_by_type(type)
37
- supported_components = page_components(raw_type)[type]
37
+ def input_components
38
+ all_components.reject(&:content?)
39
+ end
40
+
41
+ def content_components
42
+ all_components.select(&:content?)
43
+ end
44
+
45
+ def supported_components_by_type(type)
46
+ supported = supported_components(raw_type)[type]
38
47
 
39
48
  all_components.select do |component|
40
- supported_components.include?(component.type)
49
+ supported.include?(component.type)
41
50
  end
42
51
  end
43
52
 
@@ -49,12 +58,12 @@ module MetadataPresenter
49
58
  "metadata_presenter/#{type.gsub('.', '/')}"
50
59
  end
51
60
 
52
- def input_components
53
- page_components(raw_type)[:input]
61
+ def supported_input_components
62
+ supported_components(raw_type)[:input]
54
63
  end
55
64
 
56
- def content_components
57
- page_components(raw_type)[:content]
65
+ def supported_content_components
66
+ supported_components(raw_type)[:content]
58
67
  end
59
68
 
60
69
  def upload_components
@@ -65,6 +74,10 @@ module MetadataPresenter
65
74
  type == 'page.standalone'
66
75
  end
67
76
 
77
+ def question_page?
78
+ type.in?(QUESTION_PAGES)
79
+ end
80
+
68
81
  def title
69
82
  return heading if heading?
70
83
 
@@ -87,10 +100,10 @@ module MetadataPresenter
87
100
  end
88
101
  end
89
102
 
90
- def page_components(page_type)
91
- values = Rails.application.config.page_components[page_type]
103
+ def supported_components(page_type)
104
+ values = Rails.application.config.supported_components[page_type]
92
105
  if values.blank?
93
- raise PageComponentsNotDefinedError, "No page components defined for #{page_type} in config initialiser"
106
+ raise PageComponentsNotDefinedError, "No supported components defined for #{page_type} in config initialiser"
94
107
  end
95
108
 
96
109
  values
@@ -5,8 +5,16 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
5
5
  end
6
6
  end
7
7
 
8
+ def flow_objects
9
+ flow.map { |uuid, flow| MetadataPresenter::Flow.new(uuid, flow) }
10
+ end
11
+
12
+ def branches
13
+ flow_objects.select { |flow| flow.type == 'flow.branch' }
14
+ end
15
+
8
16
  def flow_object(uuid)
9
- MetadataPresenter::Flow.new(metadata.flow[uuid])
17
+ MetadataPresenter::Flow.new(uuid, metadata.flow[uuid])
10
18
  rescue StandardError
11
19
  nil
12
20
  end
@@ -10,7 +10,7 @@ module MetadataPresenter
10
10
 
11
11
  def self.map(view:, pages:, answers:)
12
12
  user_input_pages(pages).map { |page|
13
- Array(page.components_by_type(:input)).map do |component|
13
+ Array(page.supported_components_by_type(:input)).map do |component|
14
14
  new(
15
15
  view: view,
16
16
  component: component,
@@ -16,8 +16,8 @@
16
16
  components: @page.extra_components,
17
17
  tag: nil,
18
18
  classes: nil,
19
- input_components: @page.input_components,
20
- content_components: @page.content_components
19
+ input_components: @page.supported_input_components,
20
+ content_components: @page.supported_content_components
21
21
  } %>
22
22
 
23
23
  <dl class="fb-block fb-block-answers govuk-summary-list">
@@ -80,8 +80,8 @@
80
80
  components: @page.components,
81
81
  tag: nil,
82
82
  classes: nil,
83
- input_components: @page.input_components,
84
- content_components: @page.content_components
83
+ input_components: @page.supported_input_components,
84
+ content_components: @page.supported_content_components
85
85
  } %>
86
86
 
87
87
  <button <%= 'disabled' if editable? %> data-prevent-double-click="true" class="fb-block fb-block-actions govuk-button" data-module="govuk-button" data-block-id="actions" data-block-type="actions">
@@ -29,7 +29,7 @@
29
29
  components: @page.components,
30
30
  tag: nil,
31
31
  classes: nil,
32
- input_components: @page.input_components,
33
- content_components: @page.content_components
32
+ input_components: @page.supported_input_components,
33
+ content_components: @page.supported_content_components
34
34
  } %>
35
35
  </div>
@@ -21,8 +21,8 @@
21
21
  components: @page.components,
22
22
  tag: nil,
23
23
  classes: nil,
24
- input_components: @page.input_components,
25
- content_components: @page.content_components
24
+ input_components: @page.supported_input_components,
25
+ content_components: @page.supported_content_components
26
26
  } %>
27
27
 
28
28
  <%= f.govuk_submit(disabled: editable?) %>
@@ -13,8 +13,8 @@
13
13
  components: @page.components,
14
14
  tag: :h2,
15
15
  classes: 'govuk-heading-m govuk-!-margin-top-8',
16
- input_components: @page.input_components,
17
- content_components: @page.content_components
16
+ input_components: @page.supported_input_components,
17
+ content_components: @page.supported_content_components
18
18
  }
19
19
  %>
20
20
 
@@ -3,7 +3,6 @@
3
3
  <div class="govuk-grid-column-two-thirds">
4
4
 
5
5
  <%= render 'metadata_presenter/attribute/heading' %>
6
- <%= render 'metadata_presenter/attribute/lede' %>
7
6
  <%= render 'metadata_presenter/attribute/body' %>
8
7
 
9
8
  <%= form_tag(root_path, method: :post) do %>
@@ -1,4 +1,4 @@
1
- Rails.application.config.page_components =
1
+ Rails.application.config.supported_components =
2
2
  ActiveSupport::HashWithIndifferentAccess.new({
3
3
  checkanswers: {
4
4
  input: %w(),
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "_type": "flow.branch",
3
+ "title": "",
3
4
  "next": {
4
5
  "default": "",
5
6
  "conditionals": []
@@ -2,7 +2,6 @@
2
2
  "_id": "page.start",
3
3
  "_type": "page.start",
4
4
  "heading": "Service name goes here",
5
- "lede": "",
6
5
  "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
6
  "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
7
  "url": "/"
@@ -364,7 +364,6 @@
364
364
  "_id": "page.start",
365
365
  "url": "/",
366
366
  "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.",
367
- "lede": "",
368
367
  "_type": "page.start",
369
368
  "_uuid": "cf6dc32f-502c-4215-8c27-1151a45735bb",
370
369
  "heading": "Service name goes here",
@@ -92,7 +92,6 @@
92
92
  "_id": "page.start",
93
93
  "url": "/",
94
94
  "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.",
95
- "lede": "",
96
95
  "_type": "page.start",
97
96
  "_uuid": "cf6dc32f-502c-4215-8c27-1151a45735bb",
98
97
  "heading": "Service name goes here",
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.3.2'.freeze
3
3
  end
@@ -9,6 +9,9 @@
9
9
  "type": "string",
10
10
  "const": "flow.branch"
11
11
  },
12
+ "title": {
13
+ "type": "string"
14
+ },
12
15
  "next": {
13
16
  "type": "object",
14
17
  "properties": {
@@ -28,7 +28,6 @@
28
28
  ],
29
29
  "ui_category": {
30
30
  "main": [
31
- "lede",
32
31
  "body",
33
32
  "before_you_start"
34
33
  ]
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: 2.1.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
- - MoJ Online
7
+ - MoJ Forms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder
@@ -254,9 +254,9 @@ dependencies:
254
254
  - - ">="
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
- description: Service Metadata Presenter for the Form Builder product
257
+ description: Service Metadata Presenter for the MoJ Forms product
258
258
  email:
259
- - moj-online@digital.justice.gov.uk
259
+ - moj-forms@digital.justice.gov.uk
260
260
  executables: []
261
261
  extensions: []
262
262
  extra_rdoc_files: []
@@ -343,8 +343,8 @@ files:
343
343
  - config/initializers/default_metadata.rb
344
344
  - config/initializers/default_text.rb
345
345
  - config/initializers/inflections.rb
346
- - config/initializers/page_components.rb
347
346
  - config/initializers/schemas.rb
347
+ - config/initializers/supported_components.rb
348
348
  - config/routes.rb
349
349
  - default_metadata/component/checkboxes.json
350
350
  - default_metadata/component/content.json
@@ -453,7 +453,7 @@ files:
453
453
  - schemas/service/configuration.json
454
454
  - schemas/service/locale.json
455
455
  - schemas/validations/validations.json
456
- homepage: https://moj-online.service.justice.gov.uk
456
+ homepage: https://moj-forms.service.justice.gov.uk/
457
457
  licenses:
458
458
  - MIT
459
459
  metadata: {}