decidim-forms 0.30.9 → 0.31.0.rc1

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.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -10
  3. data/app/cells/decidim/forms/matrix_readonly/show.erb +1 -1
  4. data/app/cells/decidim/forms/matrix_readonly_cell.rb +3 -3
  5. data/app/cells/decidim/forms/question_readonly/show.erb +5 -5
  6. data/app/cells/decidim/forms/question_readonly/title_and_description.erb +3 -3
  7. data/app/cells/decidim/forms/response_readonly_cell.rb +9 -0
  8. data/app/cells/decidim/forms/step_navigation/show.erb +3 -3
  9. data/app/cells/decidim/forms/step_navigation_cell.rb +3 -3
  10. data/app/commands/decidim/forms/admin/update_questions.rb +6 -6
  11. data/app/commands/decidim/forms/{answer_questionnaire.rb → response_questionnaire.rb} +35 -35
  12. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +12 -12
  13. data/app/controllers/decidim/forms/admin/concerns/{has_questionnaire_answers.rb → has_questionnaire_responses.rb} +23 -19
  14. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +38 -33
  15. data/app/forms/decidim/forms/admin/display_condition_form.rb +15 -15
  16. data/app/forms/decidim/forms/admin/question_form.rb +3 -3
  17. data/app/forms/decidim/forms/admin/{answer_option_form.rb → response_option_form.rb} +3 -3
  18. data/app/forms/decidim/forms/questionnaire_form.rb +18 -16
  19. data/app/forms/decidim/forms/{answer_choice_form.rb → response_choice_form.rb} +5 -5
  20. data/app/forms/decidim/forms/{answer_form.rb → response_form.rb} +9 -9
  21. data/app/helpers/decidim/forms/admin/application_helper.rb +2 -2
  22. data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_pagination_helper.rb → has_questionnaire_responses_pagination_helper.rb} +4 -4
  23. data/app/helpers/decidim/forms/admin/concerns/{has_questionnaire_answers_url_helper.rb → has_questionnaire_responses_url_helper.rb} +5 -5
  24. data/app/helpers/decidim/forms/admin/questionnaire_responses_helper.rb +32 -0
  25. data/app/helpers/decidim/forms/application_helper.rb +1 -2
  26. data/app/jobs/decidim/forms/{export_questionnaire_answers_job.rb → export_questionnaire_responses_job.rb} +5 -5
  27. data/app/models/decidim/forms/display_condition.rb +20 -20
  28. data/app/models/decidim/forms/question.rb +14 -13
  29. data/app/models/decidim/forms/question_matrix_row.rb +1 -1
  30. data/app/models/decidim/forms/questionnaire.rb +11 -11
  31. data/app/models/decidim/forms/{answer.rb → response.rb} +9 -9
  32. data/app/models/decidim/forms/response_choice.rb +22 -0
  33. data/app/models/decidim/forms/{answer_option.rb → response_option.rb} +5 -5
  34. data/app/packs/entrypoints/decidim_forms_admin.js +3 -3
  35. data/app/packs/src/decidim/forms/admin/collapsible_questions.js +12 -10
  36. data/app/packs/src/decidim/forms/admin/forms.js +47 -66
  37. data/app/packs/src/decidim/forms/admin/{publish_answers_buttons.js → publish_responses_buttons.js} +12 -12
  38. data/app/packs/src/decidim/forms/display_conditions.component.js +12 -12
  39. data/app/packs/src/decidim/forms/forms.js +8 -29
  40. data/app/packs/stylesheets/decidim/forms/forms.scss +2 -2
  41. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +13 -13
  42. data/app/presenters/decidim/forms/admin/questionnaire_response_presenter.rb +89 -0
  43. data/app/presenters/decidim/forms/admin_log/question_presenter.rb +3 -3
  44. data/app/presenters/decidim/forms/{answer_option_presenter.rb → response_option_presenter.rb} +2 -2
  45. data/app/queries/decidim/forms/questionnaire_participant.rb +5 -5
  46. data/app/queries/decidim/forms/questionnaire_participants.rb +6 -6
  47. data/app/queries/decidim/forms/questionnaire_user_responses.rb +32 -0
  48. data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +9 -9
  49. data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +2 -2
  50. data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +3 -3
  51. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +25 -15
  52. data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +14 -21
  53. data/app/views/decidim/forms/admin/questionnaires/_response_option.html.erb +45 -0
  54. data/app/views/decidim/forms/admin/questionnaires/_response_option_template.html.erb +7 -0
  55. data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +15 -5
  56. data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +15 -5
  57. data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +1 -1
  58. data/app/views/decidim/forms/admin/questionnaires/edit_questions.html.erb +8 -8
  59. data/app/views/decidim/forms/admin/questionnaires/responses/index.html.erb +80 -0
  60. data/app/views/decidim/forms/admin/questionnaires/responses/show.html.erb +43 -0
  61. data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +24 -22
  62. data/app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb +8 -3
  63. data/app/views/decidim/forms/questionnaires/_response.html.erb +61 -0
  64. data/app/views/decidim/forms/questionnaires/edit.html.erb +2 -2
  65. data/app/views/decidim/forms/questionnaires/responses/_files.html.erb +1 -0
  66. data/app/views/decidim/forms/questionnaires/responses/_long_response.html.erb +3 -0
  67. data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_multiple.html.erb +16 -15
  68. data/app/views/decidim/forms/questionnaires/{answers → responses}/_matrix_single.html.erb +17 -16
  69. data/app/views/decidim/forms/questionnaires/responses/_multiple_option.html.erb +26 -0
  70. data/app/views/decidim/forms/questionnaires/responses/_separator.html.erb +1 -0
  71. data/app/views/decidim/forms/questionnaires/responses/_short_response.html.erb +3 -0
  72. data/app/views/decidim/forms/questionnaires/responses/_single_option.html.erb +33 -0
  73. data/app/views/decidim/forms/questionnaires/responses/_sorting.html.erb +26 -0
  74. data/app/views/decidim/forms/questionnaires/responses/_title_and_description.html.erb +1 -0
  75. data/app/views/decidim/forms/questionnaires/show.html.erb +10 -10
  76. data/config/assets.rb +2 -2
  77. data/config/locales/ar.yml +2 -22
  78. data/config/locales/bg.yml +10 -36
  79. data/config/locales/ca-IT.yml +82 -76
  80. data/config/locales/ca.yml +82 -76
  81. data/config/locales/cs.yml +79 -76
  82. data/config/locales/de.yml +80 -74
  83. data/config/locales/el.yml +10 -36
  84. data/config/locales/en.yml +90 -84
  85. data/config/locales/es-MX.yml +82 -76
  86. data/config/locales/es-PY.yml +82 -76
  87. data/config/locales/es.yml +80 -74
  88. data/config/locales/eu.yml +83 -77
  89. data/config/locales/fi-plain.yml +78 -72
  90. data/config/locales/fi.yml +76 -70
  91. data/config/locales/fr-CA.yml +72 -70
  92. data/config/locales/fr.yml +72 -70
  93. data/config/locales/ga-IE.yml +4 -7
  94. data/config/locales/gl.yml +4 -22
  95. data/config/locales/hu.yml +4 -22
  96. data/config/locales/id-ID.yml +2 -22
  97. data/config/locales/it.yml +8 -40
  98. data/config/locales/ja.yml +87 -81
  99. data/config/locales/lb.yml +8 -36
  100. data/config/locales/lt.yml +10 -36
  101. data/config/locales/lv.yml +4 -22
  102. data/config/locales/nl.yml +10 -36
  103. data/config/locales/no.yml +10 -36
  104. data/config/locales/pl.yml +10 -36
  105. data/config/locales/pt-BR.yml +10 -120
  106. data/config/locales/pt.yml +8 -36
  107. data/config/locales/ro-RO.yml +30 -52
  108. data/config/locales/ru.yml +2 -9
  109. data/config/locales/sk.yml +3 -183
  110. data/config/locales/sl.yml +0 -5
  111. data/config/locales/sv.yml +77 -70
  112. data/config/locales/tr-TR.yml +8 -36
  113. data/config/locales/val-ES.yml +2 -0
  114. data/config/locales/zh-CN.yml +8 -36
  115. data/config/locales/zh-TW.yml +10 -36
  116. data/db/migrate/20190315203056_add_session_token_to_decidim_forms_answers.rb +1 -1
  117. data/db/migrate/20250314150250_rename_answer_to_response_in_decidim_forms.rb +30 -0
  118. data/db/migrate/20250319130003_change_question_types_in_questions.rb +14 -0
  119. data/lib/decidim/api/question_matrix_row_type.rb +13 -0
  120. data/lib/decidim/api/question_type.rb +4 -3
  121. data/lib/decidim/api/questionnaire_type.rb +1 -0
  122. data/lib/decidim/api/response_option_type.rb +13 -0
  123. data/lib/decidim/exporters/form_pdf.rb +35 -43
  124. data/lib/decidim/forms/api.rb +2 -1
  125. data/lib/decidim/forms/{download_your_data_user_answers_serializer.rb → download_your_data_user_responses_serializer.rb} +3 -3
  126. data/lib/decidim/forms/engine.rb +2 -2
  127. data/lib/decidim/forms/test/factories.rb +24 -24
  128. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +178 -176
  129. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_responses.rb +159 -0
  130. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +19 -19
  131. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +44 -90
  132. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +10 -10
  133. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +43 -140
  134. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +4 -6
  135. data/lib/decidim/forms/test.rb +1 -1
  136. data/lib/decidim/forms/user_responses_serializer.rb +110 -0
  137. data/lib/decidim/forms/version.rb +1 -1
  138. data/lib/decidim/forms.rb +2 -2
  139. metadata +48 -46
  140. data/app/cells/decidim/forms/answer_readonly_cell.rb +0 -9
  141. data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +0 -30
  142. data/app/models/decidim/forms/answer_choice.rb +0 -22
  143. data/app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb +0 -112
  144. data/app/queries/decidim/forms/questionnaire_user_answers.rb +0 -32
  145. data/app/views/decidim/forms/admin/questionnaires/_answer_option.html.erb +0 -45
  146. data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +0 -7
  147. data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +0 -49
  148. data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +0 -43
  149. data/app/views/decidim/forms/questionnaires/_answer.html.erb +0 -60
  150. data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +0 -1
  151. data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +0 -3
  152. data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +0 -25
  153. data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +0 -1
  154. data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +0 -3
  155. data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +0 -32
  156. data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +0 -26
  157. data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +0 -1
  158. data/lib/decidim/api/answer_option_type.rb +0 -13
  159. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +0 -149
  160. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/draggable_behavior.rb +0 -47
  161. data/lib/decidim/forms/user_answers_serializer.rb +0 -105
  162. /data/app/cells/decidim/forms/{answer_readonly → response_readonly}/show.erb +0 -0
