quby-compiler 0.4.15 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/lib/quby/compiler/entities/question_option.rb +21 -5
- data/lib/quby/compiler/entities/questionnaire.rb +1 -1
- data/lib/quby/compiler/entities/questions/checkbox_question.rb +1 -1
- data/lib/quby/compiler/entities/questions/radio_question.rb +1 -1
- data/lib/quby/compiler/entities/questions/select_question.rb +4 -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: c114222ce815660bdbff3a284c6893b8dc809760818d1839193fec984a1027e3
|
4
|
+
data.tar.gz: 8b7938ae820807e963178a251313a3f6a237a3103e0d9aab92539eb5a534cd51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65bba6e155ee6722e836054f584c8df708c1ef9e8a87d9cb560d8020c8c16b3dadfb17b59da4ec0df128f9236f4ff20a69705af6f456c11204f8195a3cb01c36
|
7
|
+
data.tar.gz: b9f974a3ab3e6da317397726cad05b3913cc12f81b912ef928fcec50ed9b994196a7404e99f18754abcf4632fab19aad5656e354021ce3573d6735d1a42b1af5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# 0.5.0
|
2
|
+
|
3
|
+
* quby2.json BREAKING CHANGES!:
|
4
|
+
* Renamed: Questionnaire#fields to Questionnaire#questions
|
5
|
+
* Removed: Question#options
|
6
|
+
* Removed: Option#innerTitle and Option#placeholder
|
7
|
+
* Removed: Option#context_free_title
|
8
|
+
|
9
|
+
# 0.4.16
|
10
|
+
|
11
|
+
* quby2:
|
12
|
+
* Added children attribute to select questions to replace the options
|
13
|
+
* children can be of type option/html/placeholder
|
14
|
+
* Deprecate: Question#options
|
15
|
+
* Deprecate: Option#innerTitle moved to html type
|
16
|
+
* Deprecate: Option#placeholder moved to Question#placeholder attr
|
17
|
+
* Deprecate: Option#context_free_title, never needed
|
18
|
+
|
1
19
|
# 0.4.15
|
2
20
|
|
3
21
|
* quby2.json: Question#size is now always an integer/nil
|
@@ -12,12 +12,14 @@ module Quby
|
|
12
12
|
attr_reader :value
|
13
13
|
attr_reader :description, :context_free_description
|
14
14
|
attr_reader :questions
|
15
|
+
# for scale/radio/checbox questions, piece of of html that is rendered between the options
|
15
16
|
attr_reader :inner_title
|
16
17
|
validates :inner_title, inclusion: {in: [true, false, nil], message: "must be boolean"}
|
17
18
|
attr_reader :hides_questions
|
18
19
|
attr_reader :shows_questions
|
19
20
|
attr_reader :hidden
|
20
21
|
validates :hidden, inclusion: {in: [true, false], message: "must be boolean"}
|
22
|
+
# for select questions, option with no value and key is removed from answers if this one is selected.
|
21
23
|
attr_reader :placeholder
|
22
24
|
validates :placeholder, inclusion: {in: [true, false], message: "must be boolean"}
|
23
25
|
attr_reader :question
|
@@ -53,21 +55,35 @@ module Quby
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def as_json(options = {})
|
58
|
+
if inner_title
|
59
|
+
inner_title_as_json(options)
|
60
|
+
elsif placeholder
|
61
|
+
nil # placeholder attr on question.
|
62
|
+
else
|
63
|
+
option_as_json(options)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def inner_title_as_json(options = {})
|
68
|
+
{
|
69
|
+
type: 'html',
|
70
|
+
key: SecureRandom.uuid,
|
71
|
+
html: Quby::MarkdownParser.new(description).to_html
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def option_as_json(options = {})
|
56
76
|
{
|
77
|
+
type: 'option',
|
57
78
|
key: key,
|
58
79
|
value: value,
|
59
80
|
description: question.type == :select \
|
60
81
|
? description
|
61
82
|
: Quby::MarkdownParser.new(description).to_html,
|
62
|
-
context_free_description: question.type == :select \
|
63
|
-
? context_free_description
|
64
|
-
: Quby::MarkdownParser.new(context_free_description).to_html,
|
65
83
|
questions: questions,
|
66
|
-
innerTitle: inner_title,
|
67
84
|
hidesQuestions: hides_questions,
|
68
85
|
showsQuestions: shows_questions,
|
69
86
|
hidden: hidden,
|
70
|
-
placeholder: placeholder,
|
71
87
|
viewId: view_id
|
72
88
|
}
|
73
89
|
end
|
@@ -208,7 +208,7 @@ module Quby
|
|
208
208
|
outcomeDescription: outcome_description,
|
209
209
|
shortDescription: short_description,
|
210
210
|
panels: panels,
|
211
|
-
|
211
|
+
questions: fields.question_hash.as_json,
|
212
212
|
flags: flags,
|
213
213
|
textvars: textvars,
|
214
214
|
visibilityRules: visibility_rules
|
@@ -6,7 +6,10 @@ module Quby
|
|
6
6
|
module Questions
|
7
7
|
class SelectQuestion < Question
|
8
8
|
def as_json(options = {})
|
9
|
-
super.merge(
|
9
|
+
super.merge(
|
10
|
+
children: @options.as_json.compact, # for now just options, but we'll add optgroups later.
|
11
|
+
placeholder: @options.find { _1.placeholder }&.description # nil for no placeholder
|
12
|
+
)
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quby-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|