quby-compiler 0.6.1 → 0.6.3
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 +13 -0
- data/lib/quby/compiler/dsl/info_block_builder.rb +7 -3
- data/lib/quby/compiler/dsl/panel_builder.rb +1 -1
- data/lib/quby/compiler/entities/info_block.rb +4 -2
- data/lib/quby/compiler/outputs/locale_serializer.rb +1 -1
- data/lib/quby/compiler/outputs/quby_frontend_v2_serializer.rb +4 -3
- data/lib/quby/compiler/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0db7cde28558a1299251282f5fa19fef2fd8ab3528b70779930d962737f96c8
|
|
4
|
+
data.tar.gz: 74e0a2075d664b251160e2ed98ecb937185ecbcafea38ba23a777422d30d6496
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e9fa3343bd33f58bad878747e0d690966dec5e4b6c50b4be6b928c46642c0c1eb2515ba1b012fe06d24c7ff3b4ccf5f043b7a425e82841dd2866713cfb26cb9e
|
|
7
|
+
data.tar.gz: 3449a3124f17da8e64f45b3b941d9768d1d4011360078a25ea9694647732aa2d4aa94f2786f1a6dfd81ae3a6745eaca3cd8f63af67ebb0d43d1f2a3c2178f664
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
# 0.6.3
|
|
2
|
+
|
|
3
|
+
* dsl + quby2.json: Add subtype to info_blocks.
|
|
4
|
+
|
|
5
|
+
# 0.6.2
|
|
6
|
+
|
|
7
|
+
* dsl:
|
|
8
|
+
* Add text option to info_blocks, so you can start with the key.
|
|
9
|
+
* Allow label for placeholder option.
|
|
10
|
+
* quby2.json
|
|
11
|
+
* Use . between panel/info_block key and default key for items, for more consistency. Remove double panel key for items with default key.
|
|
12
|
+
* Don't camelcase translation keys for quby2, no real benefit and was wrongly camelcasing html keys.
|
|
13
|
+
|
|
1
14
|
# 0.6.1
|
|
2
15
|
|
|
3
16
|
* Switch to oj for serializing, since JSON.serialize is dumb as ^%#$& (not serializing inner object)
|
|
@@ -11,8 +11,8 @@ module Quby
|
|
|
11
11
|
delegate :panel, to: :info_block
|
|
12
12
|
delegate :questionnaire, to: :panel
|
|
13
13
|
|
|
14
|
-
def initialize(key,
|
|
15
|
-
@info_block = Entities::InfoBlock.new(key: , panel:,
|
|
14
|
+
def initialize(key, panel:, default_question_options:, custom_methods:, **options)
|
|
15
|
+
@info_block = Entities::InfoBlock.new(key: , panel:, **options)
|
|
16
16
|
@default_question_options = default_question_options
|
|
17
17
|
@custom_methods = custom_methods
|
|
18
18
|
check_key_uniqueness(key, questionnaire:)
|
|
@@ -29,6 +29,10 @@ module Quby
|
|
|
29
29
|
info_block.items << Entities::Text.new('', html_content: value.to_s, key:)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
def text(key:, html: nil, md: nil, **options)
|
|
33
|
+
info_block.items << Entities::Text.new(key:, md:, html_content: html, **options)
|
|
34
|
+
end
|
|
35
|
+
|
|
32
36
|
def question(key, **options, &block)
|
|
33
37
|
options = default_question_options.merge(options).merge(questionnaire:)
|
|
34
38
|
|
|
@@ -53,7 +57,7 @@ module Quby
|
|
|
53
57
|
def fallback_key
|
|
54
58
|
raise "Item without key in #{info_block.key}" if questionnaire.translatable?
|
|
55
59
|
|
|
56
|
-
"#{info_block.key}
|
|
60
|
+
"#{info_block.key}.item_#{info_block.items.size}"
|
|
57
61
|
end
|
|
58
62
|
end
|
|
59
63
|
end
|
|
@@ -2,16 +2,18 @@ module Quby
|
|
|
2
2
|
module Compiler
|
|
3
3
|
module Entities
|
|
4
4
|
class InfoBlock < Item
|
|
5
|
-
attr_reader :key, :items, :start_open, :panel
|
|
5
|
+
attr_reader :key, :items, :start_open, :subtype, :panel
|
|
6
6
|
attr_accessor :html
|
|
7
7
|
|
|
8
8
|
validates :key, presence: true, 'quby/compiler/type': {is_a: Symbol}
|
|
9
9
|
validates :html, presence: true
|
|
10
|
+
validates :subtype, presence: true, inclusion: {in: ["info", "question-bar"]}
|
|
10
11
|
|
|
11
|
-
def initialize(key:, panel:, start_open: true)
|
|
12
|
+
def initialize(key:, panel:, start_open: true, subtype: "info")
|
|
12
13
|
@panel = panel
|
|
13
14
|
@key = key
|
|
14
15
|
@start_open = start_open
|
|
16
|
+
@subtype = subtype
|
|
15
17
|
@items = []
|
|
16
18
|
end
|
|
17
19
|
|
|
@@ -31,7 +31,7 @@ module Quby
|
|
|
31
31
|
items.flat_map { |item|
|
|
32
32
|
case item
|
|
33
33
|
when Quby::Compiler::Entities::Text
|
|
34
|
-
{ "#{
|
|
34
|
+
{ "#{item.key}" => item.html }
|
|
35
35
|
when Quby::Compiler::Entities::Question
|
|
36
36
|
questions_for_question(item).flat_map { |question|
|
|
37
37
|
question_locale_values(question, panel:)
|
|
@@ -97,6 +97,7 @@ module Quby
|
|
|
97
97
|
def info_block_item(info_block)
|
|
98
98
|
{
|
|
99
99
|
type: 'info',
|
|
100
|
+
subtype: info_block.subtype,
|
|
100
101
|
key: info_block.key,
|
|
101
102
|
html: handle_html(info_block.html, type: :prose, v1_markdown: false),
|
|
102
103
|
startOpen: info_block.start_open,
|
|
@@ -178,10 +179,11 @@ module Quby
|
|
|
178
179
|
end
|
|
179
180
|
|
|
180
181
|
def select_question(question)
|
|
182
|
+
placeholder = question.all_options.find(&:placeholder)
|
|
181
183
|
{
|
|
182
184
|
**base_question(question),
|
|
183
185
|
children: children(question),
|
|
184
|
-
placeholder:
|
|
186
|
+
placeholder: placeholder&.label || placeholder&.description,
|
|
185
187
|
}.compact
|
|
186
188
|
end
|
|
187
189
|
|
|
@@ -330,8 +332,7 @@ module Quby
|
|
|
330
332
|
key.ends_with?("context_free_title") \
|
|
331
333
|
|| key.ends_with?("context_free_description") \
|
|
332
334
|
|| key == "short_description"
|
|
333
|
-
}
|
|
334
|
-
.transform_keys! { |k| k.to_s.split('.').tap{ _1[-1] = _1[-1].camelize(:lower) }.join('.') }
|
|
335
|
+
}
|
|
335
336
|
}
|
|
336
337
|
end
|
|
337
338
|
|