@@ -1,11 +1,12 @@
1
1
  <div class="questionnaire-questions form__wrapper">
2
- <div class="row column text-center my-4">
3
- <button type="button" class="button button__sm button__secondary collapse-all"><%= t(".collapse") %></button>
4
- <button type="button" class="button button__sm button__secondary expand-all"><%= t(".expand") %></button>
2
+ <div class="row column text-right my-4">
3
+ <button type="button" class="button button__sm button__text-secondary collapse-all"><%= t(".collapse") %></button>
4
+ |
5
+ <button type="button" class="button button__sm button__text-secondary expand-all"><%= t(".expand") %></button>
5
6
  </div>
6
7
 
7
8
  <% if questionnaire.questions_editable? %>
8
- <% if questionnaire.answers.any? && !questionnaire.published? %>
9
+ <% if questionnaire.responses.any? && !questionnaire.published? %>
9
10
  <%= cell("decidim/announcement", t(".unpublished_warning"), callout_class: "warning" ) %>
10
11
  <% end %>
11
12
 
@@ -15,7 +16,7 @@
15
16
  form: question_form,
16
17
  id: tabs_id_for_question(blank_question),
17
18
  editable: questionnaire.questions_editable?,
18
- answer_option_template_selector: "#answer-option-template-dummy",
19
+ response_option_template_selector: "#response-option-template-dummy",
19
20
  display_condition_template_selector: "#display-condition-template-dummy",
