decidim-forms 0.25.0 → 0.26.0.rc2
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/ja.yml +12 -1
- data/config/locales/lb-LU.yml +103 -0
- data/config/locales/nl.yml +11 -0
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/ro-RO.yml +67 -58
- data/config/locales/val-ES.yml +18 -0
- data/lib/decidim/forms/engine.rb +4 -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 +17 -14
@@ -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.rc2
|
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-02 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.rc2
|
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.rc2
|
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.rc2
|
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.rc2
|
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.rc2
|
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.rc2
|
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
|
@@ -305,12 +308,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
308
|
version: '2.7'
|
306
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
310
|
requirements:
|
308
|
-
- - "
|
311
|
+
- - ">"
|
309
312
|
- !ruby/object:Gem::Version
|
310
|
-
version:
|
313
|
+
version: 1.3.1
|
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: []
|