quby-compiler 0.5.25 → 0.5.27
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 +10 -0
- data/lib/quby/compiler/dsl/questions/base.rb +30 -0
- data/lib/quby/compiler/dsl/questions/float_question_builder.rb +1 -0
- data/lib/quby/compiler/dsl/questions/integer_question_builder.rb +1 -0
- data/lib/quby/compiler/dsl/questions/radio_question_builder.rb +1 -0
- data/lib/quby/compiler/dsl/questions/select_question_builder.rb +1 -0
- data/lib/quby/compiler/entities/question.rb +2 -0
- data/lib/quby/compiler/entities/visibility_rule.rb +2 -0
- data/lib/quby/compiler/outputs/quby_frontend_v2_serializer.rb +9 -5
- data/lib/quby/compiler/outputs/roqua_serializer.rb +1 -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: a93d6d4ac13078651742bb23af84089fa529ac307fe1352e54bebd563d76b168
|
4
|
+
data.tar.gz: 4289ba8dd18fce9b9524442c47505be23026e2b9a5588281bba80feeafffe96c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4375702ad36d91113b3c1845e2689bef9f4da47c4de32d877c3f26f5c08268ecb8aaef851acd1b2cc7b22879a7845094b2a768caa26db8ab344058f086885474
|
7
|
+
data.tar.gz: c5464526e4bc0b4ccb0228e83179140477c72a5bc8fb1eae2ff6a12bad94af7e505afc60104e395d9a572cb45837b599b0d5767cc636671fac79a162f4c2afc2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 0.5.27
|
2
|
+
|
3
|
+
* roqua.json: put label in context_free description if present.
|
4
|
+
* quby2.json: write option#description to label when no label present. parse/sanitize label when not select.
|
5
|
+
|
6
|
+
# 0.5.26
|
7
|
+
|
8
|
+
* Quby2: Allow img tags
|
9
|
+
* Added numeric_compare visibility rule to questions
|
10
|
+
|
1
11
|
# 0.5.25
|
2
12
|
|
3
13
|
* Give info block a type in ruby (new validator expects it)
|
@@ -83,6 +83,36 @@ module Quby
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
module CompareVisibilityRule
|
87
|
+
def compare_value(op:, value:, show_questions: [], hide_questions: [])
|
88
|
+
raise "unknown op #{op} for #{@question.key}" unless %i[gt gteq lt lteq eq].include?(op)
|
89
|
+
condition = {
|
90
|
+
type: 'numeric_compare',
|
91
|
+
field_key: @question.key,
|
92
|
+
op:,
|
93
|
+
value:
|
94
|
+
}
|
95
|
+
show_questions.each do |show_key|
|
96
|
+
@question.visibility_rules << Entities::VisibilityRule.new(
|
97
|
+
condition:,
|
98
|
+
action: {
|
99
|
+
type: 'show_question',
|
100
|
+
field_key: show_key
|
101
|
+
}
|
102
|
+
)
|
103
|
+
end
|
104
|
+
hide_questions.each do |hide_key|
|
105
|
+
@question.visibility_rules << Entities::VisibilityRule.new(
|
106
|
+
condition:,
|
107
|
+
action: {
|
108
|
+
type: 'hide_question',
|
109
|
+
field_key: hide_key
|
110
|
+
}
|
111
|
+
)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
86
116
|
module Labeling
|
87
117
|
def label(value)
|
88
118
|
@question.labels << value
|
@@ -69,6 +69,7 @@ module Quby
|
|
69
69
|
|
70
70
|
# Structuring
|
71
71
|
attr_accessor :validations
|
72
|
+
attr_reader :visibility_rules # Quby2 only
|
72
73
|
attr_accessor :dependencies
|
73
74
|
|
74
75
|
# To display unit for number items
|
@@ -150,6 +151,7 @@ module Quby
|
|
150
151
|
@display_modes = options[:display_modes]
|
151
152
|
@presentation = options[:presentation]
|
152
153
|
@validations = []
|
154
|
+
@visibility_rules = []
|
153
155
|
@parent = options[:parent]
|
154
156
|
@hidden = options[:hidden]
|
155
157
|
@table = options[:table]
|
@@ -4,6 +4,8 @@ module Quby
|
|
4
4
|
class VisibilityRule
|
5
5
|
def self.from(question)
|
6
6
|
[].tap do |rules|
|
7
|
+
rules.concat question.visibility_rules
|
8
|
+
|
7
9
|
# Transform "default invisible" into just being hidden by itself,
|
8
10
|
# since any other question showing it will take precedence anyway.
|
9
11
|
if question.default_invisible
|
@@ -261,12 +261,16 @@ module Quby
|
|
261
261
|
end
|
262
262
|
|
263
263
|
def option_as_json(option)
|
264
|
+
label = option.label || option.description
|
265
|
+
label = handle_html(label) if option.question.type != :select
|
266
|
+
description = !option.label ? nil : option.description
|
267
|
+
description = handle_html(description) if option.question.type != :select
|
264
268
|
{
|
265
269
|
type: 'option',
|
266
270
|
key: option.key,
|
267
271
|
value: option.question.type != :check_box && option.value,
|
268
|
-
label
|
269
|
-
description
|
272
|
+
label:,
|
273
|
+
description:,
|
270
274
|
questions: option.question.type != :select && option.questions.map{ question(_1) },
|
271
275
|
hidden: option.hidden.presence,
|
272
276
|
viewId: option.view_id
|
@@ -331,11 +335,11 @@ module Quby
|
|
331
335
|
if layout_version == :v2
|
332
336
|
case type
|
333
337
|
when :simple
|
334
|
-
html_sanitizer.sanitize(html, tags: %w[strong em sup sub br span], attributes: %w[class])
|
338
|
+
html_sanitizer.sanitize(html, tags: %w[strong em sup sub br span img], attributes: %w[class src alt width height])
|
335
339
|
when :question_description
|
336
|
-
html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a], attributes: %w[class])
|
340
|
+
html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a img], attributes: %w[class href target src alt width height])
|
337
341
|
when :prose
|
338
|
-
html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a h1 h2 h3 h4 hr], attributes: %w[href class target])
|
342
|
+
html_sanitizer.sanitize(html, tags: %w[strong em b i u sup sub pre blockquote p span br ul ol li a img h1 h2 h3 h4 hr], attributes: %w[href class target src alt width height])
|
339
343
|
end
|
340
344
|
elsif v1_markdown
|
341
345
|
Quby::Compiler::MarkdownParser.new(html).to_html
|
@@ -244,7 +244,7 @@ module Quby
|
|
244
244
|
{
|
245
245
|
key: option.key,
|
246
246
|
value: (option.value.to_s unless question.type == :check_box),
|
247
|
-
description: option.context_free_description || parse_markdown_and_strip_tags(option.description),
|
247
|
+
description: option.context_free_description || parse_markdown_and_strip_tags(option.label || option.description),
|
248
248
|
child_question_keys: option.questions.map(&:key).presence,
|
249
249
|
unchecks_all_others: question.try(:uncheck_all_option) && question.uncheck_all_option == option.key
|
250
250
|
}.compact
|
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.27
|
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-08-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activemodel
|