decidim-forms 0.25.1 → 0.26.0
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/app/commands/decidim/forms/answer_questionnaire.rb +6 -2
- data/app/forms/decidim/forms/admin/question_form.rb +4 -0
- data/app/models/decidim/forms/answer.rb +1 -0
- data/app/models/decidim/forms/question.rb +7 -1
- data/app/packs/src/decidim/forms/admin/forms.js +2 -0
- data/app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb +19 -4
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +5 -2
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +4 -1
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +12 -0
- data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +80 -0
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +10 -1
- data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +8 -7
- data/config/locales/ca.yml +11 -0
- data/config/locales/cs.yml +11 -0
- data/config/locales/en.yml +11 -0
- data/config/locales/es-MX.yml +11 -0
- data/config/locales/es-PY.yml +11 -0
- data/config/locales/es.yml +11 -0
- data/config/locales/fi-plain.yml +11 -0
- data/config/locales/fi.yml +11 -0
- data/config/locales/fr-CA.yml +11 -0
- data/config/locales/fr.yml +12 -1
- data/config/locales/gl.yml +11 -0
- data/config/locales/hu.yml +11 -0
- data/config/locales/ja.yml +12 -1
- data/config/locales/lb-LU.yml +103 -0
- data/config/locales/nl.yml +11 -0
- data/config/locales/no.yml +52 -0
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/ro-RO.yml +69 -58
- data/config/locales/sv.yml +12 -0
- data/config/locales/val-ES.yml +18 -0
- data/lib/decidim/forms/test/factories.rb +12 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +18 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +36 -5
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +98 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +8 -0
- data/lib/decidim/forms/user_answers_serializer.rb +7 -1
- data/lib/decidim/forms/version.rb +1 -1
- metadata +15 -12
data/config/locales/sv.yml
CHANGED
@@ -79,6 +79,7 @@ sv:
|
|
79
79
|
form:
|
80
80
|
add_question: Lägg till fråga
|
81
81
|
add_separator: Lägg till separator
|
82
|
+
add_title_and_description: Lägg till titel och beskrivning
|
82
83
|
already_answered_warning: Frågeformuläret har redan besvarats av vissa användare så du inte kan ändra dess frågor.
|
83
84
|
collapse: Komprimera alla frågor
|
84
85
|
expand: Expandera alla frågor
|
@@ -108,8 +109,18 @@ sv:
|
|
108
109
|
remove: Radera
|
109
110
|
separator: Avgränsare
|
110
111
|
up: Upp
|
112
|
+
title_and_description:
|
113
|
+
collapse: Kollapsa
|
114
|
+
description: Beskrivning
|
115
|
+
down: Ner
|
116
|
+
expand: Expandera
|
117
|
+
remove: Ta bort
|
118
|
+
title: Titel
|
119
|
+
title_and_description: Titel och beskrivning
|
120
|
+
up: Upp
|
111
121
|
update:
|
112
122
|
invalid: Det gick inte att spara formuläret.
|
123
|
+
success: Formuläret har sparats.
|
113
124
|
errors:
|
114
125
|
answer:
|
115
126
|
body: Kroppen kan inte vara to
|
@@ -130,6 +141,7 @@ sv:
|
|
130
141
|
short_answer: Kort svar
|
131
142
|
single_option: Ett alternativ
|
132
143
|
sorting: Sortering
|
144
|
+
title_and_description: Titel och beskrivning
|
133
145
|
questionnaires:
|
134
146
|
answer:
|
135
147
|
invalid: Det gick inte att besvara formuläret.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
val:
|
2
|
+
decidim:
|
3
|
+
forms:
|
4
|
+
admin:
|
5
|
+
questionnaires:
|
6
|
+
form:
|
7
|
+
add_title_and_description: Afig títol i descripció
|
8
|
+
title_and_description:
|
9
|
+
collapse: Redueix
|
10
|
+
description: Descripció
|
11
|
+
down: Baixar
|
12
|
+
expand: Expandeix
|
13
|
+
remove: Elimina
|
14
|
+
title: Títol
|
15
|
+
title_and_description: Títol i descripció
|
16
|
+
up: Pujar
|
17
|
+
question_types:
|
18
|
+
title_and_description: Títol i descripció
|
@@ -123,6 +123,10 @@ FactoryBot.define do
|
|
123
123
|
trait :separator do
|
124
124
|
question_type { :separator }
|
125
125
|
end
|
126
|
+
|
127
|
+
trait :title_and_description do
|
128
|
+
question_type { :title_and_description }
|
129
|
+
end
|
126
130
|
end
|
127
131
|
|
128
132
|
factory :answer, class: "Decidim::Forms::Answer" do
|
@@ -144,6 +148,14 @@ FactoryBot.define do
|
|
144
148
|
question { create(:questionnaire_question) }
|
145
149
|
body { generate_localized_title }
|
146
150
|
free_text { false }
|
151
|
+
|
152
|
+
trait :free_text_enabled do
|
153
|
+
free_text { true }
|
154
|
+
end
|
155
|
+
|
156
|
+
trait :free_text_disabled do
|
157
|
+
free_text { false }
|
158
|
+
end
|
147
159
|
end
|
148
160
|
|
149
161
|
factory :answer_choice, class: "Decidim::Forms::AnswerChoice" do
|
@@ -69,6 +69,24 @@ shared_examples_for "manage questionnaire answers" do
|
|
69
69
|
expect(page).to have_content("User identifier")
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
context "when multiple answer choice" do
|
74
|
+
let(:first_type) { "multiple_option" }
|
75
|
+
let!(:answer1) { create :answer, questionnaire: questionnaire, question: first, body: nil }
|
76
|
+
let!(:answer_option) { create :answer_option, question: first }
|
77
|
+
let!(:answer_choice) { create :answer_choice, answer: answer1, answer_option: answer_option, body: translated(answer_option.body, locale: I18n.locale) }
|
78
|
+
|
79
|
+
before do
|
80
|
+
find_all("a.action-icon.action-icon--eye").first.click
|
81
|
+
end
|
82
|
+
|
83
|
+
it "shows the answers page with custom body" do
|
84
|
+
within "#answers" do
|
85
|
+
expect(page).to have_css("dt", text: translated(first.body))
|
86
|
+
expect(page).to have_css("li", text: translated(answer_option.body))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
72
90
|
end
|
73
91
|
|
74
92
|
context "and managing individual answer page" do
|
@@ -4,20 +4,21 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
shared_examples_for "add questions" do
|
6
6
|
it "adds a few questions and separators to the questionnaire" do
|
7
|
-
|
7
|
+
fields_body = ["This is the first question", "This is the second question", "This is the first title and description"]
|
8
8
|
|
9
9
|
within "form.edit_questionnaire" do
|
10
10
|
click_button "Add question"
|
11
11
|
click_button "Add separator"
|
12
|
+
click_button "Add title and description"
|
12
13
|
click_button "Add question"
|
13
14
|
|
14
|
-
expect(page).to have_selector(".questionnaire-question", count:
|
15
|
+
expect(page).to have_selector(".questionnaire-question", count: 4)
|
15
16
|
|
16
17
|
expand_all_questions
|
17
18
|
|
18
|
-
page.all(".questionnaire-question .collapsible").each_with_index do |
|
19
|
-
within
|
20
|
-
fill_in find_nested_form_field_locator("body_en"), with:
|
19
|
+
page.all(".questionnaire-question .collapsible").each_with_index do |field, idx|
|
20
|
+
within field do
|
21
|
+
fill_in find_nested_form_field_locator("body_en"), with: fields_body[idx]
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -30,6 +31,7 @@ shared_examples_for "add questions" do
|
|
30
31
|
|
31
32
|
expect(page).to have_selector("input[value='This is the first question']")
|
32
33
|
expect(page).to have_selector("input[value='This is the second question']")
|
34
|
+
expect(page).to have_selector("input[value='This is the first title and description']")
|
33
35
|
expect(page).to have_content("Separator #2")
|
34
36
|
end
|
35
37
|
|
@@ -62,6 +64,35 @@ shared_examples_for "add questions" do
|
|
62
64
|
expect(page).to have_selector("strong", text: "Superkalifragilistic description")
|
63
65
|
end
|
64
66
|
|
67
|
+
it "adds a title-and-description" do
|
68
|
+
within "form.edit_questionnaire" do
|
69
|
+
click_button "Add title and description"
|
70
|
+
expand_all_questions
|
71
|
+
|
72
|
+
within ".questionnaire-question" do
|
73
|
+
fill_in find_nested_form_field_locator("body_en"), with: "Body"
|
74
|
+
|
75
|
+
fill_in_editor find_nested_form_field_locator("description_en", visible: false), with: "<strong>Superkalifragilistic description</strong>"
|
76
|
+
end
|
77
|
+
|
78
|
+
click_button "Save"
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(page).to have_admin_callout("successfully")
|
82
|
+
|
83
|
+
component.update!(
|
84
|
+
step_settings: {
|
85
|
+
component.participatory_space.active_step.id => {
|
86
|
+
allow_answers: true
|
87
|
+
}
|
88
|
+
}
|
89
|
+
)
|
90
|
+
|
91
|
+
visit questionnaire_public_path
|
92
|
+
|
93
|
+
expect(page).to have_selector("strong", text: "Superkalifragilistic description")
|
94
|
+
end
|
95
|
+
|
65
96
|
it "adds a question with answer options" do
|
66
97
|
question_body = ["This is the first question", "This is the second question"]
|
67
98
|
answer_options_body = [
|
@@ -118,6 +118,104 @@ shared_examples_for "update questions" do
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
context "when a questionnaire has a title and description" do
|
122
|
+
let!(:question) { create(:questionnaire_question, :title_and_description, questionnaire: questionnaire, body: title_and_description_body) }
|
123
|
+
|
124
|
+
before do
|
125
|
+
visit questionnaire_edit_path
|
126
|
+
expand_all_questions
|
127
|
+
end
|
128
|
+
|
129
|
+
it "modifies the question when the information is valid" do
|
130
|
+
within "form.edit_questionnaire" do
|
131
|
+
within ".questionnaire-question" do
|
132
|
+
fill_in "questionnaire_questions_#{question.id}_body_en", with: "Modified title and description"
|
133
|
+
end
|
134
|
+
|
135
|
+
click_button "Save"
|
136
|
+
end
|
137
|
+
|
138
|
+
expect(page).to have_admin_callout("successfully")
|
139
|
+
|
140
|
+
visit_questionnaire_edit_path_and_expand_all
|
141
|
+
|
142
|
+
expect(page).to have_selector("input[value='Modified title and description']")
|
143
|
+
expect(page).to have_no_selector("input[value='This is the first title and description']")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "re-renders the form when the information is invalid and displays errors" do
|
147
|
+
expand_all_questions
|
148
|
+
|
149
|
+
within "form.edit_questionnaire" do
|
150
|
+
within ".questionnaire-question" do
|
151
|
+
fill_in "questionnaire_questions_#{question.id}_body_en", with: ""
|
152
|
+
end
|
153
|
+
|
154
|
+
click_button "Save"
|
155
|
+
end
|
156
|
+
|
157
|
+
expand_all_questions
|
158
|
+
|
159
|
+
expect(page).to have_admin_callout("There was a problem saving")
|
160
|
+
expect(page).to have_content("can't be blank", count: 1)
|
161
|
+
expect(page).to have_selector("input[value='']")
|
162
|
+
expect(page).to have_no_selector("input[value='This is the first title and description']")
|
163
|
+
end
|
164
|
+
|
165
|
+
it "preserves deleted status across submission failures" do
|
166
|
+
within "form.edit_questionnaire" do
|
167
|
+
within ".questionnaire-question" do
|
168
|
+
click_button "Remove"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
click_button "Add question"
|
173
|
+
|
174
|
+
click_button "Save"
|
175
|
+
|
176
|
+
expect(page).to have_selector(".questionnaire-question", count: 1)
|
177
|
+
|
178
|
+
within ".questionnaire-question" do
|
179
|
+
expect(page).to have_selector(".card-title", text: "#1")
|
180
|
+
expect(page).to have_no_button("Up")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
it "removes the question" do
|
185
|
+
within "form.edit_questionnaire" do
|
186
|
+
within ".questionnaire-question" do
|
187
|
+
click_button "Remove"
|
188
|
+
end
|
189
|
+
|
190
|
+
click_button "Save"
|
191
|
+
end
|
192
|
+
|
193
|
+
expect(page).to have_admin_callout("successfully")
|
194
|
+
|
195
|
+
visit questionnaire_edit_path
|
196
|
+
|
197
|
+
within "form.edit_questionnaire" do
|
198
|
+
expect(page).to have_selector(".questionnaire-question", count: 0)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it "cannot be moved up" do
|
203
|
+
within "form.edit_questionnaire" do
|
204
|
+
within ".questionnaire-question" do
|
205
|
+
expect(page).to have_no_button("Up")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
it "cannot be moved down" do
|
211
|
+
within "form.edit_questionnaire" do
|
212
|
+
within ".questionnaire-question" do
|
213
|
+
expect(page).to have_no_button("Down")
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
121
219
|
context "when a questionnaire has an existing question with answer options" do
|
122
220
|
let!(:question) do
|
123
221
|
create(
|
@@ -16,6 +16,14 @@ shared_examples_for "manage questionnaires" do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
+
let(:title_and_description_body) do
|
20
|
+
{
|
21
|
+
en: "Este es el primer separador de texto",
|
22
|
+
ca: "Aquest és el primer separador de text",
|
23
|
+
es: "Esta es la primera pregunta"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
19
27
|
it "updates the questionnaire" do
|
20
28
|
visit questionnaire_edit_path
|
21
29
|
|
@@ -73,7 +73,7 @@ module Decidim
|
|
73
73
|
normalize_matrix_choices(answer, choices)
|
74
74
|
else
|
75
75
|
choices.map do |choice|
|
76
|
-
|
76
|
+
format_free_text_for choice
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -94,6 +94,12 @@ module Decidim
|
|
94
94
|
def answer_translated_attribute_name(attribute)
|
95
95
|
I18n.t(attribute.to_sym, scope: "decidim.forms.user_answers_serializer")
|
96
96
|
end
|
97
|
+
|
98
|
+
def format_free_text_for(choice)
|
99
|
+
return choice.try(:body) if choice.try(:custom_body).blank?
|
100
|
+
|
101
|
+
"#{choice.try(:body)} (#{choice.try(:custom_body)})"
|
102
|
+
end
|
97
103
|
end
|
98
104
|
end
|
99
105
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
8
8
|
- Marc Riera Casals
|
9
9
|
- Oriol Gual Oliva
|
10
10
|
- Rubén González Valero
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-02-22 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.
|
22
|
+
version: 0.26.0
|
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.
|
29
|
+
version: 0.26.0
|
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.
|
64
|
+
version: 0.26.0
|
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.
|
71
|
+
version: 0.26.0
|
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.
|
78
|
+
version: 0.26.0
|
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.
|
85
|
+
version: 0.26.0
|
86
86
|
description: A forms gem for decidim.
|
87
87
|
email:
|
88
88
|
- josepjaume@gmail.com
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb
|
166
166
|
- app/views/decidim/forms/admin/questionnaires/_question.html.erb
|
167
167
|
- app/views/decidim/forms/admin/questionnaires/_separator.html.erb
|
168
|
+
- app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb
|
168
169
|
- app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb
|
169
170
|
- app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb
|
170
171
|
- app/views/decidim/forms/admin/questionnaires/answers/index.html.erb
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb
|
181
182
|
- app/views/decidim/forms/questionnaires/answers/_single_option.html.erb
|
182
183
|
- app/views/decidim/forms/questionnaires/answers/_sorting.html.erb
|
184
|
+
- app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb
|
183
185
|
- app/views/decidim/forms/questionnaires/show.html.erb
|
184
186
|
- app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb
|
185
187
|
- config/assets.rb
|
@@ -250,6 +252,7 @@ files:
|
|
250
252
|
- config/locales/ti-ER.yml
|
251
253
|
- config/locales/tr-TR.yml
|
252
254
|
- config/locales/uk.yml
|
255
|
+
- config/locales/val-ES.yml
|
253
256
|
- config/locales/vi-VN.yml
|
254
257
|
- config/locales/vi.yml
|
255
258
|
- config/locales/zh-CN.yml
|
@@ -294,7 +297,7 @@ homepage: https://github.com/decidim/decidim
|
|
294
297
|
licenses:
|
295
298
|
- AGPL-3.0
|
296
299
|
metadata: {}
|
297
|
-
post_install_message:
|
300
|
+
post_install_message:
|
298
301
|
rdoc_options: []
|
299
302
|
require_paths:
|
300
303
|
- lib
|
@@ -309,8 +312,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
309
312
|
- !ruby/object:Gem::Version
|
310
313
|
version: '0'
|
311
314
|
requirements: []
|
312
|
-
rubygems_version: 3.1.
|
313
|
-
signing_key:
|
315
|
+
rubygems_version: 3.1.6
|
316
|
+
signing_key:
|
314
317
|
specification_version: 4
|
315
318
|
summary: Decidim forms
|
316
319
|
test_files: []
|