decidim-forms 0.29.1 → 0.30.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/cells/decidim/forms/step_navigation_cell.rb +18 -5
- data/app/commands/decidim/forms/admin/update_questionnaire.rb +1 -82
- data/app/commands/decidim/forms/admin/update_questions.rb +109 -0
- data/app/commands/decidim/forms/answer_questionnaire.rb +10 -3
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +39 -3
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb +2 -2
- data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +12 -4
- data/app/forms/decidim/forms/admin/display_condition_form.rb +1 -1
- data/app/forms/decidim/forms/admin/questionnaire_form.rb +2 -11
- data/app/forms/decidim/forms/admin/questions_form.rb +18 -0
- data/app/forms/decidim/forms/answer_choice_form.rb +5 -0
- data/app/forms/decidim/forms/answer_form.rb +1 -0
- data/app/forms/decidim/forms/questionnaire_form.rb +7 -0
- data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb +1 -1
- data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb +5 -5
- data/app/jobs/decidim/forms/export_questionnaire_answers_job.rb +5 -1
- data/app/models/decidim/forms/answer_option.rb +1 -1
- data/app/models/decidim/forms/question.rb +10 -0
- data/app/packs/entrypoints/decidim_forms.js +0 -1
- data/app/packs/entrypoints/decidim_forms_admin.js +6 -0
- data/app/packs/src/decidim/forms/admin/publish_answers_buttons.js +72 -0
- data/app/packs/src/decidim/forms/forms.js +22 -18
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +1 -1
- data/app/presenters/decidim/forms/admin_log/question_presenter.rb +31 -0
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +0 -89
- data/app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +3 -3
- data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +80 -0
- data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +0 -20
- data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +47 -0
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +11 -1
- data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +8 -1
- data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +1 -1
- data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +12 -6
- data/app/views/decidim/forms/questionnaires/edit.html.erb +47 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +13 -2
- data/config/assets.rb +1 -2
- data/config/locales/ar.yml +3 -2
- data/config/locales/bg.yml +0 -7
- data/config/locales/bn-BD.yml +1 -0
- data/config/locales/bs-BA.yml +1 -0
- data/config/locales/ca.yml +46 -6
- data/config/locales/cs.yml +45 -5
- data/config/locales/de.yml +47 -7
- data/config/locales/el.yml +0 -7
- data/config/locales/en.yml +45 -5
- data/config/locales/es-MX.yml +45 -5
- data/config/locales/es-PY.yml +45 -5
- data/config/locales/es.yml +45 -5
- data/config/locales/eu.yml +50 -10
- data/config/locales/fi-plain.yml +45 -5
- data/config/locales/fi.yml +45 -5
- data/config/locales/fr-CA.yml +37 -5
- data/config/locales/fr.yml +37 -5
- data/config/locales/gl.yml +0 -3
- data/config/locales/hu.yml +0 -3
- data/config/locales/id-ID.yml +0 -2
- data/config/locales/it.yml +0 -4
- data/config/locales/ja.yml +1 -6
- data/config/locales/lb.yml +0 -4
- data/config/locales/lt.yml +0 -7
- data/config/locales/lv.yml +0 -3
- data/config/locales/nl.yml +0 -5
- data/config/locales/no.yml +0 -5
- data/config/locales/pl.yml +0 -7
- data/config/locales/pt-BR.yml +0 -5
- data/config/locales/pt.yml +0 -4
- data/config/locales/ro-RO.yml +8 -7
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv.yml +0 -5
- data/config/locales/tr-TR.yml +0 -4
- data/config/locales/val-ES.yml +0 -2
- data/config/locales/zh-CN.yml +0 -4
- data/config/locales/zh-TW.yml +0 -7
- data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
- data/db/migrate/20241122142230_add_survey_answers_published_at_to_questions.rb +7 -0
- data/decidim-forms.gemspec +2 -7
- data/lib/decidim/api/answer_option_type.rb +1 -1
- data/lib/decidim/api/question_type.rb +4 -4
- data/lib/decidim/api/questionnaire_type.rb +4 -4
- data/lib/decidim/exporters/form_pdf.rb +114 -11
- data/lib/decidim/forms/download_your_data_user_answers_serializer.rb +0 -4
- data/lib/decidim/forms/test/factories.rb +2 -2
- data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +70 -4
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +17 -17
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -21
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +70 -94
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +15 -18
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +90 -125
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -25
- data/lib/decidim/forms/user_answers_serializer.rb +1 -1
- data/lib/decidim/forms/version.rb +1 -1
- data/lib/decidim/forms.rb +0 -1
- metadata +21 -47
- data/app/packs/entrypoints/decidim_questionnaire_answers_pdf.js +0 -1
- data/app/packs/entrypoints/decidim_questionnaire_answers_pdf.scss +0 -1
- data/app/packs/stylesheets/decidim/forms/questionnaire-answers-pdf.scss +0 -69
- data/app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb +0 -31
- data/app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb +0 -13
- data/app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb +0 -12
- data/config/initializers/wicked_pdf.rb +0 -27
- data/lib/decidim/exporters/form_pdf_controller_helper.rb +0 -13
@@ -37,29 +37,26 @@ shared_examples_for "add questions" do
|
|
37
37
|
|
38
38
|
it "adds a few questions and separators to the questionnaire" do
|
39
39
|
fields_body = ["This is the first question", "This is the second question", "This is the first title and description"]
|
40
|
+
click_on "Add question"
|
41
|
+
click_on "Add separator"
|
42
|
+
click_on "Add title and description"
|
43
|
+
click_on "Add question"
|
40
44
|
|
41
|
-
|
42
|
-
click_on "Add question"
|
43
|
-
click_on "Add separator"
|
44
|
-
click_on "Add title and description"
|
45
|
-
click_on "Add question"
|
46
|
-
|
47
|
-
expect(page).to have_css(".questionnaire-question", count: 4)
|
45
|
+
expect(page).to have_css(".questionnaire-question", count: 4)
|
48
46
|
|
49
|
-
|
47
|
+
expand_all_questions
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
49
|
+
page.all(".questionnaire-question .collapsible").each_with_index do |field, idx|
|
50
|
+
within field do
|
51
|
+
fill_in find_nested_form_field_locator("body_en"), with: fields_body[idx]
|
55
52
|
end
|
56
|
-
|
57
|
-
click_on "Save"
|
58
53
|
end
|
59
54
|
|
55
|
+
click_on "Save"
|
56
|
+
|
60
57
|
expect(page).to have_admin_callout("successfully")
|
61
58
|
|
62
|
-
|
59
|
+
visit_manage_questions_and_expand_all
|
63
60
|
|
64
61
|
expect(page).to have_css("input[value='This is the first question']")
|
65
62
|
expect(page).to have_css("input[value='This is the second question']")
|
@@ -68,59 +65,45 @@ shared_examples_for "add questions" do
|
|
68
65
|
end
|
69
66
|
|
70
67
|
it "adds a question with a rich text description" do
|
71
|
-
|
72
|
-
|
73
|
-
expand_all_questions
|
74
|
-
|
75
|
-
within ".questionnaire-question" do
|
76
|
-
fill_in find_nested_form_field_locator("body_en"), with: "Body"
|
68
|
+
click_on "Add question"
|
69
|
+
expand_all_questions
|
77
70
|
|
78
|
-
|
79
|
-
|
71
|
+
within ".questionnaire-question" do
|
72
|
+
fill_in find_nested_form_field_locator("body_en"), with: "Body"
|
80
73
|
|
81
|
-
|
74
|
+
fill_in_editor find_nested_form_field_locator("description_en", visible: false), with: "<p>\n<strong>Superkalifragilistic description</strong>\n</p>"
|
82
75
|
end
|
83
76
|
|
77
|
+
click_on "Save"
|
78
|
+
|
84
79
|
expect(page).to have_admin_callout("successfully")
|
85
80
|
|
86
|
-
|
87
|
-
step_settings: {
|
88
|
-
component.participatory_space.active_step.id => {
|
89
|
-
allow_answers: true
|
90
|
-
}
|
91
|
-
}
|
92
|
-
)
|
81
|
+
update_component_settings_or_attributes
|
93
82
|
|
94
83
|
visit questionnaire_public_path
|
84
|
+
see_questionnaire_questions
|
95
85
|
|
96
86
|
expect(page).to have_css("strong", text: "Superkalifragilistic description")
|
97
87
|
end
|
98
88
|
|
99
89
|
it "adds a title-and-description" do
|
100
|
-
|
101
|
-
|
102
|
-
expand_all_questions
|
90
|
+
click_on "Add title and description"
|
91
|
+
expand_all_questions
|
103
92
|
|
104
|
-
|
105
|
-
|
93
|
+
within ".questionnaire-question" do
|
94
|
+
fill_in find_nested_form_field_locator("body_en"), with: "Body"
|
106
95
|
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
click_on "Save"
|
96
|
+
fill_in_editor find_nested_form_field_locator("description_en", visible: false), with: "<p>\n<strong>Superkalifragilistic description</strong>\n</p>"
|
111
97
|
end
|
112
98
|
|
99
|
+
click_on "Save"
|
100
|
+
|
113
101
|
expect(page).to have_admin_callout("successfully")
|
114
102
|
|
115
|
-
|
116
|
-
step_settings: {
|
117
|
-
component.participatory_space.active_step.id => {
|
118
|
-
allow_answers: true
|
119
|
-
}
|
120
|
-
}
|
121
|
-
)
|
103
|
+
update_component_settings_or_attributes
|
122
104
|
|
123
105
|
visit questionnaire_public_path
|
106
|
+
see_questionnaire_questions
|
124
107
|
|
125
108
|
expect(page).to have_css("strong", text: "Superkalifragilistic description")
|
126
109
|
end
|
@@ -140,40 +123,38 @@ shared_examples_for "add questions" do
|
|
140
123
|
]
|
141
124
|
]
|
142
125
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
expand_all_questions
|
126
|
+
click_on "Add question"
|
127
|
+
click_on "Add question"
|
128
|
+
expand_all_questions
|
147
129
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
end
|
130
|
+
page.all(".questionnaire-question").each_with_index do |question, idx|
|
131
|
+
within question do
|
132
|
+
fill_in find_nested_form_field_locator("body_en"), with: question_body[idx]
|
152
133
|
end
|
134
|
+
end
|
153
135
|
|
154
|
-
|
136
|
+
expect(page).to have_no_content "Add answer option"
|
155
137
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
end
|
138
|
+
page.all(".questionnaire-question").each do |question|
|
139
|
+
within question do
|
140
|
+
select "Single option", from: "Type"
|
141
|
+
click_on "Add answer option"
|
161
142
|
end
|
143
|
+
end
|
162
144
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
end
|
145
|
+
page.all(".questionnaire-question").each_with_index do |question, question_idx|
|
146
|
+
question.all(".questionnaire-question-answer-option").each_with_index do |question_answer_option, answer_option_idx|
|
147
|
+
within question_answer_option do
|
148
|
+
fill_in find_nested_form_field_locator("body_en"), with: answer_options_body[question_idx][answer_option_idx]
|
168
149
|
end
|
169
150
|
end
|
170
|
-
|
171
|
-
click_on "Save"
|
172
151
|
end
|
173
152
|
|
153
|
+
click_on "Save"
|
154
|
+
|
174
155
|
expect(page).to have_admin_callout("successfully")
|
175
156
|
|
176
|
-
|
157
|
+
visit_manage_questions_and_expand_all
|
177
158
|
|
178
159
|
expect(page).to have_css("input[value='This is the first question']")
|
179
160
|
expect(page).to have_css("input[value='This is the Q1 first option']")
|
@@ -278,11 +259,12 @@ shared_examples_for "add questions" do
|
|
278
259
|
click_on "Add question"
|
279
260
|
expand_all_questions
|
280
261
|
|
262
|
+
expect(page).to have_text("Type")
|
281
263
|
select "Long answer", from: "Type"
|
282
264
|
click_on "Save"
|
283
265
|
|
284
266
|
expand_all_questions
|
285
|
-
expect(page).to have_select("Type", selected: "Long answer")
|
267
|
+
expect(page).to have_select("Type", selected: "Long answer", wait: 10)
|
286
268
|
end
|
287
269
|
|
288
270
|
it "does not preserve spurious answer options from previous type selections" do
|
@@ -300,6 +282,7 @@ shared_examples_for "add questions" do
|
|
300
282
|
click_on "Save"
|
301
283
|
expand_all_questions
|
302
284
|
|
285
|
+
expect(page).to have_text("Type")
|
303
286
|
select "Single option", from: "Type"
|
304
287
|
|
305
288
|
within ".questionnaire-question-answer-option:first-of-type" do
|
@@ -322,6 +305,7 @@ shared_examples_for "add questions" do
|
|
322
305
|
click_on "Save"
|
323
306
|
expand_all_questions
|
324
307
|
|
308
|
+
expect(page).to have_text("Type")
|
325
309
|
select "Matrix (Single option)", from: "Type"
|
326
310
|
|
327
311
|
within ".questionnaire-question-matrix-row:first-of-type" do
|
@@ -350,6 +334,7 @@ shared_examples_for "add questions" do
|
|
350
334
|
click_on "Save"
|
351
335
|
expand_all_questions
|
352
336
|
|
337
|
+
expect(page).to have_css(".questionnaire-question-answer-option")
|
353
338
|
within ".questionnaire-question-answer-option:first-of-type" do
|
354
339
|
expect(page).to have_nested_field("body_en", with: "Something")
|
355
340
|
end
|
@@ -383,7 +368,6 @@ shared_examples_for "add questions" do
|
|
383
368
|
|
384
369
|
it "allows switching translated field tabs after form failures" do
|
385
370
|
click_on "Add question"
|
386
|
-
click_on "Save"
|
387
371
|
|
388
372
|
expand_all_questions
|
389
373
|
|
@@ -405,20 +389,16 @@ shared_examples_for "add questions" do
|
|
405
389
|
let(:single_option_string) { "Single option" }
|
406
390
|
|
407
391
|
before do
|
408
|
-
|
409
|
-
|
410
|
-
within "form.edit_questionnaire" do
|
411
|
-
click_on "Add question"
|
412
|
-
|
413
|
-
expand_all_questions
|
392
|
+
click_on "Add question"
|
414
393
|
|
415
|
-
|
416
|
-
fill_in find_nested_form_field_locator("body_en"), with: "This is the first question"
|
417
|
-
end
|
394
|
+
expand_all_questions
|
418
395
|
|
419
|
-
|
420
|
-
|
396
|
+
within ".questionnaire-question" do
|
397
|
+
fill_in find_nested_form_field_locator("body_en"), with: "This is the first question"
|
421
398
|
end
|
399
|
+
|
400
|
+
expect(page).to have_no_content "Add answer option"
|
401
|
+
expect(page).to have_no_select("Maximum number of choices")
|
422
402
|
end
|
423
403
|
|
424
404
|
it "updates the free text option selector according to the selected question type" do
|
@@ -442,20 +422,16 @@ shared_examples_for "add questions" do
|
|
442
422
|
let(:single_option_string) { "Matrix (Single option)" }
|
443
423
|
|
444
424
|
before do
|
445
|
-
|
446
|
-
|
447
|
-
within "form.edit_questionnaire" do
|
448
|
-
click_on "Add question"
|
449
|
-
expand_all_questions
|
450
|
-
|
451
|
-
within ".questionnaire-question" do
|
452
|
-
fill_in find_nested_form_field_locator("body_en"), with: "This is the first question"
|
453
|
-
end
|
425
|
+
click_on "Add question"
|
426
|
+
expand_all_questions
|
454
427
|
|
455
|
-
|
456
|
-
|
457
|
-
expect(page).to have_no_select("Maximum number of choices")
|
428
|
+
within ".questionnaire-question" do
|
429
|
+
fill_in find_nested_form_field_locator("body_en"), with: "This is the first question"
|
458
430
|
end
|
431
|
+
|
432
|
+
expect(page).to have_no_content "Add answer option"
|
433
|
+
expect(page).to have_no_content "Add row"
|
434
|
+
expect(page).to have_no_select("Maximum number of choices")
|
459
435
|
end
|
460
436
|
|
461
437
|
it "updates the free text option selector according to the selected question type" do
|
data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb
CHANGED
@@ -19,7 +19,8 @@ shared_examples_for "update display conditions" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
before do
|
22
|
-
|
22
|
+
click_on "Save"
|
23
|
+
visit_manage_questions_and_expand_all
|
23
24
|
end
|
24
25
|
|
25
26
|
it "the related form appears" do
|
@@ -59,35 +60,31 @@ shared_examples_for "update display conditions" do
|
|
59
60
|
|
60
61
|
click_on "Save"
|
61
62
|
|
62
|
-
|
63
|
+
visit_manage_questions_and_expand_all
|
63
64
|
|
64
65
|
expect(page).to have_css(".questionnaire-question-display-condition", count: 0)
|
65
66
|
end
|
66
67
|
|
67
68
|
it "still removes the question even if previous editions rendered the conditions invalid" do
|
68
|
-
|
69
|
-
expect(page).to have_css(".questionnaire-question", count: 2)
|
70
|
-
|
71
|
-
within ".questionnaire-question-display-condition:first-of-type" do
|
72
|
-
select condition_question.body["en"], from: "Question"
|
73
|
-
select "Includes text", from: "Condition"
|
74
|
-
fill_in find_nested_form_field_locator("condition_value_en"), with: ""
|
75
|
-
end
|
69
|
+
expect(page).to have_css(".questionnaire-question", count: 2)
|
76
70
|
|
77
|
-
|
78
|
-
|
79
|
-
|
71
|
+
within ".questionnaire-question-display-condition:first-of-type" do
|
72
|
+
select condition_question.body["en"], from: "Question"
|
73
|
+
select "Includes text", from: "Condition"
|
74
|
+
fill_in find_nested_form_field_locator("condition_value_en"), with: ""
|
75
|
+
end
|
80
76
|
|
81
|
-
|
77
|
+
within ".questionnaire-question:last-of-type" do
|
78
|
+
click_on "Remove", match: :first
|
82
79
|
end
|
83
80
|
|
81
|
+
click_on "Save"
|
82
|
+
|
84
83
|
expect(page).to have_admin_callout("successfully")
|
85
84
|
|
86
|
-
|
85
|
+
visit_manage_questions_and_expand_all
|
87
86
|
|
88
|
-
|
89
|
-
expect(page).to have_css(".questionnaire-question", count: 1)
|
90
|
-
end
|
87
|
+
expect(page).to have_css(".questionnaire-question", count: 1)
|
91
88
|
end
|
92
89
|
end
|
93
90
|
end
|