decidim-forms 0.25.2 → 0.26.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.
- checksums.yaml +4 -4
- data/app/commands/decidim/forms/answer_questionnaire.rb +6 -2
- data/app/forms/decidim/forms/admin/question_form.rb +4 -0
- data/app/models/decidim/forms/answer.rb +1 -0
- data/app/models/decidim/forms/question.rb +7 -1
- data/app/packs/src/decidim/forms/admin/forms.js +2 -0
- data/app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb +19 -4
- data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +5 -2
- data/app/queries/decidim/forms/questionnaire_user_answers.rb +4 -1
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +12 -0
- data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +80 -0
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +10 -1
- data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +1 -0
- data/app/views/decidim/forms/questionnaires/show.html.erb +8 -7
- data/config/locales/cs.yml +11 -0
- data/config/locales/en.yml +11 -0
- data/config/locales/es.yml +11 -0
- data/config/locales/fi.yml +11 -0
- data/config/locales/fr-CA.yml +11 -0
- data/config/locales/fr.yml +11 -0
- data/config/locales/ja.yml +12 -1
- data/config/locales/lb-LU.yml +103 -0
- data/config/locales/nl.yml +11 -0
- data/config/locales/pt-BR.yml +1 -1
- data/config/locales/val-ES.yml +18 -0
- data/lib/decidim/forms/test/factories.rb +12 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +18 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +36 -5
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +98 -0
- data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +8 -0
- data/lib/decidim/forms/user_answers_serializer.rb +7 -1
- data/lib/decidim/forms/version.rb +1 -1
- metadata +14 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58253eb8322a05bac48b60ee5a1b469183bb23df8768dfa36e4ff9e89d4962be
|
4
|
+
data.tar.gz: c8ffbd6fd1537adcdd76487b0d18e832a8effbbe4722bcda72a5d8b6e5eb0d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d078591bab65974d315d8eff0fff980d2c7973a1ef67d829f952620d39d251b6b2e381655be036a740ba5d61bd4c8351984c629e74f202878c234173a2dda68
|
7
|
+
data.tar.gz: 38b3873ee99d11c14c8dcf1efadeac81e57f3a67d80e6ca23bf7c9d208d1527599d756d092b739d92b6f6bc009c36f97fe5969c90c391520fc88c14b5cd31d3f
|
@@ -20,7 +20,7 @@ module Decidim
|
|
20
20
|
#
|
21
21
|
# Broadcasts :ok if successful, :invalid otherwise.
|
22
22
|
def call
|
23
|
-
return broadcast(:invalid) if @form.invalid?
|
23
|
+
return broadcast(:invalid) if @form.invalid? || user_already_answered?
|
24
24
|
|
25
25
|
answer_questionnaire
|
26
26
|
|
@@ -32,7 +32,7 @@ module Decidim
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
attr_reader :form
|
35
|
+
attr_reader :form, :questionnaire, :current_user
|
36
36
|
|
37
37
|
private
|
38
38
|
|
@@ -96,6 +96,10 @@ module Decidim
|
|
96
96
|
raise ActiveRecord::Rollback if @errors
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
def user_already_answered?
|
101
|
+
questionnaire.answered_by?(current_user || form.context.session_token)
|
102
|
+
end
|
99
103
|
end
|
100
104
|
end
|
101
105
|
end
|
@@ -42,6 +42,10 @@ module Decidim
|
|
42
42
|
question_type == Decidim::Forms::Question::SEPARATOR_TYPE
|
43
43
|
end
|
44
44
|
|
45
|
+
def title_and_description?
|
46
|
+
question_type == Decidim::Forms::Question::TITLE_AND_DESCRIPTION_TYPE
|
47
|
+
end
|
48
|
+
|
45
49
|
def matrix_rows_by_position
|
46
50
|
matrix_rows.sort do |a, b|
|
47
51
|
if a.position && b.position
|
@@ -22,6 +22,7 @@ module Decidim
|
|
22
22
|
validate :question_belongs_to_questionnaire
|
23
23
|
|
24
24
|
scope :not_separator, -> { joins(:question).where.not(decidim_forms_questions: { question_type: Decidim::Forms::Question::SEPARATOR_TYPE }) }
|
25
|
+
scope :not_title_and_description, -> { joins(:question).where.not(decidim_forms_questions: { question_type: Decidim::Forms::Question::TITLE_AND_DESCRIPTION_TYPE }) }
|
25
26
|
|
26
27
|
def self.user_collection(user)
|
27
28
|
where(decidim_user_id: user.id)
|
@@ -8,7 +8,8 @@ module Decidim
|
|
8
8
|
|
9
9
|
QUESTION_TYPES = %w(short_answer long_answer single_option multiple_option sorting files matrix_single matrix_multiple).freeze
|
10
10
|
SEPARATOR_TYPE = "separator"
|
11
|
-
|
11
|
+
TITLE_AND_DESCRIPTION_TYPE = "title_and_description"
|
12
|
+
TYPES = (QUESTION_TYPES + [SEPARATOR_TYPE, TITLE_AND_DESCRIPTION_TYPE]).freeze
|
12
13
|
|
13
14
|
translatable_fields :body, :description
|
14
15
|
|
@@ -49,6 +50,7 @@ module Decidim
|
|
49
50
|
validates :question_type, inclusion: { in: TYPES }
|
50
51
|
|
51
52
|
scope :not_separator, -> { where.not(question_type: SEPARATOR_TYPE) }
|
53
|
+
scope :not_title_and_description, -> { where.not(question_type: TITLE_AND_DESCRIPTION_TYPE) }
|
52
54
|
|
53
55
|
scope :with_body, -> { where(question_type: %w(short_answer long_answer)) }
|
54
56
|
scope :with_choices, -> { where.not(question_type: %w(short_answer long_answer)) }
|
@@ -84,6 +86,10 @@ module Decidim
|
|
84
86
|
question_type.to_s == SEPARATOR_TYPE
|
85
87
|
end
|
86
88
|
|
89
|
+
def title_and_description?
|
90
|
+
question_type.to_s == TITLE_AND_DESCRIPTION_TYPE
|
91
|
+
end
|
92
|
+
|
87
93
|
def has_attachments?
|
88
94
|
question_type.to_s == "files"
|
89
95
|
end
|
@@ -375,8 +375,10 @@ export default function createEditableForm() {
|
|
375
375
|
fieldSelector: fieldSelector,
|
376
376
|
addFieldButtonSelector: ".add-question",
|
377
377
|
addSeparatorButtonSelector: ".add-separator",
|
378
|
+
addTitleAndDescriptionButtonSelector: ".add-title-and-description",
|
378
379
|
fieldTemplateSelector: ".decidim-question-template",
|
379
380
|
separatorTemplateSelector: ".decidim-separator-template",
|
381
|
+
TitleAndDescriptionTemplateSelector: ".decidim-title-and-description-template",
|
380
382
|
removeFieldButtonSelector: ".remove-question",
|
381
383
|
moveUpFieldButtonSelector: ".move-up-question",
|
382
384
|
moveDownFieldButtonSelector: ".move-down-question",
|
@@ -21,10 +21,13 @@ module Decidim
|
|
21
21
|
return "-" if answer.choices.empty?
|
22
22
|
|
23
23
|
choices = answer.choices.map do |choice|
|
24
|
-
|
24
|
+
{
|
25
|
+
answer_option_body: choice.try(:answer_option).try(:translated_body),
|
26
|
+
choice_body: body_or_custom_body(choice)
|
27
|
+
}
|
25
28
|
end
|
26
29
|
|
27
|
-
return choices.first if answer.question.question_type == "single_option"
|
30
|
+
return choice(choices.first) if answer.question.question_type == "single_option"
|
28
31
|
|
29
32
|
content_tag(:ul) do
|
30
33
|
safe_join(choices.map { |c| choice(c) })
|
@@ -52,11 +55,23 @@ module Decidim
|
|
52
55
|
# rubocop:enable Style/StringConcatenation
|
53
56
|
end
|
54
57
|
|
55
|
-
def choice(
|
58
|
+
def choice(choice_hash)
|
56
59
|
content_tag :li do
|
57
|
-
|
60
|
+
render_body_for choice_hash
|
58
61
|
end
|
59
62
|
end
|
63
|
+
|
64
|
+
def render_body_for(choice_hash)
|
65
|
+
return choice_hash[:answer_option_body] if choice_hash[:choice_body].blank?
|
66
|
+
|
67
|
+
"#{choice_hash[:answer_option_body]} (#{choice_hash[:choice_body]})"
|
68
|
+
end
|
69
|
+
|
70
|
+
def body_or_custom_body(choice)
|
71
|
+
return choice.custom_body if choice.try(:custom_body).present?
|
72
|
+
|
73
|
+
""
|
74
|
+
end
|
60
75
|
end
|
61
76
|
end
|
62
77
|
end
|
@@ -46,13 +46,16 @@ module Decidim
|
|
46
46
|
with_choices = sibilings.where.not("decidim_forms_questions.question_type in (?)", %w(short_answer long_answer))
|
47
47
|
.where("decidim_forms_answers.id IN (SELECT decidim_answer_id FROM decidim_forms_answer_choices)").count
|
48
48
|
|
49
|
-
(with_body + with_choices).to_f / questionnaire.questions.not_separator.count * 100
|
49
|
+
(with_body + with_choices).to_f / questionnaire.questions.not_separator.not_title_and_description.count * 100
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
54
|
def sibilings
|
55
|
-
Answer.not_separator
|
55
|
+
Answer.not_separator
|
56
|
+
.not_title_and_description
|
57
|
+
.where(questionnaire: questionnaire, session_token: participant.session_token)
|
58
|
+
.joins(:question).order("decidim_forms_questions.position ASC")
|
56
59
|
end
|
57
60
|
end
|
58
61
|
end
|
@@ -20,7 +20,10 @@ module Decidim
|
|
20
20
|
|
21
21
|
# Finds and group answers by user for each questionnaire's question.
|
22
22
|
def query
|
23
|
-
answers = Answer.not_separator
|
23
|
+
answers = Answer.not_separator
|
24
|
+
.not_title_and_description
|
25
|
+
.joins(:question)
|
26
|
+
.where(questionnaire: @questionnaire)
|
24
27
|
|
25
28
|
answers.sort_by { |answer| answer.question.position }.group_by { |a| a.user || a.session_token }.values
|
26
29
|
end
|
@@ -65,6 +65,12 @@
|
|
65
65
|
id: tabs_id_for_question(blank_question),
|
66
66
|
editable: questionnaire.questions_editable? %>
|
67
67
|
</script>
|
68
|
+
<script type="text/template" class="decidim-title-and-description-template decidim-template" id="title-and-description-template">
|
69
|
+
<%= render "decidim/forms/admin/questionnaires/title_and_description",
|
70
|
+
form: question_form,
|
71
|
+
id: tabs_id_for_question(blank_question),
|
72
|
+
editable: questionnaire.questions_editable? %>
|
73
|
+
</script>
|
68
74
|
<%= render "decidim/forms/admin/questionnaires/answer_option_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "answer-option-template-dummy" %>
|
69
75
|
<%= render "decidim/forms/admin/questionnaires/display_condition_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "display-condition-template-dummy" %>
|
70
76
|
<%= render "decidim/forms/admin/questionnaires/matrix_row_template", form: question_form, editable: questionnaire.questions_editable?, template_id: "matrix-row-template-dummy" %>
|
@@ -83,6 +89,11 @@
|
|
83
89
|
form: question_form,
|
84
90
|
id: tabs_id_for_question(question),
|
85
91
|
editable: questionnaire.questions_editable? %>
|
92
|
+
<% elsif question.title_and_description? %>
|
93
|
+
<%= render "decidim/forms/admin/questionnaires/title_and_description",
|
94
|
+
form: question_form,
|
95
|
+
id: tabs_id_for_question(question),
|
96
|
+
editable: questionnaire.questions_editable? %>
|
86
97
|
<% else %>
|
87
98
|
<%= render "decidim/forms/admin/questionnaires/question",
|
88
99
|
form: question_form,
|
@@ -102,6 +113,7 @@
|
|
102
113
|
<% if questionnaire.questions_editable? %>
|
103
114
|
<button class="button add-question"><%= t(".add_question") %></button>
|
104
115
|
<button class="button add-separator"><%= t(".add_separator") %></button>
|
116
|
+
<button class="button add-title-and-description"><%= t(".add_title_and_description") %></button>
|
105
117
|
<% end %>
|
106
118
|
</div>
|
107
119
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<% question = form.object %>
|
2
|
+
<% is_expanded = question.errors.any? %>
|
3
|
+
|
4
|
+
<div class="card questionnaire-question" id="<%= id %>-field">
|
5
|
+
<div class="card-divider question-divider">
|
6
|
+
<h2 class="card-title">
|
7
|
+
<span>
|
8
|
+
<% if editable %>
|
9
|
+
<%== icon("move") %>
|
10
|
+
<% end %>
|
11
|
+
<%= dynamic_title(translated_attribute(question.body), class: "question-title-statement", max_length: 50, omission: "...", placeholder: t(".title_and_description")) %>
|
12
|
+
</span>
|
13
|
+
|
14
|
+
<button type="button" class="button small secondary button--title question--collapse" data-toggle="<%= id %>-question-card button--collapse-question-<%= id %> button--expand-question-<%= id %>">
|
15
|
+
<span id="button--collapse-question-<%= id %>" data-toggler=".hide" class="icon-collapse <%= "hide" unless is_expanded %>">
|
16
|
+
<%== icon("caret-top", aria_label: t(".collapse"), role: "img") %>
|
17
|
+
</span>
|
18
|
+
|
19
|
+
<span id="button--expand-question-<%= id %>" data-toggler=".hide" class="icon-expand <%= "hide" if is_expanded %>">
|
20
|
+
<%== icon("caret-bottom", aria_label: t(".expand"), role: "img") %>
|
21
|
+
</span>
|
22
|
+
</button>
|
23
|
+
|
24
|
+
<% if editable %>
|
25
|
+
<button class="button small alert hollow move-up-question button--title">
|
26
|
+
<%== "#{icon("arrow-top")} #{t(".up")}" %>
|
27
|
+
</button>
|
28
|
+
|
29
|
+
<button class="button small alert hollow move-down-question button--title">
|
30
|
+
<%== "#{icon("arrow-bottom")} #{t(".down")}" %>
|
31
|
+
</button>
|
32
|
+
|
33
|
+
<button class="button small alert hollow remove-question button--title">
|
34
|
+
<%= t(".remove") %>
|
35
|
+
</button>
|
36
|
+
<% end %>
|
37
|
+
</h2>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="card-section collapsible <%= "hide" unless is_expanded %>" data-toggler=".hide" id="<%= id %>-question-card">
|
41
|
+
<div class="row column">
|
42
|
+
<%=
|
43
|
+
form.translated(
|
44
|
+
:text_field,
|
45
|
+
:body,
|
46
|
+
tabs_id: id,
|
47
|
+
label: t(".title"),
|
48
|
+
disabled: !editable
|
49
|
+
)
|
50
|
+
%>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<div class="row column">
|
54
|
+
<%=
|
55
|
+
form.translated(
|
56
|
+
:editor,
|
57
|
+
:description,
|
58
|
+
toolbar: :full,
|
59
|
+
tabs_id: id,
|
60
|
+
label: t(".description"),
|
61
|
+
disabled: !editable
|
62
|
+
)
|
63
|
+
%>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<%=
|
67
|
+
form.hidden_field(
|
68
|
+
:question_type,
|
69
|
+
value: :title_and_description
|
70
|
+
)
|
71
|
+
%>
|
72
|
+
|
73
|
+
<% if question.persisted? %>
|
74
|
+
<%= form.hidden_field :id, disabled: !editable %>
|
75
|
+
<% end %>
|
76
|
+
|
77
|
+
<%= form.hidden_field :position, value: question.position || 0, disabled: !editable %>
|
78
|
+
<%= form.hidden_field :deleted, disabled: !editable %>
|
79
|
+
</div>
|
80
|
+
</div>
|
@@ -3,6 +3,15 @@
|
|
3
3
|
<% if answer.question.separator? %>
|
4
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
5
|
<%= answer_form.hidden_field :question_id %>
|
6
|
+
<% elsif answer.question.title_and_description? %>
|
7
|
+
<%= label_tag field_id, translated_attribute(answer.question.body), class: "questionnaire-title_and_description" %>
|
8
|
+
<% if translated_attribute(answer.question.description).present? %>
|
9
|
+
<div class="help-title_and_description ">
|
10
|
+
<%= decidim_sanitize_editor translated_attribute(answer.question.description) %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
<%= 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 } %>
|
14
|
+
<%= answer_form.hidden_field :question_id %>
|
6
15
|
<% else %>
|
7
16
|
<% case answer.question.question_type %>
|
8
17
|
<% when "single_option", "multiple_option", "sorting" %>
|
@@ -13,7 +22,7 @@
|
|
13
22
|
|
14
23
|
<% if translated_attribute(answer.question.description).present? %>
|
15
24
|
<div class="help-text">
|
16
|
-
<%=
|
25
|
+
<%= decidim_sanitize_editor translated_attribute(answer.question.description) %>
|
17
26
|
</div>
|
18
27
|
<% end %>
|
19
28
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= answer_form.hidden_field :body, value: "title-and-description", id: field_id, disabled: disabled %>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<h3 class="section-heading"><%= translated_attribute questionnaire.title %></h3>
|
12
12
|
<div class="row">
|
13
13
|
<div class="columns large-<%= columns %> medium-centered lead">
|
14
|
-
<%=
|
14
|
+
<%= decidim_sanitize_editor translated_attribute questionnaire.description %>
|
15
15
|
</div>
|
16
16
|
</div>
|
17
17
|
</div>
|
@@ -20,8 +20,8 @@
|
|
20
20
|
<div class="columns large-<%= columns %> medium-centered">
|
21
21
|
<div class="card">
|
22
22
|
<div class="card__content">
|
23
|
-
|
24
|
-
|
23
|
+
<% unless questionnaire_for.try(:component)&.try(:published?) %>
|
24
|
+
<div class="section">
|
25
25
|
<div class="callout warning">
|
26
26
|
<p><%= t(".questionnaire_not_published.body") %></p>
|
27
27
|
</div>
|
@@ -65,14 +65,15 @@
|
|
65
65
|
<div id="step-<%= step_index %>" class="<%= step_index.zero? ? "questionnaire-step" : "questionnaire-step hide" %>" data-toggler=".hide">
|
66
66
|
<% if @form.total_steps > 1 %>
|
67
67
|
<h4 class="section-heading">
|
68
|
-
<%= t(".current_step", step: step_index + 1) %>
|
68
|
+
<%= t(".current_step", step: step_index + 1) %>
|
69
|
+
<span class="answer-questionnaire__steps"><%= t(".of_total_steps", total_steps: @form.total_steps) %></span>
|
69
70
|
</h4>
|
70
71
|
<% end %>
|
71
72
|
|
72
73
|
<% step_answers.each do |answer| %>
|
73
74
|
<div class="row column answer question" data-max-choices="<%= answer.question.max_choices %>" data-conditioned="<%= answer.question.display_conditions.any? %>" data-question-id="<%= answer.question.id %>">
|
74
75
|
<% answer.question.display_conditions.each do |display_condition| %>
|
75
|
-
<%= content_tag :div, nil,
|
76
|
+
<%= content_tag :div, nil, class: "display-condition", data: display_condition.to_html_data %>
|
76
77
|
<% end %>
|
77
78
|
|
78
79
|
<%= fields_for "questionnaire[responses][#{answer_idx}]", answer do |answer_form| %>
|
@@ -86,7 +87,7 @@
|
|
86
87
|
) %>
|
87
88
|
<% end %>
|
88
89
|
</div>
|
89
|
-
<% if !answer.question.separator? %>
|
90
|
+
<% if !(answer.question.separator? || answer.question.title_and_description?) %>
|
90
91
|
<% cleaned_answer_idx += 1 %>
|
91
92
|
<% end %>
|
92
93
|
<% answer_idx += 1 %>
|
@@ -108,7 +109,7 @@
|
|
108
109
|
<div class="row column tos-agreement">
|
109
110
|
<%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "questionnaire_tos_agreement", disabled: !current_participatory_space.can_participate?(current_user) %>
|
110
111
|
<div class="help-text">
|
111
|
-
<%=
|
112
|
+
<%= decidim_sanitize_editor translated_attribute questionnaire.tos %>
|
112
113
|
</div>
|
113
114
|
</div>
|
114
115
|
<% end %>
|
data/config/locales/cs.yml
CHANGED
@@ -79,6 +79,7 @@ cs:
|
|
79
79
|
form:
|
80
80
|
add_question: Přidat otázku
|
81
81
|
add_separator: Přidat oddělovač
|
82
|
+
add_title_and_description: Přidat název a popis
|
82
83
|
already_answered_warning: Formulář je již zodpovězen některými uživateli, takže jeho otázky nemůžete upravovat.
|
83
84
|
collapse: Sbalit všechny otázky
|
84
85
|
expand: Rozbalit všechny otázky
|
@@ -108,6 +109,15 @@ cs:
|
|
108
109
|
remove: Odebrat
|
109
110
|
separator: Oddělovač
|
110
111
|
up: Nahoru
|
112
|
+
title_and_description:
|
113
|
+
collapse: Sbalit
|
114
|
+
description: Popis
|
115
|
+
down: Dolů
|
116
|
+
expand: Rozbalit
|
117
|
+
remove: Odebrat
|
118
|
+
title: Název
|
119
|
+
title_and_description: Název a popis
|
120
|
+
up: Nahoru
|
111
121
|
update:
|
112
122
|
invalid: Při ukládání dotazníku došlo k chybám.
|
113
123
|
success: Formulář byl úspěšně uložen.
|
@@ -131,6 +141,7 @@ cs:
|
|
131
141
|
short_answer: Stručná odpověď
|
132
142
|
single_option: Jedna možnost
|
133
143
|
sorting: Třídění
|
144
|
+
title_and_description: Název a popis
|
134
145
|
questionnaires:
|
135
146
|
answer:
|
136
147
|
invalid: Při odpovědi na dotazník došlo k chybám.
|
data/config/locales/en.yml
CHANGED
@@ -80,6 +80,7 @@ en:
|
|
80
80
|
form:
|
81
81
|
add_question: Add question
|
82
82
|
add_separator: Add separator
|
83
|
+
add_title_and_description: Add title and description
|
83
84
|
already_answered_warning: The form is already answered by some users so you cannot modify its questions.
|
84
85
|
collapse: Collapse all questions
|
85
86
|
expand: Expand all questions
|
@@ -109,6 +110,15 @@ en:
|
|
109
110
|
remove: Remove
|
110
111
|
separator: Separator
|
111
112
|
up: Up
|
113
|
+
title_and_description:
|
114
|
+
collapse: Collapse
|
115
|
+
description: Description
|
116
|
+
down: Down
|
117
|
+
expand: Expand
|
118
|
+
remove: Remove
|
119
|
+
title: Title
|
120
|
+
title_and_description: Title and description
|
121
|
+
up: Up
|
112
122
|
update:
|
113
123
|
invalid: There was a problem saving the form.
|
114
124
|
success: Form successfully saved.
|
@@ -132,6 +142,7 @@ en:
|
|
132
142
|
short_answer: Short answer
|
133
143
|
single_option: Single option
|
134
144
|
sorting: Sorting
|
145
|
+
title_and_description: Title and description
|
135
146
|
questionnaires:
|
136
147
|
answer:
|
137
148
|
invalid: There was a problem answering the form.
|
data/config/locales/es.yml
CHANGED
@@ -79,6 +79,7 @@ es:
|
|
79
79
|
form:
|
80
80
|
add_question: Añadir pregunta
|
81
81
|
add_separator: Añadir separador
|
82
|
+
add_title_and_description: Añadir título y descripción
|
82
83
|
already_answered_warning: Algunas participantes ya han respondido el formulario, por lo que no puedes modificar las preguntas.
|
83
84
|
collapse: Contraer todas las preguntas
|
84
85
|
expand: Expandir todos las preguntas
|
@@ -108,6 +109,15 @@ es:
|
|
108
109
|
remove: Eliminar
|
109
110
|
separator: Separador
|
110
111
|
up: Subir
|
112
|
+
title_and_description:
|
113
|
+
collapse: Contraer
|
114
|
+
description: Descripción
|
115
|
+
down: Bajar
|
116
|
+
expand: Expandir
|
117
|
+
remove: Eliminar
|
118
|
+
title: Título
|
119
|
+
title_and_description: Título y descripción
|
120
|
+
up: Subir
|
111
121
|
update:
|
112
122
|
invalid: Se ha producido un error al guardar el formulario.
|
113
123
|
success: Formulario guardado correctamente.
|
@@ -131,6 +141,7 @@ es:
|
|
131
141
|
short_answer: Respuesta corta
|
132
142
|
single_option: Opción única
|
133
143
|
sorting: Ordenación
|
144
|
+
title_and_description: Titulo y descripción
|
134
145
|
questionnaires:
|
135
146
|
answer:
|
136
147
|
invalid: Se ha producido un error al responder el formulario.
|
data/config/locales/fi.yml
CHANGED
@@ -79,6 +79,7 @@ fi:
|
|
79
79
|
form:
|
80
80
|
add_question: Lisää kysymys
|
81
81
|
add_separator: Lisää erotinviiva
|
82
|
+
add_title_and_description: Lisää otsikko ja kuvaus
|
82
83
|
already_answered_warning: Jotkut käyttäjät ovat jo vastanneet tähän kyselylomakkeeseen, joten et voi enää muokata kysymyksiä.
|
83
84
|
collapse: Sulje kaikki kysymykset
|
84
85
|
expand: Avaa kaikki kysymykset
|
@@ -108,6 +109,15 @@ fi:
|
|
108
109
|
remove: Poista
|
109
110
|
separator: Erotin
|
110
111
|
up: Ylös
|
112
|
+
title_and_description:
|
113
|
+
collapse: Pienennä
|
114
|
+
description: Kuvaus
|
115
|
+
down: Alas
|
116
|
+
expand: Laajenna
|
117
|
+
remove: Poista
|
118
|
+
title: Otsikko
|
119
|
+
title_and_description: Otsikko ja kuvaus
|
120
|
+
up: Ylös
|
111
121
|
update:
|
112
122
|
invalid: Kyselylomakkeen tallentaminen epäonnistui.
|
113
123
|
success: Lomake tallennettu onnistuneesti.
|
@@ -131,6 +141,7 @@ fi:
|
|
131
141
|
short_answer: Lyhyt vastaus
|
132
142
|
single_option: Yksi vaihtoehto
|
133
143
|
sorting: Järjestäminen
|
144
|
+
title_and_description: Otsikko ja kuvaus
|
134
145
|
questionnaires:
|
135
146
|
answer:
|
136
147
|
invalid: Kyselylomakkeeseen vastaaminen epäonnistui.
|
data/config/locales/fr-CA.yml
CHANGED
@@ -79,6 +79,7 @@ fr-CA:
|
|
79
79
|
form:
|
80
80
|
add_question: Ajouter une question
|
81
81
|
add_separator: Ajouter un séparateur
|
82
|
+
add_title_and_description: Ajouter un titre et une description
|
82
83
|
already_answered_warning: Certains utilisateurs ont déjà répondu au questionnaire, vous ne pouvez donc pas modifier ses questions.
|
83
84
|
collapse: Réduire toutes les questions
|
84
85
|
expand: Développer toutes les questions
|
@@ -108,6 +109,15 @@ fr-CA:
|
|
108
109
|
remove: Retirer
|
109
110
|
separator: Séparateur
|
110
111
|
up: Haut
|
112
|
+
title_and_description:
|
113
|
+
collapse: Réduire
|
114
|
+
description: Description
|
115
|
+
down: Descendre
|
116
|
+
expand: Déveloper
|
117
|
+
remove: Supprimer
|
118
|
+
title: Titre
|
119
|
+
title_and_description: Titre et description
|
120
|
+
up: Vers le haut
|
111
121
|
update:
|
112
122
|
invalid: Il y a eu des erreurs lors de la sauvegarde du questionnaire.
|
113
123
|
success: Le formulaire a bien été sauvegardé.
|
@@ -131,6 +141,7 @@ fr-CA:
|
|
131
141
|
short_answer: Réponse courte
|
132
142
|
single_option: Option unique
|
133
143
|
sorting: Tri
|
144
|
+
title_and_description: Titre et description
|
134
145
|
questionnaires:
|
135
146
|
answer:
|
136
147
|
invalid: Il y a eu des erreurs en répondant au questionnaire.
|
data/config/locales/fr.yml
CHANGED
@@ -79,6 +79,7 @@ fr:
|
|
79
79
|
form:
|
80
80
|
add_question: Ajouter une question
|
81
81
|
add_separator: Ajouter un séparateur
|
82
|
+
add_title_and_description: Ajouter un titre et une description
|
82
83
|
already_answered_warning: Certains utilisateurs ont déjà répondu au questionnaire, vous ne pouvez donc pas modifier ses questions.
|
83
84
|
collapse: Réduire toutes les questions
|
84
85
|
expand: Développer toutes les questions
|
@@ -108,6 +109,15 @@ fr:
|
|
108
109
|
remove: Retirer
|
109
110
|
separator: Séparateur
|
110
111
|
up: Haut
|
112
|
+
title_and_description:
|
113
|
+
collapse: Réduire
|
114
|
+
description: Description
|
115
|
+
down: Descendre
|
116
|
+
expand: Déveloper
|
117
|
+
remove: Supprimer
|
118
|
+
title: Titre
|
119
|
+
title_and_description: Titre et description
|
120
|
+
up: Vers le haut
|
111
121
|
update:
|
112
122
|
invalid: Il y a eu des erreurs lors de la sauvegarde du questionnaire.
|
113
123
|
success: Le questionnaire a bien été sauvegardé.
|
@@ -131,6 +141,7 @@ fr:
|
|
131
141
|
short_answer: Réponse courte
|
132
142
|
single_option: Option unique
|
133
143
|
sorting: Tri
|
144
|
+
title_and_description: Titre et description
|
134
145
|
questionnaires:
|
135
146
|
answer:
|
136
147
|
invalid: Il y a eu des erreurs en répondant au questionnaire.
|
data/config/locales/ja.yml
CHANGED
@@ -9,7 +9,7 @@ ja:
|
|
9
9
|
max_choices: 選択肢の最大数
|
10
10
|
question_type: タイプ
|
11
11
|
questionnaire_question:
|
12
|
-
mandatory:
|
12
|
+
mandatory: 必須
|
13
13
|
max_characters: 文字数制限 (制限がない場合は0にしてください)
|
14
14
|
errors:
|
15
15
|
models:
|
@@ -79,6 +79,7 @@ ja:
|
|
79
79
|
form:
|
80
80
|
add_question: 質問を追加
|
81
81
|
add_separator: 区切り文字を追加
|
82
|
+
add_title_and_description: タイトルと説明を追加
|
82
83
|
already_answered_warning: このフォームはすでに一部のユーザーによって回答されているため、質問を修正することはできません。
|
83
84
|
collapse: すべての質問を閉じる
|
84
85
|
expand: すべての質問を展開
|
@@ -108,6 +109,15 @@ ja:
|
|
108
109
|
remove: 削除
|
109
110
|
separator: 区切り記号
|
110
111
|
up: 上へ
|
112
|
+
title_and_description:
|
113
|
+
collapse: 折りたたむ
|
114
|
+
description: 説明
|
115
|
+
down: 下へ
|
116
|
+
expand: 展開する
|
117
|
+
remove: 削除
|
118
|
+
title: タイトル
|
119
|
+
title_and_description: タイトルと説明
|
120
|
+
up: 上へ
|
111
121
|
update:
|
112
122
|
invalid: フォームの保存に失敗しました。
|
113
123
|
success: フォームを保存しました。
|
@@ -131,6 +141,7 @@ ja:
|
|
131
141
|
short_answer: 短い回答
|
132
142
|
single_option: 単一オプション
|
133
143
|
sorting: 並び替え
|
144
|
+
title_and_description: タイトルと説明
|
134
145
|
questionnaires:
|
135
146
|
answer:
|
136
147
|
invalid: フォームの回答に問題がありました。
|
data/config/locales/lb-LU.yml
CHANGED
@@ -1 +1,104 @@
|
|
1
1
|
lb:
|
2
|
+
activemodel:
|
3
|
+
attributes:
|
4
|
+
questionnaire_question:
|
5
|
+
mandatory: Verpflichtend
|
6
|
+
max_characters: Maximale Anzahl Zeichen (0 bedeutet kein Limit)
|
7
|
+
errors:
|
8
|
+
models:
|
9
|
+
answer:
|
10
|
+
attributes:
|
11
|
+
add_documents:
|
12
|
+
needs_to_be_reattached: Muss erneut angehängt werden
|
13
|
+
body:
|
14
|
+
too_long: ist zu lang
|
15
|
+
choices:
|
16
|
+
missing: sind nicht vollständig
|
17
|
+
too_many: sind zu viele
|
18
|
+
questionnaire:
|
19
|
+
request_invalid: Bei der Bearbeitung der Anfrage ist ein Fehler aufgetreten. Bitte versuchen Sie es nochmal
|
20
|
+
decidim:
|
21
|
+
forms:
|
22
|
+
admin:
|
23
|
+
models:
|
24
|
+
components:
|
25
|
+
description: Beschreibung
|
26
|
+
tos: Nutzungsbedingungen
|
27
|
+
questionnaires:
|
28
|
+
actions:
|
29
|
+
back: Zurück zu Fragen
|
30
|
+
show: Antworten anzeigen
|
31
|
+
answer_option:
|
32
|
+
answer_option: Antwortoption
|
33
|
+
free_text: Freier Text
|
34
|
+
remove: Löschen
|
35
|
+
statement: Aussage
|
36
|
+
answers:
|
37
|
+
actions:
|
38
|
+
back: Zurück zu Antworten
|
39
|
+
export: Exportieren
|
40
|
+
show: Antworten anzeigen
|
41
|
+
empty: Noch keine Antworten
|
42
|
+
export:
|
43
|
+
answer:
|
44
|
+
title: 'Antwort #%{number}'
|
45
|
+
export_response:
|
46
|
+
title: Umfrage_Benutzer_Antworten_%{token}
|
47
|
+
index:
|
48
|
+
title: "%{total} Antworten insgesamt"
|
49
|
+
show:
|
50
|
+
title: 'Antwort #%{number}'
|
51
|
+
display_condition:
|
52
|
+
answer_option: Antwortoption
|
53
|
+
condition_question: Frage
|
54
|
+
condition_type: Bedingung
|
55
|
+
condition_types:
|
56
|
+
answered: Beantwortet
|
57
|
+
equal: Gleich
|
58
|
+
match: Beinhaltet Text
|
59
|
+
not_answered: Unbeantwortet
|
60
|
+
not_equal: Nicht gleich
|
61
|
+
condition_value: Enthaltener Text
|
62
|
+
display_condition: Bedingung anzeigen
|
63
|
+
mandatory: Diese Bedingung muss immer erfüllt werden, unabhängig vom Status anderer Bedingungen
|
64
|
+
remove: Löschen
|
65
|
+
save_warning: Vergessen Sie nicht, das Formular zu speichern, bevor Sie die Anzeigebedingungen konfigurieren
|
66
|
+
select_answer_option: Antwortoption auswählen
|
67
|
+
select_condition_question: Eine Frage
|
68
|
+
select_condition_type: Wählen Sie einen Bedingungstyp
|
69
|
+
edit:
|
70
|
+
save: Speichern
|
71
|
+
title: Fragebogen bearbeiten
|
72
|
+
form:
|
73
|
+
add_question: Frage hinzufügen
|
74
|
+
add_separator: Trennzeichen hinzufügen
|
75
|
+
already_answered_warning: Der Fragebogen wird bereits von einigen Benutzern beantwortet, sodass Sie die Fragen nicht ändern können.
|
76
|
+
collapse: Alle Fragen einklappen
|
77
|
+
expand: Alle Fragen ausklappen
|
78
|
+
preview: Vorschau
|
79
|
+
title: Formular für %{questionnaire_for} bearbeiten
|
80
|
+
unpublished_warning: Das Formular ist nicht öffentlich. Sie können die Fragen ändern, dabei werden allerdings die aktuellen Antworten gelöscht.
|
81
|
+
matrix_row:
|
82
|
+
matrix_row: Zeile
|
83
|
+
questionnaires:
|
84
|
+
show:
|
85
|
+
questionnaire_not_published:
|
86
|
+
body: Dieses Formular ist noch nicht veröffentlicht.
|
87
|
+
tos_agreement: Mit der Teilnahme stimmen Sie den Nutzungsbedingungen zu
|
88
|
+
step_navigation:
|
89
|
+
show:
|
90
|
+
are_you_sure: Diese Aktion kann nicht rückgängig gemacht werden und Sie können Ihre Antworten nicht bearbeiten. Bist du sicher?
|
91
|
+
back: Zurück
|
92
|
+
continue: Weiter
|
93
|
+
submit: einreichen
|
94
|
+
user_answers_serializer:
|
95
|
+
body: Antwort
|
96
|
+
completion: Abschluss
|
97
|
+
created_at: Beantwortet am
|
98
|
+
id: ID beantworten
|
99
|
+
ip_hash: IP-Hash
|
100
|
+
question: Frage
|
101
|
+
registered: Registriert
|
102
|
+
session_token: Benutzerkennung
|
103
|
+
unregistered: Nicht registriert
|
104
|
+
user_status: Benutzerstatus
|
data/config/locales/nl.yml
CHANGED
@@ -74,6 +74,7 @@ nl:
|
|
74
74
|
form:
|
75
75
|
add_question: Vraag toevoegen
|
76
76
|
add_separator: Scheidingsteken toevoegen
|
77
|
+
add_title_and_description: Titel en beschrijving toevoegen
|
77
78
|
already_answered_warning: De vragenlijst is al door enkele gebruikers beantwoord, dus u kunt de vragen niet wijzigen.
|
78
79
|
collapse: Alle vragen samenvouwen
|
79
80
|
expand: Vouw alle vragen uit
|
@@ -102,6 +103,15 @@ nl:
|
|
102
103
|
remove: Verwijderen
|
103
104
|
separator: Scheidingsteken
|
104
105
|
up: Omhoog
|
106
|
+
title_and_description:
|
107
|
+
collapse: Inklappen
|
108
|
+
description: Beschrijving
|
109
|
+
down: Naar beneden
|
110
|
+
expand: Uitklappen
|
111
|
+
remove: Verwijderen
|
112
|
+
title: Titel
|
113
|
+
title_and_description: Titel en beschrijving
|
114
|
+
up: Naar boven
|
105
115
|
update:
|
106
116
|
invalid: Er zijn fouten opgetreden bij het opslaan van de vragenlijst.
|
107
117
|
success: Formulier succesvol opgeslagen.
|
@@ -124,6 +134,7 @@ nl:
|
|
124
134
|
short_answer: Kort antwoord
|
125
135
|
single_option: Enkele optie
|
126
136
|
sorting: sorteer-
|
137
|
+
title_and_description: Titel en beschrijving
|
127
138
|
questionnaires:
|
128
139
|
answer:
|
129
140
|
invalid: Er zijn fouten opgetreden bij het beantwoorden van de vragenlijst.
|
data/config/locales/pt-BR.yml
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
val:
|
2
|
+
decidim:
|
3
|
+
forms:
|
4
|
+
admin:
|
5
|
+
questionnaires:
|
6
|
+
form:
|
7
|
+
add_title_and_description: Afig títol i descripció
|
8
|
+
title_and_description:
|
9
|
+
collapse: Redueix
|
10
|
+
description: Descripció
|
11
|
+
down: Baixar
|
12
|
+
expand: Expandeix
|
13
|
+
remove: Elimina
|
14
|
+
title: Títol
|
15
|
+
title_and_description: Títol i descripció
|
16
|
+
up: Pujar
|
17
|
+
question_types:
|
18
|
+
title_and_description: Títol i descripció
|
@@ -123,6 +123,10 @@ FactoryBot.define do
|
|
123
123
|
trait :separator do
|
124
124
|
question_type { :separator }
|
125
125
|
end
|
126
|
+
|
127
|
+
trait :title_and_description do
|
128
|
+
question_type { :title_and_description }
|
129
|
+
end
|
126
130
|
end
|
127
131
|
|
128
132
|
factory :answer, class: "Decidim::Forms::Answer" do
|
@@ -144,6 +148,14 @@ FactoryBot.define do
|
|
144
148
|
question { create(:questionnaire_question) }
|
145
149
|
body { generate_localized_title }
|
146
150
|
free_text { false }
|
151
|
+
|
152
|
+
trait :free_text_enabled do
|
153
|
+
free_text { true }
|
154
|
+
end
|
155
|
+
|
156
|
+
trait :free_text_disabled do
|
157
|
+
free_text { false }
|
158
|
+
end
|
147
159
|
end
|
148
160
|
|
149
161
|
factory :answer_choice, class: "Decidim::Forms::AnswerChoice" do
|
@@ -69,6 +69,24 @@ shared_examples_for "manage questionnaire answers" do
|
|
69
69
|
expect(page).to have_content("User identifier")
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
context "when multiple answer choice" do
|
74
|
+
let(:first_type) { "multiple_option" }
|
75
|
+
let!(:answer1) { create :answer, questionnaire: questionnaire, question: first, body: nil }
|
76
|
+
let!(:answer_option) { create :answer_option, question: first }
|
77
|
+
let!(:answer_choice) { create :answer_choice, answer: answer1, answer_option: answer_option, body: translated(answer_option.body, locale: I18n.locale) }
|
78
|
+
|
79
|
+
before do
|
80
|
+
find_all("a.action-icon.action-icon--eye").first.click
|
81
|
+
end
|
82
|
+
|
83
|
+
it "shows the answers page with custom body" do
|
84
|
+
within "#answers" do
|
85
|
+
expect(page).to have_css("dt", text: translated(first.body))
|
86
|
+
expect(page).to have_css("li", text: translated(answer_option.body))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
72
90
|
end
|
73
91
|
|
74
92
|
context "and managing individual answer page" do
|
@@ -4,20 +4,21 @@ require "spec_helper"
|
|
4
4
|
|
5
5
|
shared_examples_for "add questions" do
|
6
6
|
it "adds a few questions and separators to the questionnaire" do
|
7
|
-
|
7
|
+
fields_body = ["This is the first question", "This is the second question", "This is the first title and description"]
|
8
8
|
|
9
9
|
within "form.edit_questionnaire" do
|
10
10
|
click_button "Add question"
|
11
11
|
click_button "Add separator"
|
12
|
+
click_button "Add title and description"
|
12
13
|
click_button "Add question"
|
13
14
|
|
14
|
-
expect(page).to have_selector(".questionnaire-question", count:
|
15
|
+
expect(page).to have_selector(".questionnaire-question", count: 4)
|
15
16
|
|
16
17
|
expand_all_questions
|
17
18
|
|
18
|
-
page.all(".questionnaire-question .collapsible").each_with_index do |
|
19
|
-
within
|
20
|
-
fill_in find_nested_form_field_locator("body_en"), with:
|
19
|
+
page.all(".questionnaire-question .collapsible").each_with_index do |field, idx|
|
20
|
+
within field do
|
21
|
+
fill_in find_nested_form_field_locator("body_en"), with: fields_body[idx]
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -30,6 +31,7 @@ shared_examples_for "add questions" do
|
|
30
31
|
|
31
32
|
expect(page).to have_selector("input[value='This is the first question']")
|
32
33
|
expect(page).to have_selector("input[value='This is the second question']")
|
34
|
+
expect(page).to have_selector("input[value='This is the first title and description']")
|
33
35
|
expect(page).to have_content("Separator #2")
|
34
36
|
end
|
35
37
|
|
@@ -62,6 +64,35 @@ shared_examples_for "add questions" do
|
|
62
64
|
expect(page).to have_selector("strong", text: "Superkalifragilistic description")
|
63
65
|
end
|
64
66
|
|
67
|
+
it "adds a title-and-description" do
|
68
|
+
within "form.edit_questionnaire" do
|
69
|
+
click_button "Add title and description"
|
70
|
+
expand_all_questions
|
71
|
+
|
72
|
+
within ".questionnaire-question" do
|
73
|
+
fill_in find_nested_form_field_locator("body_en"), with: "Body"
|
74
|
+
|
75
|
+
fill_in_editor find_nested_form_field_locator("description_en", visible: false), with: "<strong>Superkalifragilistic description</strong>"
|
76
|
+
end
|
77
|
+
|
78
|
+
click_button "Save"
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(page).to have_admin_callout("successfully")
|
82
|
+
|
83
|
+
component.update!(
|
84
|
+
step_settings: {
|
85
|
+
component.participatory_space.active_step.id => {
|
86
|
+
allow_answers: true
|
87
|
+
}
|
88
|
+
}
|
89
|
+
)
|
90
|
+
|
91
|
+
visit questionnaire_public_path
|
92
|
+
|
93
|
+
expect(page).to have_selector("strong", text: "Superkalifragilistic description")
|
94
|
+
end
|
95
|
+
|
65
96
|
it "adds a question with answer options" do
|
66
97
|
question_body = ["This is the first question", "This is the second question"]
|
67
98
|
answer_options_body = [
|
@@ -118,6 +118,104 @@ shared_examples_for "update questions" do
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
context "when a questionnaire has a title and description" do
|
122
|
+
let!(:question) { create(:questionnaire_question, :title_and_description, questionnaire: questionnaire, body: title_and_description_body) }
|
123
|
+
|
124
|
+
before do
|
125
|
+
visit questionnaire_edit_path
|
126
|
+
expand_all_questions
|
127
|
+
end
|
128
|
+
|
129
|
+
it "modifies the question when the information is valid" do
|
130
|
+
within "form.edit_questionnaire" do
|
131
|
+
within ".questionnaire-question" do
|
132
|
+
fill_in "questionnaire_questions_#{question.id}_body_en", with: "Modified title and description"
|
133
|
+
end
|
134
|
+
|
135
|
+
click_button "Save"
|
136
|
+
end
|
137
|
+
|
138
|
+
expect(page).to have_admin_callout("successfully")
|
139
|
+
|
140
|
+
visit_questionnaire_edit_path_and_expand_all
|
141
|
+
|
142
|
+
expect(page).to have_selector("input[value='Modified title and description']")
|
143
|
+
expect(page).to have_no_selector("input[value='This is the first title and description']")
|
144
|
+
end
|
145
|
+
|
146
|
+
it "re-renders the form when the information is invalid and displays errors" do
|
147
|
+
expand_all_questions
|
148
|
+
|
149
|
+
within "form.edit_questionnaire" do
|
150
|
+
within ".questionnaire-question" do
|
151
|
+
fill_in "questionnaire_questions_#{question.id}_body_en", with: ""
|
152
|
+
end
|
153
|
+
|
154
|
+
click_button "Save"
|
155
|
+
end
|
156
|
+
|
157
|
+
expand_all_questions
|
158
|
+
|
159
|
+
expect(page).to have_admin_callout("There was a problem saving")
|
160
|
+
expect(page).to have_content("can't be blank", count: 1)
|
161
|
+
expect(page).to have_selector("input[value='']")
|
162
|
+
expect(page).to have_no_selector("input[value='This is the first title and description']")
|
163
|
+
end
|
164
|
+
|
165
|
+
it "preserves deleted status across submission failures" do
|
166
|
+
within "form.edit_questionnaire" do
|
167
|
+
within ".questionnaire-question" do
|
168
|
+
click_button "Remove"
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
click_button "Add question"
|
173
|
+
|
174
|
+
click_button "Save"
|
175
|
+
|
176
|
+
expect(page).to have_selector(".questionnaire-question", count: 1)
|
177
|
+
|
178
|
+
within ".questionnaire-question" do
|
179
|
+
expect(page).to have_selector(".card-title", text: "#1")
|
180
|
+
expect(page).to have_no_button("Up")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
it "removes the question" do
|
185
|
+
within "form.edit_questionnaire" do
|
186
|
+
within ".questionnaire-question" do
|
187
|
+
click_button "Remove"
|
188
|
+
end
|
189
|
+
|
190
|
+
click_button "Save"
|
191
|
+
end
|
192
|
+
|
193
|
+
expect(page).to have_admin_callout("successfully")
|
194
|
+
|
195
|
+
visit questionnaire_edit_path
|
196
|
+
|
197
|
+
within "form.edit_questionnaire" do
|
198
|
+
expect(page).to have_selector(".questionnaire-question", count: 0)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it "cannot be moved up" do
|
203
|
+
within "form.edit_questionnaire" do
|
204
|
+
within ".questionnaire-question" do
|
205
|
+
expect(page).to have_no_button("Up")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
it "cannot be moved down" do
|
211
|
+
within "form.edit_questionnaire" do
|
212
|
+
within ".questionnaire-question" do
|
213
|
+
expect(page).to have_no_button("Down")
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
121
219
|
context "when a questionnaire has an existing question with answer options" do
|
122
220
|
let!(:question) do
|
123
221
|
create(
|
@@ -16,6 +16,14 @@ shared_examples_for "manage questionnaires" do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
+
let(:title_and_description_body) do
|
20
|
+
{
|
21
|
+
en: "Este es el primer separador de texto",
|
22
|
+
ca: "Aquest és el primer separador de text",
|
23
|
+
es: "Esta es la primera pregunta"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
19
27
|
it "updates the questionnaire" do
|
20
28
|
visit questionnaire_edit_path
|
21
29
|
|
@@ -73,7 +73,7 @@ module Decidim
|
|
73
73
|
normalize_matrix_choices(answer, choices)
|
74
74
|
else
|
75
75
|
choices.map do |choice|
|
76
|
-
|
76
|
+
format_free_text_for choice
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -94,6 +94,12 @@ module Decidim
|
|
94
94
|
def answer_translated_attribute_name(attribute)
|
95
95
|
I18n.t(attribute.to_sym, scope: "decidim.forms.user_answers_serializer")
|
96
96
|
end
|
97
|
+
|
98
|
+
def format_free_text_for(choice)
|
99
|
+
return choice.try(:body) if choice.try(:custom_body).blank?
|
100
|
+
|
101
|
+
"#{choice.try(:body)} (#{choice.try(:custom_body)})"
|
102
|
+
end
|
97
103
|
end
|
98
104
|
end
|
99
105
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: decidim-core
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.26.0.rc1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.26.0.rc1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: wicked_pdf
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -61,28 +61,28 @@ dependencies:
|
|
61
61
|
requirements:
|
62
62
|
- - '='
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version: 0.
|
64
|
+
version: 0.26.0.rc1
|
65
65
|
type: :development
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - '='
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: 0.
|
71
|
+
version: 0.26.0.rc1
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: decidim-dev
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - '='
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version: 0.
|
78
|
+
version: 0.26.0.rc1
|
79
79
|
type: :development
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - '='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 0.
|
85
|
+
version: 0.26.0.rc1
|
86
86
|
description: A forms gem for decidim.
|
87
87
|
email:
|
88
88
|
- josepjaume@gmail.com
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb
|
166
166
|
- app/views/decidim/forms/admin/questionnaires/_question.html.erb
|
167
167
|
- app/views/decidim/forms/admin/questionnaires/_separator.html.erb
|
168
|
+
- app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb
|
168
169
|
- app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb
|
169
170
|
- app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb
|
170
171
|
- app/views/decidim/forms/admin/questionnaires/answers/index.html.erb
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb
|
181
182
|
- app/views/decidim/forms/questionnaires/answers/_single_option.html.erb
|
182
183
|
- app/views/decidim/forms/questionnaires/answers/_sorting.html.erb
|
184
|
+
- app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb
|
183
185
|
- app/views/decidim/forms/questionnaires/show.html.erb
|
184
186
|
- app/views/layouts/decidim/forms/admin/questionnaires/questionnaire_answers.html.erb
|
185
187
|
- config/assets.rb
|
@@ -250,6 +252,7 @@ files:
|
|
250
252
|
- config/locales/ti-ER.yml
|
251
253
|
- config/locales/tr-TR.yml
|
252
254
|
- config/locales/uk.yml
|
255
|
+
- config/locales/val-ES.yml
|
253
256
|
- config/locales/vi-VN.yml
|
254
257
|
- config/locales/vi.yml
|
255
258
|
- config/locales/zh-CN.yml
|
@@ -305,11 +308,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
308
|
version: '2.7'
|
306
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
310
|
requirements:
|
308
|
-
- - "
|
311
|
+
- - ">"
|
309
312
|
- !ruby/object:Gem::Version
|
310
|
-
version:
|
313
|
+
version: 1.3.1
|
311
314
|
requirements: []
|
312
|
-
rubygems_version: 3.1.
|
315
|
+
rubygems_version: 3.1.6
|
313
316
|
signing_key:
|
314
317
|
specification_version: 4
|
315
318
|
summary: Decidim forms
|