decidim-forms 0.18.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -0
- data/app/assets/javascripts/decidim/forms/option_attached_inputs.component.js.es6 +1 -1
- data/app/cells/decidim/forms/question_readonly/show.erb +1 -1
- data/app/models/decidim/forms/answer.rb +1 -0
- data/app/views/decidim/forms/questionnaires/_answer.html.erb +43 -37
- data/lib/decidim/forms/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0916ac709d1816a9f838bdf0375b522b90cc42807e0d74f8bbf02e4437c341f3'
|
4
|
+
data.tar.gz: 27c4a52effed7e6d7aaa8edb5d9d4627aedf4837192201883e91cbf85bd12482
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 292bb79f355a53d0c2bc873c89eca392868b6b64e4db423007dc84d270f46a83e892b51094155e771727419ed0ce2049d40853611b507fedfe8860a91ee3b776
|
7
|
+
data.tar.gz: a0d0f60932f6686f72dbd5064cdadb0025f36a8e6934d2817cc5ed14828403fe71b767223f7c77e2b7e1b421c9af4d0dbcf33c65e33be272449f07f6f84b57fb
|
data/README.md
CHANGED
@@ -2,6 +2,34 @@
|
|
2
2
|
|
3
3
|
This gem encapsulates the logic to create and manage forms, so it can be reused in other modules, like surveys and meetings.
|
4
4
|
|
5
|
+
A `Decidim::Forms::Question` must be of one of the types:
|
6
|
+
|
7
|
+
- short_answer
|
8
|
+
- long_answer
|
9
|
+
- single_option
|
10
|
+
- multiple_option
|
11
|
+
- sorting
|
12
|
+
|
13
|
+
Here are the relations between the classes of a `Decidim::Questionnaire`:
|
14
|
+
|
15
|
+
```
|
16
|
+
1..* +----------+ 1..* +--------------+
|
17
|
+
+------------->| Question |------------->| AnswerOption |
|
18
|
+
| +-----+----+ +------+-------+
|
19
|
+
| ^ 1..1 ^ 1..*
|
20
|
+
| | |
|
21
|
+
| | |
|
22
|
+
+-------+-------+ 1..* +---+----+ 1..* +------+-------+
|
23
|
+
| Questionnaire +------->| Answer |<-------------+ AnswerChoice |
|
24
|
+
+---------------+ +---+----+ +--------------+
|
25
|
+
|
|
26
|
+
|
|
27
|
+
v 1..1
|
28
|
+
+--+---+
|
29
|
+
| User |
|
30
|
+
+------+
|
31
|
+
```
|
32
|
+
|
5
33
|
## Installation
|
6
34
|
|
7
35
|
Add this line to your module's gemspec:
|
@@ -14,7 +14,7 @@
|
|
14
14
|
const $field = $(el);
|
15
15
|
const enabled = $field.is(":checked");
|
16
16
|
|
17
|
-
$field.parents("
|
17
|
+
$field.parents("div.collection-input").find(this.dependentInputSelector).prop("disabled", !enabled);
|
18
18
|
});
|
19
19
|
}
|
20
20
|
|
@@ -19,26 +19,28 @@
|
|
19
19
|
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
20
20
|
<% choice_id = "#{field_id}_choices_#{idx}" %>
|
21
21
|
|
22
|
-
|
23
|
-
<%=
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
<div class="collection-input">
|
23
|
+
<%= label_tag "#{choice_id}_body" do %>
|
24
|
+
<%= radio_button_tag "questionnaire[answers][#{answer_idx}][choices][][body]",
|
25
|
+
translated_attribute(answer_option.body),
|
26
|
+
answer_option.id == choice.try(:answer_option_id),
|
27
|
+
id: "#{choice_id}_body", disabled: disabled %>
|
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 %>
|
29
36
|
|
30
37
|
<% if answer_option.free_text %>
|
31
38
|
<%= text_field_tag "questionnaire[answers][#{answer_idx}][choices][][custom_body]",
|
32
|
-
|
33
|
-
|
34
|
-
|
39
|
+
choice.try(:custom_body),
|
40
|
+
id: "#{choice_id}_custom_body",
|
41
|
+
disabled: true %>
|
35
42
|
<% end %>
|
36
|
-
|
37
|
-
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][][answer_option_id]",
|
38
|
-
answer_option.id,
|
39
|
-
id: "#{choice_id}_answer_option",
|
40
|
-
disabled: true %>
|
41
|
-
<% end %>
|
43
|
+
</div>
|
42
44
|
<% end %>
|
43
45
|
</div>
|
44
46
|
<% when "multiple_option" %>
|
@@ -46,21 +48,23 @@
|
|
46
48
|
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
47
49
|
<% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
|
48
50
|
|
49
|
-
|
50
|
-
<%=
|
51
|
-
|
52
|
-
|
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 %>
|
53
56
|
|
54
|
-
|
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 %>
|
55
61
|
|
56
62
|
<% if answer_option.free_text %>
|
57
63
|
<%= text_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][custom_body]",
|
58
|
-
|
59
|
-
|
64
|
+
choice.try(:custom_body),
|
65
|
+
disabled: true %>
|
60
66
|
<% end %>
|
61
|
-
|
62
|
-
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
|
63
|
-
<% end %>
|
67
|
+
</div>
|
64
68
|
<% end %>
|
65
69
|
</div>
|
66
70
|
<% when "sorting" %>
|
@@ -68,21 +72,23 @@
|
|
68
72
|
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
|
69
73
|
<% choice = answer.selected_choices.find { |choice| choice.answer_option_id == answer_option.id } %>
|
70
74
|
|
71
|
-
|
72
|
-
<%=
|
73
|
-
|
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 %>
|
75
80
|
|
76
|
-
|
81
|
+
<span class="position"><%= choice.try(:position) %></span>
|
77
82
|
|
78
|
-
|
83
|
+
<%= translated_attribute(answer_option.body) %>
|
79
84
|
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][position]",
|
86
|
+
choice.try(:position),
|
87
|
+
disabled: true %>
|
83
88
|
|
84
|
-
|
85
|
-
|
89
|
+
<%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
|
90
|
+
<% end %>
|
91
|
+
</div>
|
86
92
|
<% end %>
|
87
93
|
</div>
|
88
94
|
<% 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.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josep Jaume Rey Peroy
|
@@ -19,42 +19,42 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.19.0
|
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.19.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: decidim-admin
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.
|
36
|
+
version: 0.19.0
|
37
37
|
type: :development
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.19.0
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
45
|
name: decidim-dev
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - '='
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.
|
50
|
+
version: 0.19.0
|
51
51
|
type: :development
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - '='
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.
|
57
|
+
version: 0.19.0
|
58
58
|
description: A forms gem for decidim.
|
59
59
|
email:
|
60
60
|
- josepjaume@gmail.com
|