20
21
  matrix_row_template_selector: "#matrix-row-template-dummy" %>
21
22
  </script>
@@ -31,23 +32,15 @@
31
32
  id: tabs_id_for_question(blank_question),
32
33
  editable: questionnaire.questions_editable? %>
33
34
  </script>
34
- <%= render "decidim/forms/admin/questionnaires/answer_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "answer-option-template-dummy" %>
35
+ <%= render "decidim/forms/admin/questionnaires/response_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "response-option-template-dummy" %>
35
36
  <%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-dummy" %>
36
37
  <%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-dummy" %>
37
38
  <% end %>
38
39
  <% else %>
39
- <%= cell("decidim/announcement", t(".already_answered_warning"), callout_class: "warning" ) %>
40
+ <%= cell("decidim/announcement", t(".already_responded_warning"), callout_class: "warning" ) %>
40
41
  <% end %>
41
42
 
42
- <% list_attributes = {
43
- class: "questionnaire-questions-list flex flex-col py-6 gap-6 last:pb-0",
44
- id: "questionnaire-questions-list"
45
- }
46
- list_attributes[:"data-draggable-table"] = true if questionnaire.questions_editable?
47
- list_attributes[:"data-sort-url"] = "#" if questionnaire.questions_editable?
48
- list_attributes[:"data-draggable-handle"] = ".card-divider" if questionnaire.questions_editable? %>
49
-
50
- <%= content_tag :div, list_attributes do %>
43
+ <div class="questionnaire-questions-list flex flex-col py-6 gap-6 last:pb-0">
51
44
  <% @form.questions.each_with_index do |question, index| %>
52
45
  <%= fields_for "questions[questions][]", question do |question_form| %>
53
46
  <% if question.separator? %>
@@ -66,22 +59,22 @@
66
59
  id: tabs_id_for_question(question),
67
60
  editable: questionnaire.questions_editable?,
68
61
  display_condition_template_selector: "#display-condition-template-#{index}",
69
- answer_option_template_selector: "#answer-option-template-#{index}",
62
+ response_option_template_selector: "#response-option-template-#{index}",
70
63
  matrix_row_template_selector: "#matrix-row-template-#{index}" %>
71
64
  <%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-#{index}" %>
72
- <%= render "decidim/forms/admin/questionnaires/answer_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "answer-option-template-#{index}" %>
65
+ <%= render "decidim/forms/admin/questionnaires/response_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "response-option-template-#{index}" %>
73
66
  <%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-#{index}" %>
74
67
  <% end %>
75
68
  <% end %>
76
69
  <% end %>
77
- <% end %>
70
+ </div>
78
71
  </div>
79
72
 
80
73
  <%= append_javascript_pack_tag "decidim_forms_admin" %>
81
74
 
82
75
  <% if questionnaire.questions_editable? %>
