decidim-demographics 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 (107) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +26 -0
  3. data/Rakefile +3 -0
  4. data/app/commands/decidim/demographics/admin/update_demographics_settings.rb +44 -0
  5. data/app/commands/decidim/demographics/delete_demographic_data.rb +24 -0
  6. data/app/controllers/decidim/demographics/admin/application_controller.rb +42 -0
  7. data/app/controllers/decidim/demographics/admin/publish_responses_controller.rb +24 -0
  8. data/app/controllers/decidim/demographics/admin/questions_controller.rb +33 -0
  9. data/app/controllers/decidim/demographics/admin/responses_controller.rb +36 -0
  10. data/app/controllers/decidim/demographics/admin/settings_controller.rb +33 -0
  11. data/app/controllers/decidim/demographics/application_controller.rb +17 -0
  12. data/app/controllers/decidim/demographics/demographics_controller.rb +70 -0
  13. data/app/forms/decidim/demographics/admin/demographics_settings_form.rb +11 -0
  14. data/app/helpers/decidim/demographics/publish_responses_helper.rb +104 -0
  15. data/app/models/decidim/demographics/application_record.rb +10 -0
  16. data/app/models/decidim/demographics/demographic.rb +9 -0
  17. data/app/packs/entrypoints/decidim_demographics.js +1 -0
  18. data/app/packs/stylesheets/decidim/demographics/demographics.scss +37 -0
  19. data/app/permissions/decidim/demographics/admin/permissions.rb +22 -0
  20. data/app/permissions/decidim/demographics/permissions.rb +23 -0
  21. data/app/views/decidim/demographics/admin/demographics/_tabs_menu.html.erb +15 -0
  22. data/app/views/decidim/demographics/admin/publish_responses/index.html.erb +36 -0
  23. data/app/views/decidim/demographics/admin/questions/_questions_form.html.erb +74 -0
  24. data/app/views/decidim/demographics/admin/questions/edit.html.erb +13 -0
  25. data/app/views/decidim/demographics/admin/responses/index.html.erb +98 -0
  26. data/app/views/decidim/demographics/admin/settings/show.html.erb +23 -0
  27. data/app/views/decidim/demographics/demographics/_questionnaire.html.erb +88 -0
  28. data/app/views/decidim/demographics/demographics/_response.html.erb +41 -0
  29. data/app/views/decidim/demographics/demographics/responses/_single_option.html.erb +19 -0
  30. data/app/views/decidim/demographics/demographics/show.html.erb +25 -0
  31. data/config/assets.rb +8 -0
  32. data/config/locales/am-ET.yml +1 -0
  33. data/config/locales/ar.yml +1 -0
  34. data/config/locales/bg.yml +1 -0
  35. data/config/locales/bn-BD.yml +1 -0
  36. data/config/locales/bs-BA.yml +1 -0
  37. data/config/locales/ca-IT.yml +79 -0
  38. data/config/locales/ca.yml +79 -0
  39. data/config/locales/cs.yml +55 -0
  40. data/config/locales/da.yml +1 -0
  41. data/config/locales/de.yml +79 -0
  42. data/config/locales/el.yml +1 -0
  43. data/config/locales/en.yml +79 -0
  44. data/config/locales/eo.yml +1 -0
  45. data/config/locales/es-MX.yml +79 -0
  46. data/config/locales/es-PY.yml +79 -0
  47. data/config/locales/es.yml +79 -0
  48. data/config/locales/et.yml +1 -0
  49. data/config/locales/eu.yml +79 -0
  50. data/config/locales/fa-IR.yml +1 -0
  51. data/config/locales/fi-plain.yml +79 -0
  52. data/config/locales/fi.yml +79 -0
  53. data/config/locales/fr-CA.yml +79 -0
  54. data/config/locales/fr.yml +79 -0
  55. data/config/locales/ga-IE.yml +1 -0
  56. data/config/locales/gl.yml +1 -0
  57. data/config/locales/gn-PY.yml +1 -0
  58. data/config/locales/he-IL.yml +1 -0
  59. data/config/locales/hr.yml +1 -0
  60. data/config/locales/hu.yml +1 -0
  61. data/config/locales/id-ID.yml +1 -0
  62. data/config/locales/is-IS.yml +1 -0
  63. data/config/locales/it.yml +1 -0
  64. data/config/locales/ja.yml +79 -0
  65. data/config/locales/ka-GE.yml +1 -0
  66. data/config/locales/kaa.yml +1 -0
  67. data/config/locales/ko.yml +1 -0
  68. data/config/locales/lb.yml +1 -0
  69. data/config/locales/lo-LA.yml +1 -0
  70. data/config/locales/lt.yml +1 -0
  71. data/config/locales/lv.yml +1 -0
  72. data/config/locales/mt.yml +1 -0
  73. data/config/locales/nl.yml +1 -0
  74. data/config/locales/no.yml +8 -0
  75. data/config/locales/oc-FR.yml +1 -0
  76. data/config/locales/om-ET.yml +1 -0
  77. data/config/locales/pl.yml +1 -0
  78. data/config/locales/pt-BR.yml +1 -0
  79. data/config/locales/pt.yml +1 -0
  80. data/config/locales/ro-RO.yml +1 -0
  81. data/config/locales/ru.yml +1 -0
  82. data/config/locales/si-LK.yml +1 -0
  83. data/config/locales/sk.yml +1 -0
  84. data/config/locales/sl.yml +1 -0
  85. data/config/locales/so-SO.yml +1 -0
  86. data/config/locales/sq-AL.yml +1 -0
  87. data/config/locales/sr-CS.yml +1 -0
  88. data/config/locales/sv.yml +79 -0
  89. data/config/locales/sw-KE.yml +1 -0
  90. data/config/locales/th-TH.yml +1 -0
  91. data/config/locales/ti-ER.yml +1 -0
  92. data/config/locales/tr-TR.yml +1 -0
  93. data/config/locales/uk.yml +1 -0
  94. data/config/locales/val-ES.yml +1 -0
  95. data/config/locales/vi.yml +1 -0
  96. data/config/locales/zh-CN.yml +1 -0
  97. data/config/locales/zh-TW.yml +1 -0
  98. data/db/migrate/20250305200253_create_decidim_demographics_demographics.rb +12 -0
  99. data/decidim-demographics.gemspec +37 -0
  100. data/lib/decidim/demographics/admin.rb +10 -0
  101. data/lib/decidim/demographics/admin_engine.rb +83 -0
  102. data/lib/decidim/demographics/engine.rb +41 -0
  103. data/lib/decidim/demographics/test/factories.rb +16 -0
  104. data/lib/decidim/demographics/version.rb +10 -0
  105. data/lib/decidim/demographics.rb +52 -0
  106. data/lib/tasks/decidim_demographics.rake +14 -0
  107. metadata +195 -0
