quby-compiler 0.5.21 → 0.5.22
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/quby/compiler/outputs/quby_frontend_v2_serializer.rb +36 -1
- data/lib/quby/compiler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07f0d4268936ab1120ebb48d593645367e443a2b236f705de943599aa5e44847
|
4
|
+
data.tar.gz: e7462e8862d04e7b54badb52f833371aa304d42798c28c5da5edb4fe3d2be5f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f34d09ad62cbcf84a1749d014c651960409c0bde03a408be228f2940f7efb81c01c97bdeb7a82889d92c16aad637bdaf8cf7674a94bf513dd78454546ee15dc5
|
7
|
+
data.tar.gz: 3743a39d0850ee252b3c9d6fa32ef8d89c6ee88e69ffd1a280f39d49af97c5635943b47fec4bce53b0ab9920d408a790e780cb09907691b779254d1957893a01
|
data/CHANGELOG.md
CHANGED
@@ -27,13 +27,24 @@ module Quby
|
|
27
27
|
visibilityRules: visibility_rules.as_json,
|
28
28
|
sexpVariables: sexp_variables,
|
29
29
|
cssVars: css_vars,
|
30
|
-
}.compact
|
30
|
+
}.compact.tap do |json|
|
31
|
+
validate_all_questions_in_a_panel_question_keys(json)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# safeguard that question_keys_for_panel is considering all options.
|
36
|
+
def validate_all_questions_in_a_panel_question_keys(json)
|
37
|
+
missings = @questionnaire.question_hash.values.map(&:key) - json[:panels].flat_map{_1[:questionKeys]}
|
38
|
+
return if missings.empty?
|
39
|
+
|
40
|
+
raise "Not all questions are listed in a panel['questionKeys']: #{missings.join(",")}."
|
31
41
|
end
|
32
42
|
|
33
43
|
def panel(panel)
|
34
44
|
{
|
35
45
|
title: panel.title,
|
36
46
|
items: panel.items.map { panel_item(_1) }.compact,
|
47
|
+
questionKeys: question_keys_for_panel(panel) # added instead of calculated in js, so we can validate completeness.
|
37
48
|
}.compact
|
38
49
|
end
|
39
50
|
|
@@ -51,6 +62,30 @@ module Quby
|
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
65
|
+
def question_keys_for_panel(panel)
|
66
|
+
panel.items.flat_map do |item|
|
67
|
+
case item
|
68
|
+
when Quby::Compiler::Entities::Question
|
69
|
+
question_keys_for_question(item)
|
70
|
+
when Quby::Compiler::Entities::InfoBlock, Quby::Compiler::Entities::Table
|
71
|
+
item.items.flat_map do |nested_item|
|
72
|
+
next unless nested_item.is_a?(Quby::Compiler::Entities::Question)
|
73
|
+
question_keys_for_question(nested_item)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
[]
|
77
|
+
end
|
78
|
+
end.compact
|
79
|
+
end
|
80
|
+
|
81
|
+
def question_keys_for_question(question)
|
82
|
+
keys = [question.key]
|
83
|
+
keys << question.title_question.key if question.title_question
|
84
|
+
keys + question.options&.flat_map do |option|
|
85
|
+
option.questions&.map(&:key) # We only allow subquestions one level deep.
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
54
89
|
def info_block_item(info_block)
|
55
90
|
{
|
56
91
|
type: 'info',
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quby-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-06-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activemodel
|