metadata_presenter 3.3.12 → 3.3.14

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: 11d20716802ffbf7047c3957c4e75aac212bf07161dc5d9a7628d12d22beaacc
4
- data.tar.gz: 0bd0019535d81245f79c70c43b98cd1da6ae008a93ed3314e2263dd58e2ff4e7
3
+ metadata.gz: fce1f7719e73302d134f91f03ce4bfbd239e9303d1d2a08bc5594f9b9882585c
4
+ data.tar.gz: 5c15e0714aaa369a8898ba00d27f0199972bed43dfc6bffb99e6c0e8be35d0e9
5
5
  SHA512:
6
- metadata.gz: 0c610d9eee4512a7823d95f3257416bc5547c862cd763879d53c87d4f0269b377bac95bb41e0f1721e0c33cbc0fb63c3a396362476447cbb2bbd78c18ebdfe64
7
- data.tar.gz: 5818639f77709dc762fffc9ffd686424496b6d458266638ca7d9b8f29d4f8b344416a33385f00eca41721743d3a4215cefbd31f6134971a764faafc13565a722
6
+ metadata.gz: cfb93f873bdd5cd77e49819a924178b45c2a30e35c8dd6aab829011c058a49ca6a79aa3d94917f136e68c3274fa722b6c9864ee8f5ae759a957f40ac4c6dee95
7
+ data.tar.gz: 6c68732e6f9cbcac962ce1ef24847d317a041a3b0b48ebacc7589ddd4bfc419770d0fc049dd61427446f82e08d7baa29741538908538f54503afd9a2d21ec7ca
@@ -1,7 +1,13 @@
1
1
  module MetadataPresenter
2
2
  class DefaultText
3
- def self.[](property)
4
- Rails.application.config.default_text[property.to_s]
3
+ class << self
4
+ delegate :[], :fetch, to: :defaults
5
+
6
+ private
7
+
8
+ def defaults
9
+ Rails.application.config.default_text
10
+ end
5
11
  end
6
12
  end
7
13
  end
@@ -1,4 +1,6 @@
1
1
  class MetadataPresenter::Component < MetadataPresenter::Metadata
2
+ include Comparable
3
+
2
4
  VALIDATION_BUNDLES = {
3
5
  'date' => 'date',
4
6
  'number' => 'number',
@@ -11,6 +13,13 @@ class MetadataPresenter::Component < MetadataPresenter::Metadata
11
13
  # Threshold percentage at which the remaining count is shown
12
14
  VALIDATION_STRING_LENGTH_THRESHOLD = 75
13
15
 
16
+ def <=>(other)
17
+ return nil unless other.is_a?(MetadataPresenter::Component)
18
+ return 0 unless order
19
+
20
+ order <=> other.order
21
+ end
22
+
14
23
  # Overriding here because autocomplete component's items property is non interactable
15
24
  # in the Editor therefore it does not need to exist in the data-fb-content-data
16
25
  # attribute on the page. The data-fb-content-data attribute is what is used to
@@ -31,7 +31,7 @@ class MetadataPresenter::Metadata
31
31
 
32
32
  def method_missing(method_name, *args, &block)
33
33
  value = metadata.send(method_name, *args, &block)
34
- value.blank? && editor? ? MetadataPresenter::DefaultText[method_name] : value
34
+ value.blank? && editor? ? MetadataPresenter::DefaultText.fetch(method_name, value) : value
35
35
  end
36
36
 
37
37
  def ==(other)
@@ -181,12 +181,12 @@ module MetadataPresenter
181
181
  end
182
182
 
183
183
  def to_components(node_components, collection:)
184
- Array(node_components).map do |component|
184
+ Array(node_components).map { |component|
185
185
  MetadataPresenter::Component.new(
186
186
  component.merge(collection:),
187
187
  editor: editor?
188
188
  )
189
- end
189
+ }.sort
190
190
  end
191
191
 
192
192
  def supported_components(page_type)
@@ -2,4 +2,4 @@ Rails.application.config.default_text = JSON.parse(
2
2
  File.read(
3
3
  MetadataPresenter::Engine.root.join('default_text', 'content.json')
4
4
  )
5
- )
5
+ ).with_indifferent_access
@@ -425,7 +425,8 @@
425
425
  "collection": "components",
426
426
  "validation": {
427
427
  "required": true
428
- }
428
+ },
429
+ "order": 2
429
430
  },
430
431
  {
431
432
  "_id": "star-wars-knowledge_content_1",
@@ -433,7 +434,8 @@
433
434
  "_type": "content",
434
435
  "_uuid": "82444d3d-dab6-44c4-a147-e2650326c9eb",
435
436
  "content": "Stay on target",
436
- "collection": "components"
437
+ "collection": "components",
438
+ "order": 1
437
439
  },
438
440
  {
439
441
  "_id": "star-wars-knowledge_radios_1",
@@ -493,7 +495,8 @@
493
495
  "collection": "components",
494
496
  "validation": {
495
497
  "required": true
496
- }
498
+ },
499
+ "order": 0
497
500
  }
498
501
  ],
499
502
  "add_component": "radios",
@@ -528,7 +531,7 @@
528
531
  "heading": "Question",
529
532
  "components": [
530
533
  {
531
- "_id": "dog-picture_upload_1",
534
+ "_id": "dog-picture_upload_1",
532
535
  "name": "dog-picture_upload_1",
533
536
  "_type": "upload",
534
537
  "_uuid": "f056a76e-ec3f-47ae-b625-1bba92220ad1",
@@ -594,7 +597,7 @@
594
597
  "heading": "Multiupload",
595
598
  "components": [
596
599
  {
597
- "_id": "dog-picture_upload_2",
600
+ "_id": "dog-picture_upload_2",
598
601
  "name": "dog-picture_upload_2",
599
602
  "_type": "multiupload",
600
603
  "_uuid": "f056a76e-ec3f-47ae-b625-1bba92220ad2",
@@ -668,10 +671,8 @@
668
671
  "name": "countries_autocomplete_1",
669
672
  "_type": "autocomplete",
670
673
  "_uuid": "4dc23b9c-9757-4526-813d-b43efbe07dad",
671
- "items": [
672
- ],
673
- "errors": {
674
- },
674
+ "items": [],
675
+ "errors": {},
675
676
  "legend": "Countries",
676
677
  "validation": {
677
678
  "required": true,
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '3.3.12'.freeze
2
+ VERSION = '3.3.14'.freeze
3
3
  end
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: 3.3.12
4
+ version: 3.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoJ Forms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-07 00:00:00.000000000 Z
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder