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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1f739e99aa949b0c152539fdb879902ff12d2d28004b59d8d00316a48e71fff
4
- data.tar.gz: 92e86b5dea1b22fd8432d8e5fee5aecb8f35a4a144d1ccaa7ed1f7107680cb60
3
+ metadata.gz: '0916ac709d1816a9f838bdf0375b522b90cc42807e0d74f8bbf02e4437c341f3'
4
+ data.tar.gz: 27c4a52effed7e6d7aaa8edb5d9d4627aedf4837192201883e91cbf85bd12482
5
5
  SHA512:
6
- metadata.gz: a762c17fc2c49dfb3b0d6317cfa170ff267422ef8abaf37eed0f1addaf057ded807fc181a3d85ecfde6724b12089a88f2afefdd2005529c513dd651dccb98e51
7
- data.tar.gz: 0b84771051699336925d54983224785ff10a01a25b3fd8b4d3f3d9f161ecc7b9ab6e4542d96e19c4f8b6e23981a33c735b78547fab41720e5204a1bbc3940e14
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("label").find(this.dependentInputSelector).prop("disabled", !enabled);
17
+ $field.parents("div.collection-input").find(this.dependentInputSelector).prop("disabled", !enabled);
18
18
  });
19
19
  }
20
20
 
@@ -1,7 +1,7 @@
1
1
  <li class="questionnaire-question_readonly">
2
2
  <p>
3
3
  <%= translated_attribute(model.body) %>
4
- <br />
4
+ <br>
5
5
  <em>
6
6
  (<%= t(model.question_type, scope: "decidim.forms.question_types") %>)
7
7
  </em>
@@ -46,6 +46,7 @@ module Decidim
46
46
 
47
47
  def user_questionnaire_same_organization
48
48
  return if user&.organization == questionnaire.questionnaire_for&.organization
49
+
49
50
  errors.add(:user, :invalid)
50
51
  end
51
52
 
@@ -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
- <%= label_tag "#{choice_id}_body" do %>
23
- <%= radio_button_tag "questionnaire[answers][#{answer_idx}][choices][][body]",
24
- translated_attribute(answer_option.body),
25
- answer_option.id == choice.try(:answer_option_id),
26
- id: "#{choice_id}_body", disabled: disabled %>
27
-
28
- <%= translated_attribute(answer_option.body) %>
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
- choice.try(:custom_body),
33
- id: "#{choice_id}_custom_body",
34
- disabled: true %>
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
- <%= label_tag do %>
50
- <%= check_box_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][body]",
51
- translated_attribute(answer_option.body),
52
- choice.present?, disabled: disabled %>
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
- <%= translated_attribute(answer_option.body) %>
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
- choice.try(:custom_body),
59
- disabled: true %>
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
- <%= label_tag do %>
72
- <%= check_box_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][body]",
73
- translated_attribute(answer_option.body),
74
- choice.present?, disabled: disabled %>
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
- <span class="position"><%= choice.try(:position) %></span>
81
+ <span class="position"><%= choice.try(:position) %></span>
77
82
 
78
- <%= translated_attribute(answer_option.body) %>
83
+ <%= translated_attribute(answer_option.body) %>
79
84
 
80
- <%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][position]",
81
- choice.try(:position),
82
- disabled: true %>
85
+ <%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][position]",
86
+ choice.try(:position),
87
+ disabled: true %>
83
88
 
84
- <%= hidden_field_tag "questionnaire[answers][#{answer_idx}][choices][#{idx}][answer_option_id]", answer_option.id %>
85
- <% end %>
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 %>
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-forms version.
5
5
  module Forms
6
6
  def self.version
7
- "0.18.1"
7
+ "0.19.0"
8
8
  end
9
9
  end
10
10
  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.18.1
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.18.1
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.18.1
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.18.1
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.18.1
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.18.1
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.18.1
57
+ version: 0.19.0
58
58
  description: A forms gem for decidim.
59
59
  email:
60
60
  - josepjaume@gmail.com