83
- <script>
84
- document.addEventListener("DOMContentLoaded", function () {
76
+ <script>
77
+ document.addEventListener("turbo:load", function () {
85
78
  window.Decidim.createEditableForm();
86
79
  });
87
80
  </script>
@@ -0,0 +1,45 @@
1
+ <% response_option = form.object %>
2
+
3
+ <div class="card questionnaire-question-response-option m-4">
4
+ <div class="card-divider">
5
+ <h2 class="card-title">
6
+ <span><%= t(".response_option") %></span>
7
+ <% if editable %>
8
+ <button class="button button__xs button__transparent-secondary small alert remove-response-option button--title mb-2">
9
+ <%= icon("delete-bin-line") %>
10
+ <span class="hidden md:block"><%= t(".remove") %></span>
11
+ </button>
12
+ <% end %>
13
+ </h2>
14
+ </div>
15
+
16
+ <div class="card-section">
17
+ <div class="row column">
18
+ <%=
19
+ form.translated(
20
+ :text_field,
21
+ :body,
22
+ tabs_id: tabs_id_for_question_response_option(question, response_option),
23
+ label: t(".statement"),
24
+ disabled: !editable
25
+ )
26
+ %>
27
+ </div>
28
+
29
+ <div class="row column">
30
+ <%=
31
+ form.check_box(
32
+ :free_text,
33
+ label: t(".free_text"),
34
+ disabled: !questionnaire.questions_editable?
35
+ )
36
+ %>
37
+ </div>
38
+ </div>
39
+
40
+ <% if response_option.persisted? %>
41
+ <%= form.hidden_field :id, disabled: !editable %>
42
+ <% end %>
43
+
44
+ <%= form.hidden_field :deleted, disabled: !editable %>
45
+ </div>
@@ -0,0 +1,7 @@
1
+ <% question = form.object %>
2
+
3
+ <script type="text/template" class="decidim-response-option-template decidim-template" id="<%= template_id %>">
4
+ <%= fields_for "questions[questions][#{question.to_param}][response_options][]", blank_response_option do |response_option_form| %>
5
+ <%= render "decidim/forms/admin/questionnaires/response_option", form: response_option_form, question:, editable: %>
6
+ <% end %>
7
+ </script>
@@ -1,18 +1,28 @@
1
1
  <% question = form.object %>
2
2
 
3
3
  <div class="card questionnaire-question" id="<%= id %>-field">
4
- <%= content_tag :div, class: ["card-divider", ("hover:cursor-grab" if editable)] do %>
4
+ <div class="card-divider">
5
5
  <h2 class="card-title flex items-center">
6
6
  <span>
7
7
  <% if editable %>
8
- <%= icon("draggable", class: "dragger") %>
8
+ <%== icon("drag-move-2-fill") %>
9
9
  <% end %>
10
10
  <%= dynamic_title(t(".separator"), class: "question-title-statement", max_length: 50, omission: "...", placeholder: t(".separator")) %>
11
11
  </span>
12
12
 
13
- <div class="flex items-center gap-x-4 ml-auto">
13
+ <div class="flex flex-row-reverse items-center gap-x-4 ml-auto">
14
14
  <% if editable %>
15
- <button type="button" class="button button__xs button__transparent button__transparent-secondary small alert remove-question button--title">
15
+ <button class="button button__xs button__transparent button__transparent-secondary small alert move-up-question button--title">
16
+ <%= icon("arrow-up-line") %>
17
+ <span class="hidden md:block"><%= t(".up") %></span>
18
+ </button>
19
+
20
+ <button class="button button__xs button__transparent button__transparent-secondary small alert move-down-question button--title">
21
+ <%= icon("arrow-down-line") %>
22
+ <span class="hidden md:block"><%= t(".down") %></span>
23
+ </button>
24
+
25
+ <button class="button button__xs button__transparent button__transparent-secondary small alert remove-question button--title">
16
26
  <%= icon("delete-bin-line") %>
17
27
  <span class="hidden md:block"><%= t(".remove") %></span>
18
28
  </button>
@@ -32,5 +42,5 @@
32
42
 
33
43
  <%= form.hidden_field :position, value: question.position || 0, disabled: !editable %>
34
44
  <%= form.hidden_field :deleted, disabled: !editable %>
35
- <% end %>
45
+ </div>
36
46
  </div>
@@ -3,11 +3,11 @@
3
3
 
4
4
  <div class="card questionnaire-question" id="accordion-<%= id %>-field">
5
5
  <div data-controller="accordion">
6
- <%= content_tag :div, class: ["card-divider", ("hover:cursor-grab" if editable)] do %>
6
+ <div class="card-divider">
7
7
  <h2 class="card-title flex items-center">
8
8
  <span>
9
9
  <% if editable %>
10
- <%= icon("draggable", class: "dragger") %>
10
+ <%== icon("drag-move-2-fill") %>
11
11
  <% end %>
12
12
  <%= dynamic_title(translated_attribute(question.body), class: "question-title-statement", max_length: 50, omission: "...", placeholder: t(".title_and_description")) %>
13
13
  </span>
@@ -23,9 +23,19 @@
23
23
  </button>
24
24
 
25
25
  <% if editable %>
26
- <button type="button" class="button button__xs button__transparent button__transparent-secondary small alert remove-question button--title">
26
+ <button class="button button__xs button__transparent button__transparent-secondary small alert move-up-question button--title">
27
+ <%= icon("arrow-up-line") %>
28
+ <span class="hidden md:block"><%= t(".up") %></span>
29
+ </button>
30
+
31
+ <button class="button button__xs button__transparent button__transparent-secondary small alert move-down-question button--title">
32
+ <%= icon("arrow-down-line") %>
33
+ <span class="hidden md:block"><%= t(".down") %></span>
34
+ </button>
35
+
36
+ <button class="button button__xs button__transparent button__transparent-secondary small alert remove-question button--title">
27
37
  <%= icon("delete-bin-line") %>
28
- <%= t(".remove") %>
38
+ <span class="hidden md:block"><%= t(".remove") %></span>
29
39
  </button>
30
40
  <% end %>
31
41
  </div>
@@ -71,6 +81,6 @@
71
81
 
72
82
  <%= form.hidden_field :position, value: question.position || 0, disabled: !editable %>
73
83
  <%= form.hidden_field :deleted, disabled: !editable %>
74
- <% end %>
84
+ </div>
75
85
  </div>
76
86
  </div>
@@ -1,7 +1,7 @@
1
1
  <% add_decidim_page_title(t("decidim.forms.admin.questionnaires.edit.title")) %>
2
2
 
3
3
  <% if templates_defined? && choose_template? %>
4
- <%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title") } %>
4
+ <%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title"), show_buttons: true } %>
5
5
  <% else %>
6
6
 
7
7
  <div class="item__edit item__edit-1col">
@@ -1,7 +1,7 @@
1
1
  <% add_decidim_page_title(t("decidim.forms.admin.questionnaires.edit.title")) %>
2
2
 
3
3
  <% if templates_defined? && choose_template? %>
4
- <%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title") } %>
4
+ <%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title"), show_buttons: true } %>
5
5
  <% else %>
6
6
 
7
7
  <div class="questionnaire-questions">
@@ -11,20 +11,20 @@
11
11
 
12
12
  <% unless template? questionnaire.questionnaire_for %>
13
13
  <% if questionnaire.questions_editable? %>
14
- <button class="button button__sm button__secondary add-question"><%= t(".add_question") %></button>
15
- <button class="button button__sm button__secondary add-separator"><%= t(".add_separator") %></button>
16
- <button class="button button__sm button__secondary add-title-and-description"><%= t(".add_title_and_description") %></button>
14
+ <button class="button button__sm button__transparent-secondary add-question"><%= t(".add_question") %></button>
15
+ <button class="button button__sm button__transparent-secondary add-separator"><%= t(".add_separator") %></button>
16
+ <button class="button button__sm button__transparent-secondary add-title-and-description"><%= t(".add_title_and_description") %></button>
17
17
  <% end %>
18
18
  <% if allowed_to? :preview, :questionnaire %>
19
19
  <%= link_to t("preview", scope: "decidim.forms.admin.questionnaires.form"), public_url, class: "button button__sm button__transparent-secondary", target: :_blank, data: { "external-link": false } %>
20
20
  <% end %>
21
- <% if questionnaire.answers.any? %>
22
- <%= export_dropdown(current_component, questionnaire.id) if allowed_to? :export_answers, :questionnaire %>
23
- <% if allowed_to? :show, :questionnaire_answers %>
21
+ <% if questionnaire.responses.any? %>
22
+ <%= export_dropdown(current_component, questionnaire.id) if allowed_to? :export_responses, :questionnaire %>
23
+ <% if allowed_to? :show, :questionnaire_responses %>
24
24
  <%= link_to t("actions.show", scope: "decidim.forms.admin.questionnaires"), questionnaire_participants_url, class: "button button__sm button__secondary new whitespace-nowrap" %>
25
25
  <% end %>
26
26
  <% else %>
27
- <button class="button button__sm button__secondary whitespace-nowrap" disabled><%= t("empty", scope: "decidim.forms.admin.questionnaires.answers") %></button>
27
+ <button class="button button__sm button__secondary whitespace-nowrap" disabled><%= t("empty", scope: "decidim.forms.admin.questionnaires.responses") %></button>
28
28
  <% end %>
29
29
  <% end %>
30
30
  </h1>
@@ -0,0 +1,80 @@
1
+ <div class="card" id="responses">
2
+ <div class="item_show__header">
3
+ <h1 class="item_show__header-title">
4
+ <%= t ".title", total: @total %>
5
+ <%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires"), questionnaire_url, class: "button button__sm button__secondary new" %>
6
+ </h1>
7
+ </div>
8
+ <div class="table-stacked">
9
+ <table class="table-list">
10
+ <thead>
11
+ <tr>
12
+ <th>#</th>
13
+ <th><%= first_table_th(@participants.first) %></th>
14
+ <th><%= t("user_status", scope: "decidim.forms.user_responses_serializer") %></th>
15
+ <th><%= t("ip_hash", scope: "decidim.forms.user_responses_serializer") %></th>
16
+ <th><%= t("completion", scope: "decidim.forms.user_responses_serializer") %></th>
17
+ <th><%= t("created_at", scope: "decidim.forms.user_responses_serializer") %></th>
18
+ <th></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody>
22
+ <% @participants.each_with_index do |participant, idx| %>
23
+ <tr>
24
+ <td data-label="#"><%= idx + 1 + page_offset %></td>
25
+ <td data-label="<%= first_table_th(@participants.first) %>">
26
+ <% if allowed_to? :show, :questionnaire_responses %>
27
+ <%= link_to first_table_td(participant), questionnaire_participant_responses_url(participant.session_token) %>
28
+ <% else %>
29
+ <%= first_table_td(participant) %>
30
+ <% end %>
31
+ </td>
32
+ <td data-label="<%= t("user_status", scope: "decidim.forms.user_responses_serializer") %>">
33
+ <%= participant.status %>
34
+ </td>
35
+ <td data-label="<%= t("ip_hash", scope: "decidim.forms.user_responses_serializer") %>">
36
+ <%= participant.ip_hash %>
37
+ </td>
38
+ <td data-label="<%= t("completion", scope: "decidim.forms.user_responses_serializer") %>">
39
+ <%= display_percentage(participant.completion) %>
40
+ </td>
41
+ <td data-label="<%= t("created_at", scope: "decidim.forms.user_responses_serializer") %>">
42
+ <%= l participant.responded_at, format: :short %>
43
+ </td>
44
+ <td data-label="<%= t("actions.actions", scope: "decidim.admin") %>" class="table-list__actions">
45
+ <button type="button" data-controller="dropdown" data-target="actions-participant-<%= participant.id %>"
46
+ aria-label="<%= t("decidim.admin.actions.actions_label", resource: participant.session_token) %>">
47
+ <%= icon "more-fill", class: "text-secondary" %>
48
+ </button>
49
+
50
+ <div class="inline-block relative">
51
+ <ul id="actions-participant-<%= participant.id %>" class="dropdown dropdown__action" aria-hidden="true">
52
+ <% if allowed_to? :show, :questionnaire_responses %>
53
+ <li class="dropdown__item">
54
+ <%= link_to questionnaire_participant_responses_url(participant.session_token), target: "_blank", data: { "external-link": false }, class: "dropdown__button" do %>
55
+ <%= icon "eye-line" %>
56
+ <%= t("actions.show", scope: "decidim.forms.admin.questionnaires.responses") %>
57
+ <% end %>
58
+ </li>
59
+ <% end %>
60
+
61
+ <% if allowed_to? :export_response, :questionnaire_responses %>
62
+ <hr>
63
+
64
+ <li class="dropdown__item">
65
+ <%= link_to questionnaire_export_response_url(participant.session_token), class: "dropdown__button" do %>
66
+ <%= icon "download-line" %>
67
+ <%= t("actions.export", scope: "decidim.forms.admin.questionnaires.responses") %>
68
+ <% end %>
69
+ </li>
70
+ <% end %>
71
+ </ul>
72
+ </div>
73
+ </td>
74
+ </tr>
75
+ <% end %>
76
+ </tbody>
77
+ </table>
78
+ </div>
79
+ </div>
80
+ <%= decidim_paginate @query %>
@@ -0,0 +1,43 @@
1
+ <div class="card" id="responses">
2
+ <div class="item_show__header">
3
+ <h1 class="item_show__header-title">
4
+ <%= t ".title", number: current_idx %>
5
+
6
+ <%= link_to t("actions.next", scope: "decidim.forms.admin.questionnaires.responses").html_safe, next_url, rel: "next", class: "button button__sm button__secondary next" unless last? %>
7
+ <%= link_to t("actions.previous", scope: "decidim.forms.admin.questionnaires.responses").html_safe, prev_url, rel: "prev", class: "button button__sm button__secondary prev" unless first? %>
8
+ <%= link_to t("actions.export", scope: "decidim.forms.admin.questionnaires.responses"), questionnaire_export_response_url(@participant.session_token), class: "button button__sm button__secondary export" %>
9
+ <%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires.responses"), questionnaire_participants_url, class: "button button__sm button__secondary back" %>
10
+ </h1>
11
+ </div>
12
+ <div class="card-section">
13
+ <div class="table">
14
+ <table class="table-list">
15
+ <thead>
16
+ <tr>
17
+ <th><%= t("session_token", scope: "decidim.forms.user_responses_serializer") %></th>
18
+ <th><%= t("user_status", scope: "decidim.forms.user_responses_serializer") %></th>
19
+ <th><%= t("ip_hash", scope: "decidim.forms.user_responses_serializer") %></th>
20
+ <th><%= t("completion", scope: "decidim.forms.user_responses_serializer") %></th>
21
+ <th><%= t("created_at", scope: "decidim.forms.user_responses_serializer") %></th>
22
+ <th></th>
23
+ </tr>
24
+ </thead>
25
+ <tbody>
26
+ <tr>
27
+ <td><%= @participant.session_token %></td>
28
+ <td><%= @participant.status %></td>
29
+ <td><%= @participant.ip_hash %></td>
30
+ <td><%= display_percentage(@participant.completion) %></td>
31
+ <td><%= l @participant.responded_at, format: :short %></td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
35
+ </div>
36
+ <dl class="p-4 [&_ul]:list-disc [&_ul]:pl-4">
37
+ <% @participant.responses.each do |response| %>
38
+ <dt class="font-semibold"><%= response.question %></dt>
39
+ <dd><%= response.body %></dd>
40
+ <% end %>
41
+ </dl>
42
+ </div>
43
+ </div>
@@ -10,54 +10,56 @@
10
10
  <%= cell("decidim/announcement", translated_attribute(questionnaire_for.announcement), callout_class: "warning") %>
11
11
  <% end %>
12
12
 
13
- <%= decidim_form_for(@form, url: update_url, method: :post, html: { multipart: true, class: "form answer-questionnaire" }, data: { "safe-path" => form_path }) do |form| %>
13
+ <%= decidim_form_for(@form, url: update_url, method: :post, html: { multipart: true, class: "form response-questionnaire" }, data: { "safe-path" => form_path }) do |form| %>
14
14
  <%= form_required_explanation %>
15
15
 
16
- <%= form.hidden_field :allow_editing_answers %>
16
+ <%= form.hidden_field :allow_editing_responses %>
17
17
 
18
18
  <%= invisible_captcha %>
19
- <% answer_idx = 0 %>
20
- <% @form.responses_by_step.each_with_index do |step_answers, step_index| %>
21
- <div id="step-<%= step_index %>" class="answer-questionnaire__step" <%= "hidden" if !step_index.zero? %>>
19
+ <% response_idx = 0 %>
20
+ <% cleaned_response_idx = 1 %>
21
+ <% @form.responses_by_step.each_with_index do |step_responses, step_index| %>
22
+ <div id="step-<%= step_index %>" class="response-questionnaire__step" <%= "hidden" if !step_index.zero? %>>
22
23
 
23
24
  <% if @form.total_steps > 1 %>
24
- <p class="answer-questionnaire__step-counter">
25
+ <p class="response-questionnaire__step-counter">
25
26
  <%= t("decidim.forms.questionnaires.show.current_step", step: step_index + 1) %>&nbsp;<%= t("decidim.forms.questionnaires.show.of_total_steps", total_steps: @form.total_steps) %></span>
26
27
  </p>
27
28
  <% end %>
28
29
 
29
- <% step_answers.each do |answer| %>
30
- <div class="answer question" data-max-choices="<%= answer.question.max_choices %>" data-conditioned="<%= answer.question.display_conditions.any? %>" data-question-id="<%= answer.question.id %>">
31
- <% answer.question.display_conditions.each do |display_condition| %>
30
+ <% step_responses.each do |response| %>
31
+ <div class="response question" data-max-choices="<%= response.question.max_choices %>" data-conditioned="<%= response.question.display_conditions.any? %>" data-question-id="<%= response.question.id %>">
32
+ <% response.question.display_conditions.each do |display_condition| %>
32
33
  <%= content_tag :div, nil, class: "display-condition", data: display_condition.to_html_data %>
33
34
  <% end %>
34
35
 
35
- <%= fields_for "questionnaire[responses][#{answer_idx}]", answer do |answer_form| %>
36
+ <%= fields_for "questionnaire[responses][#{response_idx}]", response do |response_form| %>
36
37
  <%= render(
37
- "decidim/forms/questionnaires/answer",
38
- answer_form:,
39
- answer:,
40
- answer_idx:,
38
+ "decidim/forms/questionnaires/response",
39
+ response_form:,
40
+ response:,
41
+ response_idx:,
42
+ cleaned_response_idx:,
41
43
  disabled: !current_participatory_space.can_participate?(current_user)
42
44
  ) %>
43
45
  <% end %>
44
46
  </div>
45
47
 
46
- <% answer_idx += 1 %>
48
+ <% if !(response.question.separator? || response.question.title_and_description?) %>
49
+ <% cleaned_response_idx += 1 %>
50
+ <% end %>
51
+
52
+ <% response_idx += 1 %>
47
53
 
48
54
  <% end %>
49
55
 
50
- <div class="answer-questionnaire__footer">
56
+ <div class="response-questionnaire__footer">
51
57
  <% if step_index + 1 == @form.total_steps %>
52
- <% if show_represent_user_group? %>
53
- <%= cell("decidim/represent_user_group", form) %>
54
- <% end %>
55
-
56
58
  <% if show_public_participation? %>
57
59
  <%= cell("decidim/public_participation", form) %>
58
60
  <% end %>
59
61
 
60
- <div class="answer-questionnaire__tos">
62
+ <div class="response-questionnaire__tos">
61
63
  <%= form.check_box :tos_agreement, label: t("decidim.forms.questionnaires.show.tos_agreement"), id: "questionnaire_tos_agreement", disabled: !current_participatory_space.can_participate?(current_user) %>
62
64
  <div>
63
65
  <%= decidim_sanitize_editor translated_attribute questionnaire.tos %>
@@ -71,7 +73,7 @@
71
73
  total_steps: @form.total_steps,
72
74
  button_disabled: !current_participatory_space.can_participate?(current_user),
73
75
  form:,
74
- allow_editing_answers: questionnaire_for.try(:allow_editing_answers?)
76
+ allow_editing_responses: questionnaire_for.try(:allow_editing_responses?)
75
77
  ) %>
76
78
  </div>
77
79
  </div>
@@ -1,7 +1,12 @@
1
- <%= render partial: "decidim/devise/shared/login_boxes", locals: { scope: "decidim.forms.questionnaires.show.answer_questionnaire" } %>
1
+ <%# i18n-tasks-use t("decidim.forms.questionnaires.show.response_questionnaire.already_have_an_account?") %>
2
+ <%# i18n-tasks-use t("decidim.forms.questionnaires.show.response_questionnaire.are_you_new?") %>
3
+ <%# i18n-tasks-use t("decidim.forms.questionnaires.show.response_questionnaire.sign_in_description") %>
4
+ <%# i18n-tasks-use t("decidim.forms.questionnaires.show.response_questionnaire.sign_up_description") %>
5
+ <%# i18n-tasks-use t("decidim.forms.questionnaires.show.response_questionnaire.title") %>
6
+ <%= render partial: "decidim/devise/shared/login_boxes", locals: { scope: "decidim.forms.questionnaires.show.response_questionnaire" } %>
2
7
 
3
- <div class="answer-questionnaire mt-12">
4
- <ol class="answer-questionnaire__step">
8
+ <div class="response-questionnaire mt-12">
9
+ <ol class="response-questionnaire__step">
5
10
  <%= cell(
6
11
  "decidim/forms/question_readonly",
7
12
  collection: @questionnaire.questions.not_conditioned.not_separator,
@@ -0,0 +1,61 @@
1
+ <% field_id = "questionnaire_responses_#{response_idx}" %>
2
+
3
+ <% if response.question.separator? %>
4
+
5
+ <%= render partial: "decidim/forms/questionnaires/responses/#{response.question.question_type}", locals: { response:, response_form:, response_idx:, field_id:, disabled: } %>
6
+ <%= response_form.hidden_field :question_id %>
7
+
8
+ <% elsif response.question.title_and_description? %>
9
+
10
+ <div class="response-questionnaire__step-heading">
11
+ <h3 class="h3"><%= translated_attribute(response.question.body) %></h3>
12
+ <% if translated_attribute(response.question.description).present? %>
13
+ <div>
14
+ <%= decidim_sanitize_editor_admin translated_attribute(response.question.description) %>
15
+ </div>
16
+ <% end %>
17
+ </div>
18
+
19
+ <%= render partial: "decidim/forms/questionnaires/responses/#{response.question.question_type}", locals: { response:, response_form:, response_idx:, field_id:, disabled: } %>
20
+ <%= response_form.hidden_field :question_id %>
21
+
22
+ <% else %>
23
+
24
+ <div class="response-questionnaire__question">
25
+ <%
26
+ label_options = {
27
+ class: "response-questionnaire__question-label questionnaire-question",
28
+ data: { "response-idx": cleaned_response_idx }
29
+ }
30
+ label_options[:for] = nil if %w(matrix_single matrix_multiple single_option multiple_option).include?(response.question.question_type)
31
+ %>
32
+
33
+ <%= label_tag field_id, **label_options do %>
34
+ <%= translated_attribute(response.question.body) %>
35
+ <% if response.question.mandatory? %>
36
+ <%= response_form.send(:required_indicator) %>
37
+ <% end %>
38
+ <% if response.question.max_choices %>
39
+ <%= " (#{response.send(:max_choices_label)})" %>
40
+ <% end %>
41
+ <% end %>
42
+
43
+ <% if translated_attribute(response.question.description).present? %>
44
+ <div class="response-questionnaire__question-description">
45
+ <%= decidim_sanitize_editor_admin translated_attribute(response.question.description) %>
46
+ </div>
47
+ <% end %>
48
+
49
+ <% if response.question.max_choices %>
50
+ <small class="form-error max-choices-alert"><%= t(".max_choices_alert") %></small>
51
+ <% end %>
52
+
53
+ <% %w(short_answer long_answer).exclude?(response&.question&.question_type) && response.errors.full_messages.each do |msg| %>
54
+ <small class="form-error is-visible"><%= msg %></small>
55
+ <% end %>
56
+
57
+ <%= render partial: "decidim/forms/questionnaires/responses/#{response.question.question_type}", locals: { response:, response_form:, response_idx:, field_id:, disabled:, maxlength: (response.question.max_characters if response.question.max_characters.positive?) } %>
58
+ <%= response_form.hidden_field :question_id %>
59
+ </div>
60
+
61
+ <% end %>
@@ -29,8 +29,8 @@
29
29
  <% end %>
30
30
 
31
31
  <section>
32
- <% if allow_answers? %>
33
- <% if visitor_can_answer? %>
32
+ <% if allow_responses? %>
33
+ <% if visitor_can_respond? %>
34
34
  <% if @form.responses_by_step.flatten.empty? %>
35
35
  <%= cell("decidim/announcement", t("decidim.forms.questionnaires.show.empty")) %>
36
36
  <% else %>
@@ -0,0 +1 @@
1
+ <%= response_form.upload :add_documents, attachments: response.documents, label: false, multiple: true, id: field_id, disabled:, button_class: "button button__lg button__transparent-secondary w-full" %>
@@ -0,0 +1,3 @@
1
+ <div>
2
+ <%= response_form.text_area :body, label: false, id: field_id, rows: 10, disabled:, maxlength:, class: "w-full", required: false, data: { controller: "character-counter" } %>
3
+ </div>