decidim-forms 0.23.1.rc1 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/forms/display_conditions.component.js.es6 +5 -6
- data/app/forms/decidim/forms/answer_form.rb +1 -1
- data/app/forms/decidim/forms/questionnaire_form.rb +5 -0
- data/app/models/decidim/forms/display_condition.rb +22 -8
- data/lib/decidim/forms/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00b6fa084292af8d4b343f801ccc5725a7983e3390b41dcd00f2b84b34afc914
|
4
|
+
data.tar.gz: 9f037814dca4fd315e6425074dc2d8c42f8c144d1bb8c5042897dd8ab5410bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc48b056500a941f30b72dd044e9614008b8a0e84111e10af937ce00bab58d13a2e8938a4fa7a8dea9660dbb6c00ffc5b897330f42a9f73a2203edd5c86dd6d9
|
7
|
+
data.tar.gz: a0dbe8818ba0efbe2d7d8b1f9503c5b07cde7023437d81ab5ee1c1695a16631d26e054cc8dd072460c97c652101ef34ef5489e6bfb596cc6376d58f3e53fd184
|
@@ -29,14 +29,13 @@
|
|
29
29
|
let multipleInput = [];
|
30
30
|
|
31
31
|
$conditionWrapperField.find(".radio-button-collection, .check-box-collection").find(".collection-input").each((idx, el) => {
|
32
|
-
const $
|
33
|
-
const checked =
|
32
|
+
const $input = $(el).find("input[name$=\\[body\\]]");
|
33
|
+
const checked = $input.is(":checked");
|
34
34
|
|
35
35
|
if (checked) {
|
36
|
-
const
|
37
|
-
const
|
38
|
-
const
|
39
|
-
const id = $label.find("input[type='hidden']").val();
|
36
|
+
const text = $(el).find("input[name$=\\[custom_body\\]]").val();
|
37
|
+
const value = $input.val();
|
38
|
+
const id = $(el).find("input[name$=\\[answer_option_id\\]]").val();
|
40
39
|
|
41
40
|
multipleInput.push({ id, value, text });
|
42
41
|
}
|
@@ -51,7 +51,7 @@ module Decidim
|
|
51
51
|
|
52
52
|
def display_conditions_fulfilled?
|
53
53
|
question.display_conditions.all? do |condition|
|
54
|
-
answer =
|
54
|
+
answer = context.responses&.find { |r| r.question_id&.to_i == condition.condition_question.id }
|
55
55
|
condition.fulfilled?(answer)
|
56
56
|
end
|
57
57
|
end
|
@@ -23,6 +23,11 @@ module Decidim
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# Add other responses to the context so AnswerForm can validate conditional questions
|
27
|
+
def before_validation
|
28
|
+
context.responses = attributes[:responses]
|
29
|
+
end
|
30
|
+
|
26
31
|
# Public: Splits reponses by step, keeping the separator.
|
27
32
|
#
|
28
33
|
# Returns an array of steps. Each step is a list of the questions in that
|
@@ -21,18 +21,19 @@ module Decidim
|
|
21
21
|
# Answer option provided to check for "equal" or "not_equal" (optional)
|
22
22
|
belongs_to :answer_option, class_name: "AnswerOption", foreign_key: "decidim_answer_option_id", optional: true
|
23
23
|
|
24
|
-
def fulfilled?(
|
24
|
+
def fulfilled?(answer_form)
|
25
|
+
return answer_form.present? if condition_type == "answered"
|
26
|
+
return answer_form.blank? if condition_type == "not_answered"
|
27
|
+
# rest of options require presence
|
28
|
+
return if answer_form.blank?
|
29
|
+
|
25
30
|
case condition_type
|
26
|
-
when "answered"
|
27
|
-
answer.present?
|
28
|
-
when "not_answered"
|
29
|
-
answer.blank?
|
30
31
|
when "equal"
|
31
|
-
|
32
|
+
answer_form.choices.pluck(:answer_option_id).include?(answer_option.id)
|
32
33
|
when "not_equal"
|
33
|
-
|
34
|
+
answer_form.choices.pluck(:answer_option_id).exclude?(answer_option.id)
|
34
35
|
when "match"
|
35
|
-
|
36
|
+
condition_value.values.reject(&:blank?).any? { |value| answer_form_matches?(answer_form, value) }
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
@@ -46,6 +47,19 @@ module Decidim
|
|
46
47
|
value: condition_value&.dig(I18n.locale.to_s)
|
47
48
|
}.compact
|
48
49
|
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def answer_form_matches?(answer_form, value)
|
54
|
+
search = Regexp.new(value, Regexp::IGNORECASE)
|
55
|
+
if answer_form.body
|
56
|
+
answer_form.body.match?(search)
|
57
|
+
else
|
58
|
+
answer_form.choices.any? do |choice_value|
|
59
|
+
choice_value.body&.match?(search) || choice_value.custom_body&.match?(search)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
49
63
|
end
|
50
64
|
end
|
51
65
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.1
|
4
|
+
version: 0.23.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-11-
|
14
|
+
date: 2020-11-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: decidim-core
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.23.1
|
22
|
+
version: 0.23.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.23.1
|
29
|
+
version: 0.23.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: wicked_pdf
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,28 +61,28 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - '='
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.23.1
|
64
|
+
version: 0.23.1
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - '='
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.23.1
|
71
|
+
version: 0.23.1
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: decidim-dev
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - '='
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 0.23.1
|
78
|
+
version: 0.23.1
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - '='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.23.1
|
85
|
+
version: 0.23.1
|
86
86
|
description: A forms gem for decidim.
|
87
87
|
email:
|
88
88
|
- josepjaume@gmail.com
|
@@ -296,9 +296,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
296
296
|
version: '2.6'
|
297
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
298
|
requirements:
|
299
|
-
- - "
|
299
|
+
- - ">="
|
300
300
|
- !ruby/object:Gem::Version
|
301
|
-
version:
|
301
|
+
version: '0'
|
302
302
|
requirements: []
|
303
303
|
rubygems_version: 3.0.3
|
304
304
|
signing_key:
|