@@ -0,0 +1,74 @@
1
+ <div class="questionnaire-questions form__wrapper">
2
+ <div class="row column text-center my-4">
3
+ <% if questionnaire.questions_editable? %>
4
+ <button class="button button__xs button__transparent-secondary add-question"><%= t(".add_question") %></button>
5
+ <% end %>
6
+ <button type="button" class="button button__xs button__transparent-secondary collapse-all"><%= t(".collapse") %></button>
7
+ <button type="button" class="button button__xs button__transparent-secondary expand-all"><%= t(".expand") %></button>
8
+ </div>
9
+
10
+ <%= fields_for "questions[questions][#{blank_question.to_param}]", blank_question do |question_form| %>
11
+ <script type="text/template" class="decidim-question-template decidim-template" id="question-template">
12
+ <%= render "decidim/forms/admin/questionnaires/question",
13
+ form: question_form,
14
+ id: tabs_id_for_question(blank_question),
15
+ editable: questionnaire.questions_editable?,
16
+ response_option_template_selector: "#response-option-template-dummy",
17
+ display_condition_template_selector: "#display-condition-template-dummy",
18
+ matrix_row_template_selector: "#matrix-row-template-dummy" %>
19
+ </script>
20
+ <script type="text/template" class="decidim-separator-template decidim-template" id="separator-template">
21
+ <%= render "decidim/forms/admin/questionnaires/separator",
22
+ form: question_form,
23
+ id: tabs_id_for_question(blank_question),
24
+ editable: questionnaire.questions_editable? %>
25
+ </script>
26
+ <script type="text/template" class="decidim-title-and-description-template decidim-template" id="title-and-description-template">
27
+ <%= render "decidim/forms/admin/questionnaires/title_and_description",
28
+ form: question_form,
29
+ id: tabs_id_for_question(blank_question),
30
+ editable: questionnaire.questions_editable? %>
31
+ </script>
32
+ <%= render "decidim/forms/admin/questionnaires/response_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "response-option-template-dummy" %>
33
+ <%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-dummy" %>
34
+ <%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-dummy" %>
35
+ <% end %>
36
+ <div class="questionnaire-questions-list flex flex-col py-6 gap-6 last:pb-0">
37
+ <% @form.questions.each_with_index do |question, index| %>
38
+ <%= fields_for "questions[questions][]", question do |question_form| %>
39
+ <% if question.separator? %>
40
+ <%= render "decidim/forms/admin/questionnaires/separator",
41
+ form: question_form,
42
+ id: tabs_id_for_question(question),
43
+ editable: questionnaire.questions_editable? %>
44
+ <% elsif question.title_and_description? %>
45
+ <%= render "decidim/forms/admin/questionnaires/title_and_description",
46
+ form: question_form,
47
+ id: tabs_id_for_question(question),
48
+ editable: questionnaire.questions_editable? %>
49
+ <% else %>
50
+ <%= render "decidim/forms/admin/questionnaires/question",
51
+ form: question_form,
52
+ id: tabs_id_for_question(question),
53
+ editable: questionnaire.questions_editable?,
54
+ display_condition_template_selector: "#display-condition-template-#{index}",
55
+ response_option_template_selector: "#response-option-template-#{index}",
56
+ matrix_row_template_selector: "#matrix-row-template-#{index}" %>
57
+ <%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-#{index}" %>
58
+ <%= render "decidim/forms/admin/questionnaires/response_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "response-option-template-#{index}" %>
59
+ <%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-#{index}" %>
60
+ <% end %>
61
+ <% end %>
62
+ <% end %>
63
+ </div>
64
+ </div>
65
+
66
+ <%= append_javascript_pack_tag "decidim_forms_admin" %>
67
+
68
+ <% if questionnaire.questions_editable? %>
69
+ <script>
70
+ document.addEventListener("turbo:load", function () {
71
+ window.Decidim.createEditableForm();
72
+ });
73
+ </script>
74
+ <% end %>
@@ -0,0 +1,13 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+
3
+ <%= render "decidim/demographics/admin/demographics/tabs_menu" do %>
4
+ <%= button_tag t("decidim.demographics.admin.questions.edit.save"), class: "main-tabs-menu__cta-button", form: "survey-form" %>
5
+ <% end %>
6
+
7
+ <div class="item__edit item__edit-1col">
8
+ <div class="item__edit-form">
9
+ <%= decidim_form_for(@form, url: update_questions_questions_path, method: :patch, html: { id: "survey-form", class: "form-defaults form edit_questions_survey" }) do |form| %>
10
+ <%= render partial: "questions_form", object: form %>
11
+ <% end %>
12
+ </div>
13
+ </div>
@@ -0,0 +1,98 @@
1
+ <% add_decidim_page_title(t(".title", total: @total)) %>
2
+
3
+ <%= render "decidim/demographics/admin/demographics/tabs_menu" do %>
4
+ <div>
5
+ <% if allowed_to? :index, :demographics_responses %>
6
+ <% if @participants.count.zero? %>
7
+ <%= link_to t("publish_responses", scope: "decidim.demographics.admin.responses.index"), "#", class: "main-tabs-menu__cta-button", disabled: true %>
8
+ <% else %>
9
+ <%= link_to t("publish_responses", scope: "decidim.demographics.admin.responses.index"), publish_responses_path, class: "main-tabs-menu__cta-button" %>
10
+ <% end %>
11
+ <% end %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <% if @participants.count.zero? %>
16
+ <%= cell("decidim/announcement", { body: t("decidim.surveys.admin.responses.index.no_responses") }) %>
17
+ <% end %>
18
+
19
+ <div class="card" id="responses">
20
+ <div class="item_show__header">
21
+ <h1 class="item_show__header-title">
22
+ <%= t ".title", total: @total %>
23
+ </h1>
24
+ </div>
25
+ <div class="table-stacked">
26
+ <table class="table-list">
27
+ <thead>
28
+ <tr>
29
+ <th>#</th>
30
+ <th class="!text-left"><%= first_table_th(@participants.first) %></th>
31
+ <th><%= t("user_status", scope: "decidim.forms.user_responses_serializer") %></th>
32
+ <th><%= t("ip_hash", scope: "decidim.forms.user_responses_serializer") %></th>
33
+ <th><%= t("completion", scope: "decidim.forms.user_responses_serializer") %></th>
34
+ <th><%= t("created_at", scope: "decidim.forms.user_responses_serializer") %></th>
35
+ <th><%= t("actions.title", scope: "decidim.demographics") %></th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <% @participants.each_with_index do |participant, idx| %>
40
+ <tr>
41
+ <td data-label="#">
42
+ <%= idx + 1 + page_offset %>
43
+ </td>
44
+ <td class="!text-left" data-label="<%= first_table_th(@participants.first) %>">
45
+ <% if allowed_to? :show, :questionnaire_responses %>
46
+ <%= link_to first_table_td(participant), questionnaire_participant_responses_url(participant.session_token) %>
47
+ <% else %>
48
+ <%= first_table_td(participant) %></td>
49
+ <% end %>
50
+ <td data-label="<%= t("user_status", scope: "decidim.forms.user_responses_serializer") %>">
51
+ <%= participant.status %>
52
+ </td>
53
+ <td data-label="<%= t("ip_hash", scope: "decidim.forms.user_responses_serializer") %>">
54
+ <%= participant.ip_hash %>
55
+ </td>
56
+ <td data-label="<%= t("completion", scope: "decidim.forms.user_responses_serializer") %>">
57
+ <%= display_percentage(participant.completion) %>
58
+ </td>
59
+ <td data-label="<%= t("created_at", scope: "decidim.forms.user_responses_serializer") %>">
60
+ <%= l participant.responded_at, format: :short %>
61
+ </td>
62
+ <td data-label="<%= t("actions.title", scope: "decidim.demographics") %>" class="table-list__actions">
63
+ <button type="button" data-controller="dropdown" data-target="actions-participant-<%= idx %>" aria-label="<%= t("decidim.admin.actions.actions_label") %>">
64
+ <%= icon "more-fill", class: "text-secondary" %>
65
+ </button>
66
+
67
+ <div class="inline-block relative">
68
+ <ul id="actions-participant-<%= idx %>" class="dropdown dropdown__action" aria-hidden="true">
69
+ <% if allowed_to? :show, :demographics_responses %>
70
+ <li class="dropdown__item">
71
+ <%= link_to questionnaire_participant_responses_url(participant.session_token), target: "_blank", data: { "external-link": false }, class: "dropdown__button" do %>
72
+ <%= icon "eye-line" %>
73
+ <%= t("actions.show", scope: "decidim.forms.admin.questionnaires.responses") %>
74
+ <% end %>
75
+ </li>
76
+
77
+ <hr>
78
+ <% end %>
79
+
80
+ <% if allowed_to? :export_response, :demographics_responses %>
81
+ <li class="dropdown__item">
82
+ <%= link_to questionnaire_export_response_url(participant.session_token), class: "dropdown__button" do %>
83
+ <%= icon "download-line" %>
84
+ <%= t("actions.export", scope: "decidim.forms.admin.questionnaires.responses") %>
85
+ <% end %>
86
+ </li>
87
+ <% end %>
88
+ </ul>
89
+ </div>
90
+
91
+ </td>
92
+ </tr>
93
+ <% end %>
94
+ </tbody>
95
+ </table>
96
+ </div>
97
+ </div>
98
+ <%= decidim_paginate @query %>
@@ -0,0 +1,23 @@
1
+ <% add_decidim_page_title(t(".title")) %>
2
+
3
+ <%= render "decidim/demographics/admin/demographics/tabs_menu" do %>
4
+ <div>
5
+ <%= button_tag t("decidim.demographics.admin.settings.show.save"), class: "main-tabs-menu__cta-button", form: "survey-form" %>
6
+ </div>
7
+ <% end %>
8
+
9
+ <div class="item__edit item__edit-1col">
10
+ <div class="item__edit-form">
11
+ <%= decidim_form_for(@form, url: decidim_admin_demographics.settings_path, html: { id: "survey-form", class: "form-defaults form edit_questionnaire" }) do |form| %>
12
+ <div class="form__wrapper">
13
+ <div class="card pt-4">
14
+ <div class="card-section">
15
+ <div class="row column">
16
+ <%= form.check_box :collect_data, help_text: t(".collect_data_help"), label: t(".collect_data"), aria: { label: :collect_data } %>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ <% end %>
22
+ </div>
23
+ </div>
@@ -0,0 +1,88 @@
1
+ <noscript>
2
+ <%= cell("decidim/announcement", { title: t("decidim.forms.questionnaires.show.questionnaire_js_disabled.title"), body: t("decidim.forms.questionnaires.show.questionnaire_js_disabled.body") }, callout_class: "warning") %>
3
+ </noscript>
4
+
5
+ <% if questionnaire_for.respond_to?(:announcement) and questionnaire_for.announcement.present? %>
6
+ <%= cell("decidim/announcement", translated_attribute(questionnaire_for.announcement), callout_class: "warning") %>
7
+ <% end %>
8
+
9
+ <%= decidim_form_for(@form, url: update_url, method: :post, html: { multipart: true, class: "form demographic response-questionnaire" }, data: { "safe-path" => form_path }) do |form| %>
10
+
11
+ <%= invisible_captcha %>
12
+
13
+ <% response_idx = 0 %>
14
+ <% cleaned_response_idx = 1 %>
15
+
16
+ <div id="step-0" class="response-questionnaire__step">
17
+ <% @form.responses.each_with_index do |response, step_index| %>
18
+ <div class="response question" data-max-choices="<%= response.question.max_choices %>" data-conditioned="<%= response.question.display_conditions.any? %>" data-question-id="<%= response.question.id %>">
19
+ <% response.question.display_conditions.each do |display_condition| %>
20
+ <%= content_tag :div, nil, class: "display-condition", data: display_condition.to_html_data %>
21
+ <% end %>
22
+
23
+ <%= fields_for "questionnaire[responses][#{response_idx}]", response do |response_form| %>
24
+ <%= render(
25
+ "decidim/demographics/demographics/response",
26
+ response_form:,
27
+ response:,
28
+ response_idx:,
29
+ cleaned_response_idx:,
30
+ disabled: false
31
+ ) %>
32
+ <% end %>
33
+ </div>
34
+
35
+ <% if !(response.question.separator? || response.question.title_and_description?) %>
36
+ <% cleaned_response_idx += 1 %>
37
+ <% end %>
38
+
39
+ <% response_idx += 1 %>
40
+ <% end %>
41
+ <div class="response-questionnaire__footer">
42
+ <div class="response-questionnaire__tos">
43
+ <%= form.check_box :tos_agreement, label: t(".tos_agreement", link: link_to(t(".terms_of_service"), decidim.page_path("terms-of-service"))), label_options: { class: "form__wrapper-checkbox-label" } %>
44
+
45
+ <div>
46
+ <%= decidim_sanitize_editor translated_attribute questionnaire.tos %>
47
+ </div>
48
+ </div>
49
+
50
+ <div class="form__wrapper-block flex-col-reverse md:flex-row ml-auto pt-0">
51
+
52
+ <% if visitor_already_responded? %>
53
+ <button type="button" data-dialog-open="delete-answers" class="button button__sm md:button__lg button__transparent-secondary ml-auto mr-0 open-modal-button">
54
+ <%= t(".delete_my_data") %>
55
+ </button>
56
+ <% end %>
57
+
58
+ <%= form.submit(
59
+ t(".submit"),
60
+ class: "button button__sm md:button__lg button__secondary mr-auto !ml-0",
61
+ disabled: !demographic.collect_data?
62
+ ) %>
63
+
64
+ </div>
65
+ </div>
66
+ </div>
67
+ <% end %>
68
+
69
+ <%= decidim_modal id: "delete-answers", class:"verification-modal" do %>
70
+ <div data-dialog-container>
71
+ <%= icon "delete-bin-line" %>
72
+ <h3 class="h3" id="dialog-title-delete-account" data-dialog-title>
73
+ <%= t(".modal_title") %>
74
+ </h3>
75
+ <div data-confirm-modal-content="">
76
+ <%= t(".modal_question") %>
77
+ </div>
78
+ </div>
79
+ <div data-dialog-actions>
80
+ <button type="button" class="button button__sm md:button__lg button__transparent-secondary" data-dialog-close="delete-answers">
81
+ <%= t(".modal_close") %>
82
+ </button>
83
+
84
+ <%= button_to demographics_engine.demographics_path, method: :delete, class: "button button__sm md:button__lg button__secondary" do %>
85
+ <%= t(".modal_ok") %>
86
+ <% end %>
87
+ </div>
88
+ <% end %>
@@ -0,0 +1,41 @@
1
+ <% field_id = "questionnaire_responses_#{response_idx}" %>
2
+ <div class="response-questionnaire__question">
3
+ <%
4
+ label_options = {
5
+ class: "response-questionnaire__question-label questionnaire-question",
6
+ data: { "response-idx": cleaned_response_idx }
7
+ }
8
+ label_options[:for] = nil if %w(matrix_single matrix_multiple single_option multiple_option).include?(response.question.question_type)
9
+ %>
10
+
11
+ <%= label_tag field_id, **label_options do %>
12
+ <%= translated_attribute(response.question.body) %>
13
+ <% if response.question.mandatory? %>
14
+ <%= response_form.send(:required_indicator) %>
15
+ <% end %>
16
+ <% if response.question.max_choices %>
17
+ <%= " (#{response.send(:max_choices_label)})" %>
18
+ <% end %>
19
+ <% end %>
20
+
21
+ <% if translated_attribute(response.question.description).present? %>
22
+ <div class="response-questionnaire__question-description">
23
+ <%= decidim_sanitize_editor_admin translated_attribute(response.question.description) %>
24
+ </div>
25
+ <% end %>
26
+
27
+ <% if response.question.max_choices %>
28
+ <small class="form-error max-choices-alert"><%= t("decidim.forms.questionnaires.response.max_choices_alert") %></small>
29
+ <% end %>
30
+
31
+ <% response.errors.full_messages.each do |msg| %>
32
+ <small class="form-error is-visible"><%= msg %></small>
33
+ <% end %>
34
+ <% if lookup_context.template_exists?("decidim/demographics/demographics/responses/_#{response.question.question_type}") %>
35
+ <%= render partial: "decidim/demographics/demographics/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?) } %>
36
+ <% else %>
37
+ <%= 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?) } %>
38
+ <% end %>
39
+
40
+ <%= response_form.hidden_field :question_id %>
41
+ </div>
@@ -0,0 +1,19 @@
1
+ <div>
2
+ <%= hidden_field_tag "questionnaire[responses][#{response_idx}][choices][][body]", translated_attribute(response.question.response_options.first.body) %>
3
+ <%= response_form.collection_select :body,
4
+ response.question.response_options,
5
+ :id,
6
+ ->(response_option) { translated_attribute(response_option.body) },
7
+ {
8
+ selected: response.choices.first.try(:response_option_id),
9
+ label: false
10
+ },
11
+ {
12
+ name: "questionnaire[responses][#{response_idx}][choices][][response_option_id]",
13
+ id: field_id,
14
+ disabled:,
15
+ maxlength:,
16
+ class: "w-full",
17
+ onchange: "setFormFieldValue('#{field_id}', 'questionnaire[responses][#{response_idx}][choices][][body]')"
18
+ } %>
19
+ </div>
@@ -0,0 +1,25 @@
1
+ <% add_decidim_meta_tags({
2
+ title: translated_attribute(questionnaire.title),
3
+ description: translated_attribute(questionnaire.description)
4
+ }) %>
5
+
6
+ <%= append_stylesheet_pack_tag "decidim_forms" %>
7
+ <%= append_stylesheet_pack_tag "decidim_demographics" %>
8
+ <%= append_javascript_pack_tag "decidim_forms" %>
9
+
10
+ <% content_for :profile_title do %>
11
+ <%= t(".page_title") %>
12
+ <% end %>
13
+
14
+ <%= render layout: "layouts/decidim/shared/layout_user_profile" do %>
15
+ <%= t("layouts.decidim.shared.layout_center.alert") %>
16
+ <%= render partial: "decidim/demographics/demographics/questionnaire" %>
17
+ <% end %>
18
+
19
+ <script>
20
+ function setFormFieldValue(field_id, field_to_update) {
21
+ const element = document.getElementById(field_id);
22
+
23
+ document.querySelector(`input[name='${field_to_update}']`).value = element.options[element.selectedIndex].text;
24
+ }
25
+ </script>
data/config/assets.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ base_path = File.expand_path("..", __dir__)
4
+
5
+ Decidim::Shakapacker.register_path("#{base_path}/app/packs")
6
+ Decidim::Shakapacker.register_entrypoints(
7
+ decidim_demographics: "#{base_path}/app/packs/entrypoints/decidim_demographics.js"
8
+ )
@@ -0,0 +1 @@
1
+ am:
@@ -0,0 +1 @@
1
+ ar:
@@ -0,0 +1 @@
1
+ bg:
@@ -0,0 +1 @@
1
+ bn:
@@ -0,0 +1 @@
1
+ bs:
@@ -0,0 +1,79 @@
1
+ ---
2
+ ca-IT:
3
+ decidim:
4
+ demographics:
5
+ actions:
6
+ title: Accions
7
+ admin:
8
+ demographics:
9
+ tabs_menu:
10
+ title: Dades demogràfiques
11
+ demographics_menu:
12
+ questions: Preguntes
13
+ responses: Respostes
14
+ settings: Configuració
15
+ publish_responses:
16
+ index:
17
+ description: Descripció
18
+ title: Mostrar les respostes
19
+ questions:
20
+ edit:
21
+ save: Desar
22
+ title: Preguntes
23
+ questions_form:
24
+ add_question: Afegir pregunta
25
+ collapse: Replega totes les preguntes
26
+ expand: Desplega totes les preguntes
27
+ responses:
28
+ index:
29
+ publish_responses: Mostrar les respostes
30
+ title: "%{total} respostes en total"
31
+ settings:
32
+ show:
33
+ collect_data: Activar la recol·lecció de dades demogràfiques
34
+ collect_data_help: Habilitant aquesta opció es permetrà a les usuàries facilitar les dades a la plataforma.
35
+ save: Desar
36
+ title: Configuració
37
+ update:
38
+ invalid: S'ha produït un error en desar les dades demogràfiques
39
+ success: Les dades demogràfiques s'han desat correctament
40
+ title: Dades demogràfiques
41
+ demographics:
42
+ questionnaire:
43
+ delete_my_data: Esborrar les dades
44
+ modal_close: Cancel·lar
45
+ modal_ok: D'acord
46
+ modal_question: S'esborraran totes les teves dades demogràfiques.
47
+ modal_title: Esborrar les dades
48
+ submit: Desar les dades
49
+ terms_of_service: termes i condicions d'ús
50
+ tos_agreement: En participar acceptes els %{link}.
51
+ show:
52
+ page_title: Donació de dades demogràfiques
53
+ destroy:
54
+ error: Hi va haver un error eliminant les teves dades demogràfiques donades
55
+ success: Les dades demogràfiques que vas donar s'han eliminat correctament
56
+ name: Donació de dades demogràfiques
57
+ questions:
58
+ age:
59
+ options:
60
+ - entre 15 i 29 anys
61
+ - entre 30 i 44 anys
62
+ - entre 45 i 64 anys
63
+ - 65 anys o més
64
+ question: Quina edat tens?
65
+ gender:
66
+ options:
67
+ - Home
68
+ - Dona
69
+ - No binari
70
+ - El meu gènere no està llistat
71
+ - Prefereixo no respondre
72
+ question: Quina de les opcions següents descriu millor el teu gènere?
73
+ postal:
74
+ question: Quin és el codi postal del teu domicili?
75
+ layouts:
76
+ decidim:
77
+ shared:
78
+ layout_center:
79
+ alert: En proporcionar aquesta informació estàs contribuint a l'anàlisi estadística que ajuda a millorar l'indicador de qualitat. Les teves dades seran agregades i utilitzades només per a finalitats de recerca.
@@ -0,0 +1,79 @@
1
+ ---
2
+ ca:
3
+ decidim:
4
+ demographics:
5
+ actions:
6
+ title: Accions
7
+ admin:
8
+ demographics:
9
+ tabs_menu:
10
+ title: Dades demogràfiques
11
+ demographics_menu:
12
+ questions: Preguntes
13
+ responses: Respostes
14
+ settings: Configuració
15
+ publish_responses:
16
+ index:
17
+ description: Descripció
18
+ title: Mostrar les respostes
19
+ questions:
20
+ edit:
21
+ save: Desar
22
+ title: Preguntes
23
+ questions_form:
24
+ add_question: Afegir pregunta
25
+ collapse: Replega totes les preguntes
26
+ expand: Desplega totes les preguntes
27
+ responses:
28
+ index:
29
+ publish_responses: Mostrar les respostes
30
+ title: "%{total} respostes en total"
31
+ settings:
32
+ show:
33
+ collect_data: Activar la recol·lecció de dades demogràfiques
34
+ collect_data_help: Habilitant aquesta opció es permetrà a les usuàries facilitar les dades a la plataforma.
35
+ save: Desar
36
+ title: Configuració
37
+ update:
38
+ invalid: S'ha produït un error en desar les dades demogràfiques
39
+ success: Les dades demogràfiques s'han desat correctament
40
+ title: Dades demogràfiques
41
+ demographics:
42
+ questionnaire:
43
+ delete_my_data: Esborrar les dades
44
+ modal_close: Cancel·lar
45
+ modal_ok: D'acord
46
+ modal_question: S'esborraran totes les teves dades demogràfiques.
47
+ modal_title: Esborrar les dades
48
+ submit: Desar les dades
49
+ terms_of_service: termes i condicions d'ús
50
+ tos_agreement: En participar acceptes els %{link}.
51
+ show:
52
+ page_title: Donació de dades demogràfiques
53
+ destroy:
54
+ error: Hi va haver un error eliminant les teves dades demogràfiques donades
55
+ success: Les dades demogràfiques que vas donar s'han eliminat correctament
56
+ name: Donació de dades demogràfiques
57
+ questions:
58
+ age:
59
+ options:
60
+ - entre 15 i 29 anys
61
+ - entre 30 i 44 anys
62
+ - entre 45 i 64 anys
63
+ - 65 anys o més
64
+ question: Quina edat tens?
65
+ gender:
66
+ options:
67
+ - Home
68
+ - Dona
69
+ - No binari
70
+ - El meu gènere no està llistat
71
+ - Prefereixo no respondre
72
+ question: Quina de les opcions següents descriu millor el teu gènere?
73
+ postal:
74
+ question: Quin és el codi postal del teu domicili?
75
+ layouts:
76
+ decidim:
77
+ shared:
78
+ layout_center:
79
+ alert: En proporcionar aquesta informació estàs contribuint a l'anàlisi estadística que ajuda a millorar l'indicador de qualitat. Les teves dades seran agregades i utilitzades només per a finalitats de recerca.
@@ -0,0 +1,55 @@
1
+ ---
2
+ cs:
3
+ decidim:
4
+ demographics:
5
+ actions:
6
+ title: Akce
7
+ admin:
8
+ demographics:
9
+ tabs_menu:
10
+ title: Demografie
11
+ demographics_menu:
12
+ questions: Otázky
13
+ responses: Odpovědi
14
+ settings: Nastavení
15
+ publish_responses:
16
+ index:
17
+ description: Popis
18
+ title: Zobrazit odpovědi
19
+ settings:
20
+ show:
21
+ title: Nastavení
22
+ update:
23
+ invalid: Došlo k chybě při ukládání demografických dat
24
+ success: Demografická data byla úspěšně uložena
25
+ title: Demografie
26
+ demographics:
27
+ questionnaire:
28
+ delete_my_data: Smazat data
29
+ modal_close: Zrušit
30
+ modal_ok: Ok
31
+ modal_question: Všechny vaše demografické údaje budou odstraněny.
32
+ modal_title: Smazat data
33
+ questions:
34
+ age:
35
+ options:
36
+ - 15 až 29 let
37
+ - 30 až 44 let
38
+ - 45 až 64 let
39
+ - 65 let a více
40
+ question: Jaký je váš věk?
41
+ gender:
42
+ options:
43
+ - Muž
44
+ - Žena
45
+ - Nebinární
46
+ - Mé pohlaví není uvedeno
47
+ - Nechci uvádět
48
+ question: Který z následujících nejlépe popisuje vaše pohlaví?
49
+ postal:
50
+ question: Jaké je poštovní směrovací číslo vašeho domova?
51
+ layouts:
52
+ decidim:
53
+ shared:
54
+ layout_center:
55
+ alert: Poskytnutím těchto informací přispějete ke statistické analýze, která pomáhá zlepšit ukazatel kvality. Vaše údaje budou agregovány a použity pouze pro výzkumné účely.
@@ -0,0 +1 @@
1
+ da: