decidim-forms 0.20.1 → 0.23.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/admin/decidim_forms_manifest.css +3 -0
- data/app/assets/config/admin/decidim_forms_manifest.js +1 -0
- data/app/assets/config/decidim_forms_manifest.css +1 -0
- data/app/assets/images/decidim/surveys/icon.svg +1 -19
- data/app/assets/javascripts/decidim/forms/admin/auto_select_options_from_url.component.js.es6 +40 -0
- data/app/assets/javascripts/decidim/forms/admin/collapsible_questions.js.es6 +13 -0
- data/app/assets/javascripts/decidim/forms/admin/forms.js.es6 +260 -16
- data/app/assets/javascripts/decidim/forms/admin/live_text_update.component.js.es6 +52 -0
- data/app/assets/javascripts/decidim/forms/autosortable_checkboxes.component.js.es6 +54 -34
- data/app/assets/javascripts/decidim/forms/display_conditions.component.js.es6 +203 -0
- data/app/assets/javascripts/decidim/forms/forms.js.es6 +49 -1
- data/app/assets/javascripts/decidim/forms/max_choices_alert.component.js.es6 +44 -0
- data/app/assets/stylesheets/decidim/forms/forms.scss +39 -0
- data/app/assets/stylesheets/decidim/forms/questionnaire-answers-pdf.scss +69 -0
- data/app/cells/decidim/forms/matrix_readonly/show.erb +5 -0
- data/app/cells/decidim/forms/matrix_readonly_cell.rb +12 -0
- data/app/cells/decidim/forms/question_readonly/show.erb +5 -1
- data/app/cells/decidim/forms/question_readonly_cell.rb +5 -0
- data/app/cells/decidim/forms/step_navigation/show.erb +35 -0
- data/app/cells/decidim/forms/step_navigation_cell.rb +46 -0
- data/app/commands/decidim/forms/admin/update_questionnaire.rb +33 -1
- data/app/commands/decidim/forms/answer_questionnaire.rb +2 -1
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +52 -2
- data/app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb +97 -0
- data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +11 -2
- data/app/forms/decidim/forms/admin/display_condition_form.rb +100 -0
- data/app/forms/decidim/forms/admin/question_form.rb +21 -1
- data/app/forms/decidim/forms/admin/question_matrix_row_form.rb +26 -0
- data/app/forms/decidim/forms/answer_choice_form.rb +1 -0
- data/app/forms/decidim/forms/answer_form.rb +31 -2
- data/app/forms/decidim/forms/questionnaire_form.rb +30 -3
- data/app/helpers/decidim/forms/admin/application_helper.rb +37 -0
- data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_pagination_helper.rb +49 -0
- data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb +40 -0
- data/app/helpers/decidim/forms/admin/questionnaire_answers_helper.rb +27 -0
- data/app/jobs/decidim/forms/export_questionnaire_answers_job.rb +19 -0
- data/app/models/decidim/forms/answer.rb +0 -3
- data/app/models/decidim/forms/answer_choice.rb +7 -0
- data/app/models/decidim/forms/answer_option.rb +14 -0
- data/app/models/decidim/forms/display_condition.rb +65 -0
- data/app/models/decidim/forms/question.rb +52 -2
- data/app/models/decidim/forms/question_matrix_row.rb +15 -0
- data/app/models/decidim/forms/questionnaire.rb +11 -1
- data/app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb +43 -0
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +60 -0
- data/app/presenters/decidim/forms/answer_option_presenter.rb +20 -0
- data/app/presenters/decidim/forms/question_presenter.rb +16 -0
- data/app/queries/decidim/forms/questionnaire_participant.rb +35 -0
- data/app/queries/decidim/forms/questionnaire_participants.rb +43 -0
- data/app/types/decidim/forms/answer_option_type.rb +14 -0
- data/app/types/decidim/forms/question_type.rb +23 -0
- data/app/types/decidim/forms/questionnaire_type.rb +22 -0
- data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +1 -1
- data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +88 -0
- data/app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb +7 -0
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +67 -8
- data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +34 -0
- data/app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb +7 -0
- data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +45 -6
- data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +41 -0
- data/app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb +31 -0
- data/app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb +13 -0
- data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +53 -0
- data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +48 -0
- data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +9 -5
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +28 -99
- data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/answers/_matrix_multiple.html.erb +43 -0
- data/app/views/decidim/forms/questionnaires/answers/_matrix_single.html.erb +43 -0
- data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +23 -0
- data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +30 -0
- data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +23 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +78 -26
- data/app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb +12 -0
- data/config/initializers/wicked_pdf.rb +25 -0
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +7 -4
- data/config/locales/bg-BG.yml +14 -0
- data/config/locales/bg.yml +14 -0
- data/config/locales/ca.yml +89 -5
- data/config/locales/cs.yml +89 -5
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +92 -4
- data/config/locales/el.yml +118 -0
- data/config/locales/en.yml +89 -5
- data/config/locales/eo.yml +1 -0
- data/config/locales/es-MX.yml +88 -4
- data/config/locales/es-PY.yml +88 -4
- data/config/locales/es.yml +88 -4
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +7 -4
- data/config/locales/fi-plain.yml +88 -4
- data/config/locales/fi.yml +88 -4
- data/config/locales/fr-CA.yml +172 -0
- data/config/locales/fr.yml +89 -5
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +7 -4
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +11 -5
- data/config/locales/id-ID.yml +7 -4
- data/config/locales/is.yml +1 -0
- data/config/locales/it.yml +89 -5
- data/config/locales/ja-JP.yml +170 -0
- data/config/locales/ja.yml +170 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +118 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +92 -8
- data/config/locales/no.yml +54 -5
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +113 -26
- data/config/locales/pt-BR.yml +8 -5
- data/config/locales/pt.yml +111 -24
- data/config/locales/ro-RO.yml +167 -0
- data/config/locales/ru.yml +4 -2
- data/config/locales/sk-SK.yml +88 -0
- data/config/locales/sk.yml +90 -0
- data/config/locales/sl.yml +12 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +1 -0
- data/config/locales/sv.yml +88 -7
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +7 -4
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +172 -0
- data/config/locales/zh-TW.yml +1 -0
- data/db/migrate/20200130194123_create_decidim_forms_display_conditions.rb +20 -0
- data/db/migrate/20200225123810_create_decidim_forms_question_matrix_rows.rb +11 -0
- data/db/migrate/20200304152939_add_matrix_row_id_to_decidim_forms_answer_choices.rb +11 -0
- data/lib/decidim/api/questionnaire_entity_interface.rb +18 -0
- data/lib/decidim/exporters/form_pdf.rb +33 -0
- data/lib/decidim/exporters/form_pdf_controller_helper.rb +11 -0
- data/lib/decidim/forms.rb +6 -0
- data/lib/decidim/forms/admin_engine.rb +1 -1
- data/lib/decidim/forms/api.rb +7 -0
- data/lib/decidim/forms/test.rb +6 -0
- data/lib/decidim/forms/test/factories.rb +55 -0
- data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +918 -60
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +108 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +33 -575
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +179 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +463 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +93 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +461 -0
- data/lib/decidim/forms/user_answers_serializer.rb +21 -4
- data/lib/decidim/forms/version.rb +1 -1
- metadata +133 -10
@@ -0,0 +1,41 @@
|
|
1
|
+
<% question = form.object %>
|
2
|
+
|
3
|
+
<div class="card questionnaire-question" id="<%= id %>-field">
|
4
|
+
<div class="card-divider question-divider">
|
5
|
+
<h2 class="card-title">
|
6
|
+
<span>
|
7
|
+
<% if editable %>
|
8
|
+
<%== icon("move") %>
|
9
|
+
<% end %>
|
10
|
+
<%= dynamic_title(t(".separator"), class: "question-title-statement", max_length: 50, omission: "...", placeholder: t(".separator")) %>
|
11
|
+
</span>
|
12
|
+
|
13
|
+
<% if editable %>
|
14
|
+
<button class="button small alert hollow move-up-question button--title">
|
15
|
+
<%== "#{icon("arrow-top")} #{t(".up")}" %>
|
16
|
+
</button>
|
17
|
+
|
18
|
+
<button class="button small alert hollow move-down-question button--title">
|
19
|
+
<%== "#{icon("arrow-bottom")} #{t(".down")}" %>
|
20
|
+
</button>
|
21
|
+
|
22
|
+
<button class="button small alert hollow remove-question button--title">
|
23
|
+
<%= t(".remove") %>
|
24
|
+
</button>
|
25
|
+
<% end %>
|
26
|
+
</h2>
|
27
|
+
|
28
|
+
<%=
|
29
|
+
form.hidden_field(
|
30
|
+
:question_type,
|
31
|
+
value: :separator
|
32
|
+
)
|
33
|
+
%>
|
34
|
+
<% if question.persisted? %>
|
35
|
+
<%= form.hidden_field :id, disabled: !editable %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%= form.hidden_field :position, value: question.position || 0, disabled: !editable %>
|
39
|
+
<%= form.hidden_field :deleted, disabled: !editable %>
|
40
|
+
</div>
|
41
|
+
</div>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<div class="answer">
|
2
|
+
<h2 class="title"><%= t(".title", number: participant_counter + 1) %></h2>
|
3
|
+
|
4
|
+
<table class="participant-info">
|
5
|
+
<thead>
|
6
|
+
<tr>
|
7
|
+
<th class='token'><%= t("session_token", scope: "decidim.forms.user_answers_serializer") %></th>
|
8
|
+
<th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
|
9
|
+
<th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
|
10
|
+
<th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
|
11
|
+
<th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
|
12
|
+
</tr>
|
13
|
+
</thead>
|
14
|
+
<tbody>
|
15
|
+
<tr>
|
16
|
+
<td><%= participant.session_token %></td>
|
17
|
+
<td><%= participant.status %></td>
|
18
|
+
<td><%= participant.ip_hash %></td>
|
19
|
+
<td><%= display_percentage(participant.completion) %></td>
|
20
|
+
<td><%= l participant.answered_at, format: :short %></td>
|
21
|
+
</tr>
|
22
|
+
</tbody>
|
23
|
+
</table>
|
24
|
+
|
25
|
+
<div class="answers">
|
26
|
+
<% participant.answers.each do |answer| %>
|
27
|
+
<h3 class="question"><%= answer.question %></h3>
|
28
|
+
<p><%= answer.body %></p>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="questionnaire-answers">
|
2
|
+
<div class="header">
|
3
|
+
<h1><%= translated_attribute(questionnaire.title) %></h1>
|
4
|
+
<div class="description">
|
5
|
+
<%== translated_attribute(questionnaire.description).html_safe %>
|
6
|
+
</div>
|
7
|
+
<% if collection.count > 1 %>
|
8
|
+
<h2><%= t("title", scope: "decidim.forms.admin.questionnaires.answers.index", total: collection.count) %></h2>
|
9
|
+
<% end %>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<%= render partial: "decidim/forms/admin/questionnaires/answers/export/answer", collection: collection, locals: { questionnaire: questionnaire }, as: :participant %>
|
13
|
+
</div>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<div class="card" id="answers">
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title">
|
4
|
+
<%= t ".title", total: @total %>
|
5
|
+
<div class="button--title">
|
6
|
+
<%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires"), questionnaire_url, class: "button tiny button--title new" %>
|
7
|
+
</div>
|
8
|
+
</h2>
|
9
|
+
</div>
|
10
|
+
<div class="card-section">
|
11
|
+
<div class="table-scroll">
|
12
|
+
<table class="table-list">
|
13
|
+
<thead>
|
14
|
+
<tr>
|
15
|
+
<th>#</th>
|
16
|
+
<th><%= first_table_th(@participants.first) %></th>
|
17
|
+
<th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
|
18
|
+
<th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
|
19
|
+
<th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
|
20
|
+
<th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
|
21
|
+
<th></th>
|
22
|
+
</tr>
|
23
|
+
</thead>
|
24
|
+
<tbody>
|
25
|
+
<% @participants.each_with_index do |participant, idx| %>
|
26
|
+
<tr>
|
27
|
+
<td><%= idx + 1 + page_offset %></td>
|
28
|
+
<td>
|
29
|
+
<% if allowed_to? :show, :questionnaire_answers %>
|
30
|
+
<%= link_to first_table_td(participant), questionnaire_participant_answers_url(participant.session_token) %>
|
31
|
+
<% else %>
|
32
|
+
<%= first_table_td(participant) %></td>
|
33
|
+
<% end %>
|
34
|
+
<td><%= participant.status %></td>
|
35
|
+
<td><%= participant.ip_hash %></td>
|
36
|
+
<td><%= display_percentage(participant.completion) %></td>
|
37
|
+
<td><%= l participant.answered_at, format: :short %></td>
|
38
|
+
<td class="table-list__actions">
|
39
|
+
<% if allowed_to? :show, :questionnaire_answers %>
|
40
|
+
<%= icon_link_to "eye", questionnaire_participant_answers_url(participant.session_token), t("actions.show", scope: "decidim.forms.admin.questionnaires.answers"), class: "action-icon--eye" %>
|
41
|
+
<% end %>
|
42
|
+
<% if allowed_to? :export_response, :questionnaire_answers %>
|
43
|
+
<%= icon_link_to "data-transfer-download", questionnaire_export_response_url(participant.session_token), t("actions.export", scope: "decidim.forms.admin.questionnaires.answers"), class: "action-icon--data-transfer-download" %>
|
44
|
+
<% end %>
|
45
|
+
</td>
|
46
|
+
</tr>
|
47
|
+
<% end %>
|
48
|
+
</tbody>
|
49
|
+
</table>
|
50
|
+
<%= paginate @query, theme: "decidim" %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
</div>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<div class="card" id="answers">
|
2
|
+
<div class="card-divider">
|
3
|
+
<h2 class="card-title">
|
4
|
+
<%= t ".title", number: current_idx %>
|
5
|
+
<div class="button--title">
|
6
|
+
<%= link_to_unless last?, t("views.pagination.next").html_safe, next_url, rel: "next", class: "button tiny button--title next" %>
|
7
|
+
</div>
|
8
|
+
<div class="button--title">
|
9
|
+
<%= link_to_unless first?, t("views.pagination.previous").html_safe, prev_url, rel: "prev", class: "button tiny button--title prev" %>
|
10
|
+
</div>
|
11
|
+
<div class="button--title">
|
12
|
+
<%= link_to t("actions.export", scope: "decidim.forms.admin.questionnaires.answers"), questionnaire_export_response_url(@participant.session_token), class: "button tiny button--title export" %>
|
13
|
+
<%= link_to t("actions.back", scope: "decidim.forms.admin.questionnaires.answers"), questionnaire_participants_url, class: "button tiny button--title back" %>
|
14
|
+
</div>
|
15
|
+
</h2>
|
16
|
+
</div>
|
17
|
+
<div class="card-section">
|
18
|
+
<div class="table">
|
19
|
+
<table class="table-list">
|
20
|
+
<thead>
|
21
|
+
<tr>
|
22
|
+
<th><%= t("session_token", scope: "decidim.forms.user_answers_serializer") %></th>
|
23
|
+
<th><%= t("user_status", scope: "decidim.forms.user_answers_serializer") %></th>
|
24
|
+
<th><%= t("ip_hash", scope: "decidim.forms.user_answers_serializer") %></th>
|
25
|
+
<th><%= t("completion", scope: "decidim.forms.user_answers_serializer") %></th>
|
26
|
+
<th><%= t("created_at", scope: "decidim.forms.user_answers_serializer") %></th>
|
27
|
+
<th></th>
|
28
|
+
</tr>
|
29
|
+
</thead>
|
30
|
+
<tbody>
|
31
|
+
<tr>
|
32
|
+
<td><%= @participant.session_token %></td>
|
33
|
+
<td><%= @participant.status %></td>
|
34
|
+
<td><%= @participant.ip_hash %></td>
|
35
|
+
<td><%= display_percentage(@participant.completion) %></td>
|
36
|
+
<td><%= l @participant.answered_at, format: :short %></td>
|
37
|
+
</tr>
|
38
|
+
</tbody>
|
39
|
+
</table>
|
40
|
+
</div>
|
41
|
+
<dl>
|
42
|
+
<% @participant.answers.each do |answer| %>
|
43
|
+
<dt><%= answer.question %></dt>
|
44
|
+
<dd><%= answer.body %></dd>
|
45
|
+
<% end %>
|
46
|
+
</dl>
|
47
|
+
</div>
|
48
|
+
</div>
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
2
|
-
<%= render partial: "decidim/
|
1
|
+
<% if templates_defined? && choose_template? %>
|
2
|
+
<%= render partial: "decidim/templates/admin/questionnaire_templates/choose", locals: { target: questionnaire, form_title: t("decidim.forms.admin.questionnaires.edit.title") } %>
|
3
|
+
<% else %>
|
4
|
+
<%= decidim_form_for(@form, url: update_url, method: :put, html: { class: "form edit_questionnaire" }) do |form| %>
|
5
|
+
<%= render partial: "decidim/forms/admin/questionnaires/form", object: form, locals: { title: title_for_questionnaire } %>
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
+
<div class="button--double form-general-submit">
|
8
|
+
<%= form.submit t(".save"), class: "button" %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
7
11
|
<% end %>
|
@@ -1,100 +1,29 @@
|
|
1
|
-
<% field_id = "
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<%
|
9
|
-
|
10
|
-
<%
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<%= translated_attribute(answer_option.body) %>
|
30
|
-
|
31
|
-
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][][answer_option_id]",
|
32
|
-
answer_option.id,
|
33
|
-
id: "#{choice_id}_answer_option",
|
34
|
-
disabled: true %>
|
35
|
-
<% end %>
|
36
|
-
|
37
|
-
<% if answer_option.free_text %>
|
38
|
-
<%= text_field_tag "questionnaire[answers][#{answer_idx}][choices][][custom_body]",
|
39
|
-
choice.try(:custom_body),
|
40
|
-
id: "#{choice_id}_custom_body",
|
41
|
-
disabled: true %>
|
42
|
-
<% end %>
|
43
|
-
</div>
|
44
|
-
<% end %>
|
45
|
-
</div>
|
46
|
-
<% when "multiple_option" %>
|
47
|
-
<div class="check-box-collection">
|
48
|
-
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
49
|
-
<% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
|
50
|
-
|
51
|
-
<div class="collection-input">
|
52
|
-
<%= label_tag do %>
|
53
|
-
<%= check_box_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][body]",
|
54
|
-
translated_attribute(answer_option.body),
|
55
|
-
choice.present?, disabled: disabled %>
|
56
|
-
|
57
|
-
<%= translated_attribute(answer_option.body) %>
|
58
|
-
|
59
|
-
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
|
60
|
-
<% end %>
|
61
|
-
|
62
|
-
<% if answer_option.free_text %>
|
63
|
-
<%= text_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][custom_body]",
|
64
|
-
choice.try(:custom_body),
|
65
|
-
disabled: true %>
|
66
|
-
<% end %>
|
67
|
-
</div>
|
68
|
-
<% end %>
|
69
|
-
</div>
|
70
|
-
<% when "sorting" %>
|
71
|
-
<div class="sortable-check-box-collection">
|
72
|
-
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
73
|
-
<% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
|
74
|
-
|
75
|
-
<div class="collection-input">
|
76
|
-
<%= label_tag do %>
|
77
|
-
<%= check_box_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][body]",
|
78
|
-
translated_attribute(answer_option.body),
|
79
|
-
choice.present?, disabled: disabled %>
|
80
|
-
|
81
|
-
<span class="position"><%= choice.try(:position) %></span>
|
82
|
-
|
83
|
-
<%= translated_attribute(answer_option.body) %>
|
84
|
-
|
85
|
-
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][position]",
|
86
|
-
choice.try(:position),
|
87
|
-
disabled: true %>
|
88
|
-
|
89
|
-
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
|
90
|
-
<% end %>
|
91
|
-
</div>
|
92
|
-
<% end %>
|
93
|
-
</div>
|
94
|
-
<% end %>
|
95
|
-
|
96
|
-
<%= answer_form.hidden_field :question_id %>
|
97
|
-
|
98
|
-
<% answer.errors.full_messages.each do |msg| %>
|
99
|
-
<small class="form-error is-visible"><%= msg %></small>
|
1
|
+
<% field_id = "questionnaire_responses_#{answer_idx}" %>
|
2
|
+
|
3
|
+
<% if answer.question.separator? %>
|
4
|
+
<%= render partial: "decidim/forms/questionnaires/answers/#{answer.question.question_type}", locals: { answer: answer, answer_form: answer_form, answer_idx: answer_idx, field_id: field_id, disabled: disabled } %>
|
5
|
+
<%= answer_form.hidden_field :question_id %>
|
6
|
+
<% else %>
|
7
|
+
<% case answer.question.question_type %>
|
8
|
+
<% when "single_option", "multiple_option", "sorting" %>
|
9
|
+
<label class="questionnaire-question"><%= answer.label(cleaned_answer_idx) %></label>
|
10
|
+
<% else %>
|
11
|
+
<%= label_tag field_id, answer.label(cleaned_answer_idx), class: "questionnaire-question" %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% if translated_attribute(answer.question.description).present? %>
|
15
|
+
<div class="help-text">
|
16
|
+
<%= decidim_sanitize translated_attribute(answer.question.description) %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<%= render partial: "decidim/forms/questionnaires/answers/#{answer.question.question_type}", locals: { answer: answer, answer_form: answer_form, answer_idx: answer_idx, field_id: field_id, disabled: disabled } %>
|
21
|
+
|
22
|
+
<%= answer_form.hidden_field :question_id %>
|
23
|
+
|
24
|
+
<small class="form-error max-choices-alert"><%= t(".max_choices_alert") %></small>
|
25
|
+
|
26
|
+
<% answer.errors.full_messages.each do |msg| %>
|
27
|
+
<small class="form-error is-visible"><%= msg %></small>
|
28
|
+
<% end %>
|
100
29
|
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= answer_form.text_area :body, label: false, id: field_id, rows: 10, disabled: disabled %>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<table class="questionnaire-question-matrix table">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<td></td>
|
5
|
+
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
6
|
+
<td><%= translated_attribute(answer_option.body) %></td>
|
7
|
+
<% end %>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<tbody>
|
11
|
+
<% answer.question.matrix_rows.each_with_index do |row, row_idx| %>
|
12
|
+
<tr class="check-box-collection">
|
13
|
+
<td><%= translated_attribute row.body %></td>
|
14
|
+
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
15
|
+
<% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id && choice.matrix_row_id == row.id } %>
|
16
|
+
<% choice_id = "#{field_id}_matrix_row_#{row_idx}_choice_#{idx}" %>
|
17
|
+
<td>
|
18
|
+
<div class="collection-input">
|
19
|
+
<%= check_box_tag "questionnaire[responses][#{answer_idx}][choices][][body]",
|
20
|
+
translated_attribute(answer_option.body),
|
21
|
+
choice.present?,
|
22
|
+
id: "#{choice_id}_body", disabled: disabled %>
|
23
|
+
<%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][][answer_option_id]",
|
24
|
+
answer_option.id,
|
25
|
+
id: "#{choice_id}_answer_option",
|
26
|
+
disabled: true %>
|
27
|
+
<%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][][matrix_row_id]",
|
28
|
+
row.id,
|
29
|
+
id: "#{choice_id}_matrix_row",
|
30
|
+
disabled: true %>
|
31
|
+
<% if answer_option.free_text %>
|
32
|
+
<%= text_field_tag "questionnaire[responses][#{answer_idx}][choices][][custom_body]",
|
33
|
+
choice.try(:custom_body),
|
34
|
+
id: "#{choice_id}_custom_body",
|
35
|
+
disabled: true %>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
</td>
|
39
|
+
<% end %>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
42
|
+
</tbody>
|
43
|
+
</table>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
<table class="questionnaire-question-matrix table">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<td></td>
|
5
|
+
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
6
|
+
<td><%= translated_attribute(answer_option.body) %></td>
|
7
|
+
<% end %>
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<tbody>
|
11
|
+
<% answer.question.matrix_rows.each_with_index do |row, row_idx| %>
|
12
|
+
<tr class="radio-button-collection">
|
13
|
+
<td><%= translated_attribute row.body %></td>
|
14
|
+
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
15
|
+
<% choice = answer.choices.find { |choice| choice.answer_option_id == answer_option.id && choice.matrix_row_id == row.id } %>
|
16
|
+
<% choice_id = "#{field_id}_matrix_row_#{row_idx}_choice_#{idx}" %>
|
17
|
+
<td>
|
18
|
+
<div class="collection-input">
|
19
|
+
<%= radio_button_tag "questionnaire[responses][#{answer_idx}][choices][#{row_idx}][body]",
|
20
|
+
translated_attribute(answer_option.body),
|
21
|
+
answer_option.id == choice.try(:answer_option_id),
|
22
|
+
id: "#{choice_id}_body", disabled: disabled %>
|
23
|
+
<%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{row_idx}][answer_option_id]",
|
24
|
+
answer_option.id,
|
25
|
+
id: "#{choice_id}_answer_option",
|
26
|
+
disabled: true %>
|
27
|
+
<%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{row_idx}][matrix_row_id]",
|
28
|
+
row.id,
|
29
|
+
id: "#{choice_id}_matrix_row",
|
30
|
+
disabled: true %>
|
31
|
+
<% if answer_option.free_text %>
|
32
|
+
<%= text_field_tag "questionnaire[responses][#{answer_idx}][choices][#{row_idx}][custom_body]",
|
33
|
+
choice.try(:custom_body),
|
34
|
+
id: "#{choice_id}_custom_body",
|
35
|
+
disabled: true %>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
</td>
|
39
|
+
<% end %>
|
40
|
+
</tr>
|
41
|
+
<% end %>
|
42
|
+
</tbody>
|
43
|
+
</table>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="check-box-collection">
|
2
|
+
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
3
|
+
<% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
|
4
|
+
|
5
|
+
<div class="collection-input">
|
6
|
+
<%= label_tag do %>
|
7
|
+
<%= check_box_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][body]",
|
8
|
+
translated_attribute(answer_option.body),
|
9
|
+
choice.present?, disabled: disabled %>
|
10
|
+
|
11
|
+
<%= translated_attribute(answer_option.body) %>
|
12
|
+
|
13
|
+
<%= hidden_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<% if answer_option.free_text %>
|
17
|
+
<%= text_field_tag "questionnaire[responses][#{answer_idx}][choices][#{idx}][custom_body]",
|
18
|
+
choice.try(:custom_body),
|
19
|
+
disabled: true %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
23
|
+
</div>
|