decidim-forms 0.27.2 → 0.27.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/forms/decidim/forms/answer_form.rb +17 -2
- data/app/forms/decidim/forms/questionnaire_form.rb +4 -0
- data/app/models/decidim/forms/question.rb +4 -0
- data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +1 -1
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +2 -2
- data/app/views/decidim/forms/questionnaires/show.html.erb +1 -1
- data/config/locales/eu.yml +11 -11
- data/config/locales/fa-IR.yml +1 -0
- data/config/locales/kaa.yml +1 -0
- data/config/locales/zh-TW.yml +191 -0
- data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +2 -1
- data/lib/decidim/forms/version.rb +1 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe0eacc810fb380764e96c7474000294dad78a56ff8fbba63da37ddad92da57a
|
4
|
+
data.tar.gz: d9d90aaf1e88deff5c8ad71fa685448a2a6e3ad0e73663c88a1e3567087b66b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74a496c438077dfc2404b9c832db751d43c166e8eb2ce6089b0c98c173d0fa615e34346a631bcbc2d1f1a48ac58a96de460bde7e23030c700751bb2ab5a458bb
|
7
|
+
data.tar.gz: 419adf2d45fb56a6e359015fda1bfc47d291c17295f5cab43c4780f3aad0e2d0c045c645a04972e20d9849d9a44f4bf36e94a45a956a4ac04a61c11430c34984
|
@@ -18,7 +18,7 @@ module Decidim
|
|
18
18
|
validates :selected_choices, presence: true, if: :mandatory_choices?
|
19
19
|
|
20
20
|
validate :max_choices, if: -> { question.max_choices }
|
21
|
-
validate :all_choices, if: -> { question.
|
21
|
+
validate :all_choices, if: -> { question.sorting? && question.mandatory? }
|
22
22
|
validate :min_choices, if: -> { question.matrix? && question.mandatory? }
|
23
23
|
validate :documents_present, if: -> { question.question_type == "files" && question.mandatory? }
|
24
24
|
validate :max_characters, if: -> { question.max_characters.positive? }
|
@@ -59,7 +59,22 @@ module Decidim
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def display_conditions_fulfilled?
|
62
|
-
question.display_conditions.
|
62
|
+
return optional_conditions_fulfilled? unless question.display_conditions.where(mandatory: true).any?
|
63
|
+
|
64
|
+
mandatory_conditions_fulfilled?
|
65
|
+
end
|
66
|
+
|
67
|
+
def mandatory_conditions_fulfilled?
|
68
|
+
question.display_conditions.where(mandatory: true).all? do |condition|
|
69
|
+
answer = context.responses&.find { |r| r.question_id&.to_i == condition.condition_question.id }
|
70
|
+
condition.fulfilled?(answer)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def optional_conditions_fulfilled?
|
75
|
+
return true unless question.display_conditions.where(mandatory: false).any?
|
76
|
+
|
77
|
+
question.display_conditions.where(mandatory: false).any? do |condition|
|
63
78
|
answer = context.responses&.find { |r| r.question_id&.to_i == condition.condition_question.id }
|
64
79
|
condition.fulfilled?(answer)
|
65
80
|
end
|
@@ -4,6 +4,8 @@ module Decidim
|
|
4
4
|
module Forms
|
5
5
|
# This class holds a Form to answer a questionnaire from Decidim's public page.
|
6
6
|
class QuestionnaireForm < Decidim::Form
|
7
|
+
include ActiveModel::Validations::Callbacks
|
8
|
+
|
7
9
|
# as questionnaire uses "answers" for the database relationships is
|
8
10
|
# important not to use the same word here to avoid querying all the entries, resulting in a high performance penalty
|
9
11
|
attribute :responses, Array[AnswerForm]
|
@@ -12,6 +14,8 @@ module Decidim
|
|
12
14
|
|
13
15
|
attribute :tos_agreement, Boolean
|
14
16
|
|
17
|
+
before_validation :before_validation
|
18
|
+
|
15
19
|
validates :tos_agreement, allow_nil: false, acceptance: true
|
16
20
|
validate :session_token_in_context
|
17
21
|
|
@@ -31,7 +31,7 @@
|
|
31
31
|
<%= form.translated :editor, :description, toolbar: :full, lines: 30, label: t("models.components.description", scope: "decidim.forms.admin") %>
|
32
32
|
</div>
|
33
33
|
<div class="row column">
|
34
|
-
<%= form.translated :editor, :tos, toolbar: :
|
34
|
+
<%= form.translated :editor, :tos, toolbar: :content, lines: 10, label: t("models.components.tos", scope: "decidim.forms.admin") %>
|
35
35
|
</div>
|
36
36
|
</div>
|
37
37
|
</div>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<%= label_tag field_id, translated_attribute(answer.question.body), class: "questionnaire-title_and_description" %>
|
8
8
|
<% if translated_attribute(answer.question.description).present? %>
|
9
9
|
<div class="help-title_and_description ">
|
10
|
-
<%=
|
10
|
+
<%= decidim_sanitize_editor_admin translated_attribute(answer.question.description) %>
|
11
11
|
</div>
|
12
12
|
<% end %>
|
13
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 } %>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
<% if translated_attribute(answer.question.description).present? %>
|
24
24
|
<div class="help-text">
|
25
|
-
<%=
|
25
|
+
<%= decidim_sanitize_editor_admin translated_attribute(answer.question.description) %>
|
26
26
|
</div>
|
27
27
|
<% end %>
|
28
28
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<h2 class="section-heading"><%= translated_attribute questionnaire.title %></h2>
|
12
12
|
<div class="row">
|
13
13
|
<div class="columns large-<%= columns %> medium-centered lead">
|
14
|
-
<%=
|
14
|
+
<%= decidim_sanitize_editor_admin translated_attribute questionnaire.description %>
|
15
15
|
</div>
|
16
16
|
</div>
|
17
17
|
</div>
|
data/config/locales/eu.yml
CHANGED
@@ -98,18 +98,18 @@ eu:
|
|
98
98
|
add_matrix_row: Gehitu errenkada
|
99
99
|
any: Edozein
|
100
100
|
collapse: Bildu
|
101
|
-
description:
|
102
|
-
down:
|
101
|
+
description: Deskribapena
|
102
|
+
down: Behera
|
103
103
|
expand: Zabaldu
|
104
104
|
question: Galdera
|
105
105
|
remove: Kendu
|
106
|
-
statement:
|
107
|
-
up:
|
106
|
+
statement: Adierazpena
|
107
|
+
up: Gora
|
108
108
|
separator:
|
109
|
-
down:
|
109
|
+
down: Behera
|
110
110
|
remove: Kendu
|
111
111
|
separator: Bereizlea
|
112
|
-
up:
|
112
|
+
up: Gora
|
113
113
|
title_and_description:
|
114
114
|
collapse: Tolestu
|
115
115
|
description: Deskribapena
|
@@ -124,7 +124,7 @@ eu:
|
|
124
124
|
success: Galdetegia zuzen gorde da.
|
125
125
|
admin_log:
|
126
126
|
questionnaire:
|
127
|
-
update: "%{user_name}
|
127
|
+
update: "%{user_name} erabiltzaileak %{resource_name} galdetegia eguneratu du"
|
128
128
|
errors:
|
129
129
|
answer:
|
130
130
|
body: Testua ezin da hutsik egon
|
@@ -141,21 +141,21 @@ eu:
|
|
141
141
|
multiple_option: Hainbat aukera
|
142
142
|
short_answer: Erantzun laburra
|
143
143
|
single_option: Aukera bakarra
|
144
|
-
sorting:
|
144
|
+
sorting: Sailkaketa
|
145
145
|
title_and_description: Izenburua eta deskribapena
|
146
146
|
questionnaire_answer_presenter:
|
147
147
|
download_attachment: Deskargatu eranskina
|
148
148
|
questionnaires:
|
149
149
|
answer:
|
150
|
-
invalid:
|
150
|
+
invalid: Akatsen bat gertatu da galdeketa erantzutean.
|
151
151
|
max_choices_alert: Aukera gehiegi daude hautatuta
|
152
|
-
success:
|
152
|
+
success: Formularioak ondo erantzun du.
|
153
153
|
question:
|
154
154
|
max_choices: 'Gehienezko aukerak: %{n}'
|
155
155
|
show:
|
156
156
|
answer_questionnaire:
|
157
157
|
anonymous_user_message: <a href="%{sign_in_link}">Hasi saioa zure kontuarekin</a> edo <a href="%{sign_up_link}">saioa hasi</a> galdetegiari erantzuteko.
|
158
|
-
title: Erantzun
|
158
|
+
title: Erantzun formularioari
|
159
159
|
current_step: '%{step} urratsa'
|
160
160
|
of_total_steps: '%{total_steps} etik'
|
161
161
|
questionnaire_answered:
|
@@ -0,0 +1 @@
|
|
1
|
+
fa:
|
@@ -0,0 +1 @@
|
|
1
|
+
kaa:
|
data/config/locales/zh-TW.yml
CHANGED
@@ -1 +1,192 @@
|
|
1
|
+
---
|
1
2
|
zh-TW:
|
3
|
+
activemodel:
|
4
|
+
attributes:
|
5
|
+
answer:
|
6
|
+
body: 回答
|
7
|
+
choices: 選項
|
8
|
+
selected_choices: 已選擇的選項
|
9
|
+
question:
|
10
|
+
max_choices: 選擇的最大數量
|
11
|
+
question_type: 類別
|
12
|
+
questionnaire_question:
|
13
|
+
mandatory: 必填的
|
14
|
+
max_characters: 字元限制(如果不需要限制,請設為0)
|
15
|
+
errors:
|
16
|
+
models:
|
17
|
+
answer:
|
18
|
+
attributes:
|
19
|
+
add_documents:
|
20
|
+
needs_to_be_reattached: 需要重新附加
|
21
|
+
body:
|
22
|
+
too_long: 太長
|
23
|
+
choices:
|
24
|
+
missing: 尚未完成
|
25
|
+
too_many: 太多了
|
26
|
+
questionnaire:
|
27
|
+
request_invalid: 處理請求時發生錯誤,請再試一次
|
28
|
+
decidim:
|
29
|
+
forms:
|
30
|
+
admin:
|
31
|
+
models:
|
32
|
+
components:
|
33
|
+
description: 說明
|
34
|
+
tos: 服務條款
|
35
|
+
questionnaires:
|
36
|
+
actions:
|
37
|
+
back: 返回問題
|
38
|
+
show: 顯示回應
|
39
|
+
answer_option:
|
40
|
+
answer_option: 答案選項:
|
41
|
+
free_text: 免費文字
|
42
|
+
remove: 移除
|
43
|
+
statement: 聲明
|
44
|
+
answers:
|
45
|
+
actions:
|
46
|
+
back: 返回回覆
|
47
|
+
export: 匯出
|
48
|
+
show: 顯示答案
|
49
|
+
empty: 目前尚未回答
|
50
|
+
export:
|
51
|
+
answer:
|
52
|
+
title: '回應 #%{number}'
|
53
|
+
export_response:
|
54
|
+
title: 調查問卷使用者回答_%{token}
|
55
|
+
index:
|
56
|
+
title: "%{total} 個回應總數"
|
57
|
+
show:
|
58
|
+
title: '回答#%{number}'
|
59
|
+
display_condition:
|
60
|
+
answer_option: 答案選項
|
61
|
+
condition_question: 問題
|
62
|
+
condition_type: 條件
|
63
|
+
condition_types:
|
64
|
+
answered: 已回答
|
65
|
+
equal: 等於
|
66
|
+
match: 包含文字
|
67
|
+
not_answered: 未回答
|
68
|
+
not_equal: 不等於
|
69
|
+
condition_value: 包含文字
|
70
|
+
display_condition: 顯示條件
|
71
|
+
mandatory: 這個條件必須始終滿足,無論其他條件的狀態如何。
|
72
|
+
remove: 移除
|
73
|
+
save_warning: 在配置顯示條件之前,請記得保存表單。
|
74
|
+
select_answer_option: 選擇答案選項
|
75
|
+
select_condition_question: 選取一個問題
|
76
|
+
select_condition_type: 選擇一個條件類型
|
77
|
+
edit:
|
78
|
+
save: 儲存
|
79
|
+
title: 編輯問卷內容
|
80
|
+
form:
|
81
|
+
add_question: 新增問題
|
82
|
+
add_separator: 新增分隔線
|
83
|
+
add_title_and_description: 新增標題與描述
|
84
|
+
already_answered_warning: 已有使用者回答此表單,因此您無法修改問題。
|
85
|
+
collapse: 收起所有問題
|
86
|
+
expand: 展開所有問題
|
87
|
+
preview: 預覽
|
88
|
+
title: 編輯問卷表單%{questionnaire_for}
|
89
|
+
unpublished_warning: 此表單尚未發佈。您可以修改其問題,但這樣做將刪除目前的回答。
|
90
|
+
matrix_row:
|
91
|
+
matrix_row: 列
|
92
|
+
remove: 移除
|
93
|
+
statement: 聲明
|
94
|
+
question:
|
95
|
+
add_answer_option: 新增答案選項
|
96
|
+
add_display_condition: 新增顯示條件
|
97
|
+
add_display_condition_info: 請先儲存表單再設定顯示條件
|
98
|
+
add_matrix_row: 新增列
|
99
|
+
any: 任何
|
100
|
+
collapse: 收回
|
101
|
+
description: 說明
|
102
|
+
down: 向下
|
103
|
+
expand: 展開
|
104
|
+
question: 問題
|
105
|
+
remove: 移除
|
106
|
+
statement: 聲明
|
107
|
+
up: 往上
|
108
|
+
separator:
|
109
|
+
down: 向下
|
110
|
+
remove: 移除
|
111
|
+
separator: 分隔線
|
112
|
+
up: 往上
|
113
|
+
title_and_description:
|
114
|
+
collapse: 收回
|
115
|
+
description: 說明
|
116
|
+
down: 向下
|
117
|
+
expand: 展開
|
118
|
+
remove: 移除
|
119
|
+
title: 標題
|
120
|
+
title_and_description: 標題和描述
|
121
|
+
up: 往上
|
122
|
+
update:
|
123
|
+
invalid: 儲存表單時發生問題。
|
124
|
+
success: 表單已成功儲存。
|
125
|
+
admin_log:
|
126
|
+
questionnaire:
|
127
|
+
update: "%{user_name} 更新了 %{resource_name} 問卷模板"
|
128
|
+
errors:
|
129
|
+
answer:
|
130
|
+
body: 內容不能為空
|
131
|
+
images:
|
132
|
+
dimensions: "%{width} x %{height} 像素"
|
133
|
+
processors:
|
134
|
+
resize_and_pad: 圖片將被調整大小並填充至 %{dimensions}。
|
135
|
+
resize_to_fit: 此圖片將被調整大小以符合 %{dimensions}。
|
136
|
+
question_types:
|
137
|
+
files: 檔案
|
138
|
+
long_answer: 長回答
|
139
|
+
matrix_multiple: 矩陣(多重選項)
|
140
|
+
matrix_single: 矩陣(單一選項)
|
141
|
+
multiple_option: 多選
|
142
|
+
short_answer: 簡答
|
143
|
+
single_option: 單選
|
144
|
+
sorting: 排序中
|
145
|
+
title_and_description: 標題和描述
|
146
|
+
questionnaire_answer_presenter:
|
147
|
+
download_attachment: 下載附件
|
148
|
+
questionnaires:
|
149
|
+
answer:
|
150
|
+
invalid: 回答表單時出現問題
|
151
|
+
max_choices_alert: 選擇的項目太多了
|
152
|
+
success: 表單已成功回答
|
153
|
+
question:
|
154
|
+
max_choices: '最多選擇數量: %{n}'
|
155
|
+
show:
|
156
|
+
answer_questionnaire:
|
157
|
+
anonymous_user_message: <a href="%{sign_in_link}">使用現有帳號登入</a> 或 <a href="%{sign_up_link}">註冊新帳戶</a> 以回答此表單。
|
158
|
+
title: 回答表單
|
159
|
+
current_step: 步驟%{step}
|
160
|
+
of_total_steps: 的%{total_steps}
|
161
|
+
questionnaire_answered:
|
162
|
+
body: 您已經回答過此表格。
|
163
|
+
title: 已經回答
|
164
|
+
questionnaire_closed:
|
165
|
+
body: 該表格已關閉,無法回答。
|
166
|
+
title: 表單已關閉
|
167
|
+
questionnaire_for_private_users:
|
168
|
+
body: 此表單僅適用於私人使用者
|
169
|
+
title: 表單已關閉
|
170
|
+
questionnaire_js_disabled:
|
171
|
+
body: 此表單的某些功能將被禁用。為了改善您的體驗,請在您的瀏覽器中啟用JavaScript。
|
172
|
+
title: JavaScript已停用
|
173
|
+
questionnaire_not_published:
|
174
|
+
body: 此表單尚未發佈。
|
175
|
+
tos_agreement: 透過參與,您同意其服務條款
|
176
|
+
step_navigation:
|
177
|
+
show:
|
178
|
+
are_you_sure: 此操作無法撤消,您將無法編輯您的答案。您確定嗎?
|
179
|
+
back: 返回
|
180
|
+
continue: 繼續
|
181
|
+
submit: 提交
|
182
|
+
user_answers_serializer:
|
183
|
+
body: 回答
|
184
|
+
completion: 完成
|
185
|
+
created_at: 回答時間
|
186
|
+
id: 回答 ID
|
187
|
+
ip_hash: IP Hash
|
188
|
+
question: 問題
|
189
|
+
registered: 已註冊
|
190
|
+
session_token: 使用者識別碼
|
191
|
+
unregistered: 未註冊
|
192
|
+
user_status: 用戶狀態
|
@@ -538,12 +538,13 @@ shared_examples_for "has questionnaire" do
|
|
538
538
|
end
|
539
539
|
end
|
540
540
|
|
541
|
-
context "when question type is sorting" do
|
541
|
+
context "when question type is sorting and mandatory" do
|
542
542
|
let!(:question) do
|
543
543
|
create(
|
544
544
|
:questionnaire_question,
|
545
545
|
questionnaire: questionnaire,
|
546
546
|
question_type: "sorting",
|
547
|
+
mandatory: true,
|
547
548
|
options: [
|
548
549
|
{ "body" => { "en" => "chocolate" } },
|
549
550
|
{ "body" => { "en" => "like" } },
|
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.27.
|
4
|
+
version: 0.27.3
|
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: 2023-
|
14
|
+
date: 2023-05-11 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.27.
|
22
|
+
version: 0.27.3
|
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.27.
|
29
|
+
version: 0.27.3
|
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.27.
|
64
|
+
version: 0.27.3
|
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.27.
|
71
|
+
version: 0.27.3
|
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.27.
|
78
|
+
version: 0.27.3
|
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.27.
|
85
|
+
version: 0.27.3
|
86
86
|
description: A forms gem for decidim.
|
87
87
|
email:
|
88
88
|
- josepjaume@gmail.com
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- config/locales/et-EE.yml
|
210
210
|
- config/locales/et.yml
|
211
211
|
- config/locales/eu.yml
|
212
|
+
- config/locales/fa-IR.yml
|
212
213
|
- config/locales/fi-pl.yml
|
213
214
|
- config/locales/fi-plain.yml
|
214
215
|
- config/locales/fi.yml
|
@@ -227,6 +228,7 @@ files:
|
|
227
228
|
- config/locales/it.yml
|
228
229
|
- config/locales/ja.yml
|
229
230
|
- config/locales/ka-GE.yml
|
231
|
+
- config/locales/kaa.yml
|
230
232
|
- config/locales/ko-KR.yml
|
231
233
|
- config/locales/ko.yml
|
232
234
|
- config/locales/lb-LU.yml
|
@@ -317,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
319
|
- !ruby/object:Gem::Version
|
318
320
|
version: '0'
|
319
321
|
requirements: []
|
320
|
-
rubygems_version: 3.
|
322
|
+
rubygems_version: 3.2.22
|
321
323
|
signing_key:
|
322
324
|
specification_version: 4
|
323
325
|
summary: Decidim forms
|