decidim-forms 0.27.10 → 0.28.0.rc4

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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/cells/decidim/forms/answer_readonly/show.erb +1 -1
  4. data/app/cells/decidim/forms/matrix_readonly/show.erb +1 -1
  5. data/app/cells/decidim/forms/question_readonly/show.erb +8 -8
  6. data/app/cells/decidim/forms/question_readonly/title_and_description.erb +8 -0
  7. data/app/cells/decidim/forms/question_readonly_cell.rb +7 -0
  8. data/app/cells/decidim/forms/step_navigation/show.erb +13 -26
  9. data/app/cells/decidim/forms/step_navigation_cell.rb +7 -0
  10. data/app/commands/decidim/forms/answer_questionnaire.rb +31 -11
  11. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire.rb +4 -4
  12. data/app/controllers/decidim/forms/admin/concerns/has_questionnaire_answers.rb +1 -1
  13. data/app/controllers/decidim/forms/concerns/has_questionnaire.rb +3 -3
  14. data/app/forms/decidim/forms/answer_form.rb +7 -3
  15. data/app/forms/decidim/forms/questionnaire_form.rb +1 -1
  16. data/app/helpers/decidim/forms/admin/application_helper.rb +1 -1
  17. data/app/helpers/decidim/forms/admin/concerns/has_questionnaire_answers_url_helper.rb +2 -2
  18. data/app/models/decidim/forms/answer.rb +1 -1
  19. data/app/models/decidim/forms/display_condition.rb +2 -2
  20. data/app/models/decidim/forms/question.rb +0 -4
  21. data/app/models/decidim/forms/questionnaire.rb +1 -1
  22. data/app/packs/entrypoints/decidim_forms.js +4 -0
  23. data/app/packs/src/decidim/forms/admin/collapsible_questions.js +12 -6
  24. data/app/packs/src/decidim/forms/admin/forms.js +7 -7
  25. data/app/packs/src/decidim/forms/display_conditions.component.js +3 -3
  26. data/app/packs/src/decidim/forms/forms.js +15 -9
  27. data/app/packs/src/decidim/forms/option_attached_inputs.component.js +1 -1
  28. data/app/packs/stylesheets/decidim/forms/forms.scss +82 -52
  29. data/app/packs/stylesheets/decidim/forms/questionnaire-answers-pdf.scss +13 -13
  30. data/app/presenters/decidim/forms/admin/questionnaire_participant_presenter.rb +2 -2
  31. data/app/presenters/decidim/forms/admin_log/questionnaire_presenter.rb +2 -2
  32. data/app/presenters/decidim/forms/answer_option_presenter.rb +1 -1
  33. data/app/queries/decidim/forms/questionnaire_participants.rb +1 -1
  34. data/app/views/decidim/forms/admin/questionnaires/_answer_option.html.erb +1 -1
  35. data/app/views/decidim/forms/admin/questionnaires/_answer_option_template.html.erb +1 -1
  36. data/app/views/decidim/forms/admin/questionnaires/_display_condition.html.erb +2 -2
  37. data/app/views/decidim/forms/admin/questionnaires/_display_condition_template.html.erb +1 -1
  38. data/app/views/decidim/forms/admin/questionnaires/_form.html.erb +52 -74
  39. data/app/views/decidim/forms/admin/questionnaires/_matrix_row.html.erb +1 -1
  40. data/app/views/decidim/forms/admin/questionnaires/_matrix_row_template.html.erb +1 -1
  41. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +147 -135
  42. data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +15 -13
  43. data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +69 -63
  44. data/app/views/decidim/forms/admin/questionnaires/answers/export/_answer.html.erb +4 -4
  45. data/app/views/decidim/forms/admin/questionnaires/answers/export/pdf.html.erb +1 -1
  46. data/app/views/decidim/forms/admin/questionnaires/answers/index.html.erb +41 -45
  47. data/app/views/decidim/forms/admin/questionnaires/answers/show.html.erb +13 -18
  48. data/app/views/decidim/forms/admin/questionnaires/edit.html.erb +33 -6
  49. data/app/views/decidim/forms/questionnaires/_answer.html.erb +31 -27
  50. data/app/views/decidim/forms/questionnaires/_questionnaire.html.erb +78 -0
  51. data/app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb +11 -0
  52. data/app/views/decidim/forms/questionnaires/answers/_files.html.erb +1 -1
  53. data/app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb +3 -1
  54. data/app/views/decidim/forms/questionnaires/answers/_matrix_multiple.html.erb +44 -41
  55. data/app/views/decidim/forms/questionnaires/answers/_matrix_single.html.erb +44 -41
  56. data/app/views/decidim/forms/questionnaires/answers/_multiple_option.html.erb +7 -6
  57. data/app/views/decidim/forms/questionnaires/answers/_separator.html.erb +1 -1
  58. data/app/views/decidim/forms/questionnaires/answers/_short_answer.html.erb +3 -1
  59. data/app/views/decidim/forms/questionnaires/answers/_single_option.html.erb +13 -12
  60. data/app/views/decidim/forms/questionnaires/answers/_sorting.html.erb +9 -12
  61. data/app/views/decidim/forms/questionnaires/answers/_title_and_description.html.erb +1 -1
  62. data/app/views/decidim/forms/questionnaires/show.html.erb +35 -144
  63. data/config/initializers/wicked_pdf.rb +1 -1
  64. data/config/locales/ar.yml +0 -6
  65. data/config/locales/bg.yml +0 -177
  66. data/config/locales/ca.yml +7 -2
  67. data/config/locales/cs.yml +8 -3
  68. data/config/locales/de.yml +9 -4
  69. data/config/locales/el.yml +7 -2
  70. data/config/locales/en.yml +8 -3
  71. data/config/locales/es-MX.yml +7 -2
  72. data/config/locales/es-PY.yml +7 -2
  73. data/config/locales/es.yml +7 -2
  74. data/config/locales/eu.yml +8 -3
  75. data/config/locales/fi-plain.yml +7 -2
  76. data/config/locales/fi.yml +8 -3
  77. data/config/locales/fr-CA.yml +8 -3
  78. data/config/locales/fr.yml +8 -3
  79. data/config/locales/gl.yml +0 -4
  80. data/config/locales/hu.yml +3 -9
  81. data/config/locales/id-ID.yml +0 -4
  82. data/config/locales/it.yml +0 -6
  83. data/config/locales/ja.yml +6 -1
  84. data/config/locales/lb.yml +0 -6
  85. data/config/locales/lt.yml +7 -2
  86. data/config/locales/lv.yml +0 -6
  87. data/config/locales/nl.yml +0 -6
  88. data/config/locales/no.yml +0 -6
  89. data/config/locales/pl.yml +6 -8
  90. data/config/locales/pt-BR.yml +0 -25
  91. data/config/locales/pt.yml +0 -6
  92. data/config/locales/ro-RO.yml +19 -14
  93. data/config/locales/ru.yml +0 -3
  94. data/config/locales/sk.yml +0 -6
  95. data/config/locales/sv.yml +32 -43
  96. data/config/locales/tr-TR.yml +0 -6
  97. data/config/locales/zh-CN.yml +0 -6
  98. data/config/locales/zh-TW.yml +7 -2
  99. data/lib/decidim/forms/engine.rb +8 -0
  100. data/lib/decidim/forms/test/factories.rb +37 -51
  101. data/lib/decidim/forms/test/shared_examples/has_questionnaire.rb +129 -239
  102. data/lib/decidim/forms/test/shared_examples/manage_questionnaire_answers.rb +18 -18
  103. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_display_conditions.rb +14 -14
  104. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/add_questions.rb +60 -78
  105. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_display_conditions.rb +6 -6
  106. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +25 -25
  107. data/lib/decidim/forms/test/shared_examples/manage_questionnaires.rb +9 -9
  108. data/lib/decidim/forms/user_answers_serializer.rb +1 -1
  109. data/lib/decidim/forms/version.rb +1 -1
  110. metadata +23 -18
  111. data/app/packs/src/decidim/forms/autosortable_checkboxes.component.js +0 -83
  112. data/config/locales/he-IL.yml +0 -1
  113. data/decidim-forms.gemspec +0 -34
@@ -57,14 +57,14 @@ shared_examples_for "manage questionnaires" do
57
57
  end
58
58
 
59
59
  context "when the questionnaire is already answered" do
60
- let!(:question) { create(:questionnaire_question, questionnaire: questionnaire, body: body, question_type: "multiple_option") }
61
- let!(:answer) { create(:answer, questionnaire: questionnaire, question: question) }
60
+ let!(:question) { create(:questionnaire_question, questionnaire:, body:, question_type: "multiple_option") }
61
+ let!(:answer) { create(:answer, questionnaire:, question:) }
62
62
 
63
63
  it "cannot modify questionnaire questions" do
64
64
  visit questionnaire_edit_path
65
65
 
66
- expect(page).to have_no_content("Add question")
67
- expect(page).to have_no_content("Remove")
66
+ expect(page).not_to have_content("Add question")
67
+ expect(page).not_to have_content("Remove")
68
68
 
69
69
  expand_all_questions
70
70
 
@@ -72,26 +72,26 @@ shared_examples_for "manage questionnaires" do
72
72
  expect(page).to have_selector("select[id$=question_type][disabled]")
73
73
  expect(page).to have_selector("select[id$=max_choices][disabled]")
74
74
  expect(page).to have_selector("input[id$=max_characters][disabled]")
75
- expect(page).to have_selector(".ql-editor[contenteditable=false]")
75
+ expect(page).to have_selector(".ProseMirror[contenteditable=false]")
76
76
  end
77
77
  end
78
78
 
79
79
  private
80
80
 
81
81
  def find_nested_form_field_locator(attribute, visible: :visible)
82
- find_nested_form_field(attribute, visible: visible)["id"]
82
+ find_nested_form_field(attribute, visible:)["id"]
83
83
  end
84
84
 
85
85
  def find_nested_form_field(attribute, visible: :visible)
86
- current_scope.find(nested_form_field_selector(attribute), visible: visible)
86
+ current_scope.find(nested_form_field_selector(attribute), visible:)
87
87
  end
88
88
 
89
89
  def have_nested_field(attribute, with:)
90
- have_field find_nested_form_field_locator(attribute), with: with
90
+ have_field find_nested_form_field_locator(attribute), with:
91
91
  end
92
92
 
93
93
  def have_no_nested_field(attribute, with:)
94
- have_no_field(find_nested_form_field_locator(attribute), with: with)
94
+ have_no_field(find_nested_form_field_locator(attribute), with:)
95
95
  end
96
96
 
97
97
  def nested_form_field_selector(attribute)
@@ -83,7 +83,7 @@ module Decidim
83
83
  row_body = translated_attribute(matrix_row.body)
84
84
 
85
85
  row_choices = answer.question.answer_options.map do |answer_option|
86
- choice = choices.find_by(matrix_row: matrix_row, answer_option: answer_option)
86
+ choice = choices.find_by(matrix_row:, answer_option:)
87
87
  choice.try(:custom_body) || choice.try(:body)
88
88
  end
89
89
 
@@ -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.27.10"
7
+ "0.28.0.rc4"
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.27.10
4
+ version: 0.28.0.rc4
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: 2025-03-20 00:00:00.000000000 Z
14
+ date: 2023-12-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.10
22
+ version: 0.28.0.rc4
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.10
29
+ version: 0.28.0.rc4
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.10
64
+ version: 0.28.0.rc4
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.10
71
+ version: 0.28.0.rc4
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.10
78
+ version: 0.28.0.rc4
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.10
85
+ version: 0.28.0.rc4
86
86
  description: A forms gem for decidim.
87
87
  email:
88
88
  - josepjaume@gmail.com
@@ -100,6 +100,7 @@ files:
100
100
  - app/cells/decidim/forms/matrix_readonly/show.erb
101
101
  - app/cells/decidim/forms/matrix_readonly_cell.rb
102
102
  - app/cells/decidim/forms/question_readonly/show.erb
103
+ - app/cells/decidim/forms/question_readonly/title_and_description.erb
103
104
  - app/cells/decidim/forms/question_readonly_cell.rb
104
105
  - app/cells/decidim/forms/step_navigation/show.erb
105
106
  - app/cells/decidim/forms/step_navigation_cell.rb
@@ -142,7 +143,6 @@ files:
142
143
  - app/packs/src/decidim/forms/admin/collapsible_questions.js
143
144
  - app/packs/src/decidim/forms/admin/forms.js
144
145
  - app/packs/src/decidim/forms/admin/live_text_update.component.js
145
- - app/packs/src/decidim/forms/autosortable_checkboxes.component.js
146
146
  - app/packs/src/decidim/forms/display_conditions.component.js
147
147
  - app/packs/src/decidim/forms/forms.js
148
148
  - app/packs/src/decidim/forms/max_choices_alert.component.js
@@ -173,6 +173,8 @@ files:
173
173
  - app/views/decidim/forms/admin/questionnaires/answers/show.html.erb
174
174
  - app/views/decidim/forms/admin/questionnaires/edit.html.erb
175
175
  - app/views/decidim/forms/questionnaires/_answer.html.erb
176
+ - app/views/decidim/forms/questionnaires/_questionnaire.html.erb
177
+ - app/views/decidim/forms/questionnaires/_questionnaire_readonly.html.erb
176
178
  - app/views/decidim/forms/questionnaires/answers/_files.html.erb
177
179
  - app/views/decidim/forms/questionnaires/answers/_long_answer.html.erb
178
180
  - app/views/decidim/forms/questionnaires/answers/_matrix_multiple.html.erb
@@ -219,7 +221,6 @@ files:
219
221
  - config/locales/ga-IE.yml
220
222
  - config/locales/gl.yml
221
223
  - config/locales/gn-PY.yml
222
- - config/locales/he-IL.yml
223
224
  - config/locales/hr-HR.yml
224
225
  - config/locales/hr.yml
225
226
  - config/locales/hu.yml
@@ -280,7 +281,6 @@ files:
280
281
  - db/migrate/20201110152921_add_salt_to_decidim_forms_questionnaires.rb
281
282
  - db/migrate/20210208094442_add_max_characters_to_decidim_forms_questions.rb
282
283
  - db/migrate/20210616153042_set_position_to_question_matrix_rows.rb
283
- - decidim-forms.gemspec
284
284
  - lib/decidim/api/answer_option_type.rb
285
285
  - lib/decidim/api/question_type.rb
286
286
  - lib/decidim/api/questionnaire_entity_interface.rb
@@ -304,26 +304,31 @@ files:
304
304
  - lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb
305
305
  - lib/decidim/forms/user_answers_serializer.rb
306
306
  - lib/decidim/forms/version.rb
307
- homepage: https://github.com/decidim/decidim
307
+ homepage: https://decidim.org
308
308
  licenses:
309
309
  - AGPL-3.0
310
- metadata: {}
310
+ metadata:
311
+ bug_tracker_uri: https://github.com/decidim/decidim/issues
312
+ documentation_uri: https://docs.decidim.org/
313
+ funding_uri: https://opencollective.com/decidim
314
+ homepage_uri: https://decidim.org
315
+ source_code_uri: https://github.com/decidim/decidim
311
316
  post_install_message:
312
317
  rdoc_options: []
313
318
  require_paths:
314
319
  - lib
315
320
  required_ruby_version: !ruby/object:Gem::Requirement
316
321
  requirements:
317
- - - "~>"
322
+ - - ">="
318
323
  - !ruby/object:Gem::Version
319
- version: 3.0.0
324
+ version: '3.1'
320
325
  required_rubygems_version: !ruby/object:Gem::Requirement
321
326
  requirements:
322
- - - ">="
327
+ - - ">"
323
328
  - !ruby/object:Gem::Version
324
- version: '0'
329
+ version: 1.3.1
325
330
  requirements: []
326
- rubygems_version: 3.2.22
331
+ rubygems_version: 3.4.20
327
332
  signing_key:
328
333
  specification_version: 4
329
334
  summary: Decidim forms
@@ -1,83 +0,0 @@
1
- /* eslint-disable require-jsdoc */
2
- /* eslint-disable no-ternary */
3
-
4
- class AutosortableCheckboxesComponent {
5
- constructor(options = {}) {
6
- this.wrapperField = options.wrapperField;
7
- this._bindEvent();
8
- this._order();
9
- this._normalize();
10
- }
11
-
12
- // Order by position
13
- _order() {
14
- const max = $(this.wrapperField).find(".collection-input").length;
15
- $(this.wrapperField).find(".collection-input").each((idx, el) => {
16
- const $positionField = $(el).find("input[name$=\\[position\\]]");
17
- const position = $positionField.val()
18
- ? parseInt($positionField.val(), 10)
19
- : max;
20
-
21
- let $next = $(el).next();
22
- while ($next.length > 0) {
23
- const $nextPositionField = $next.find("input[name$=\\[position\\]]");
24
- const nextPosition = $nextPositionField.val()
25
- ? parseInt($nextPositionField.val(), 10)
26
- : max;
27
-
28
- if (position > nextPosition) {
29
- $next.insertBefore($(el));
30
- }
31
- $next = $next.next();
32
- }
33
- });
34
- }
35
-
36
- _findLastPosition() {
37
- let lastPosition = 0;
38
- $(this.wrapperField).find(".collection-input").each((idx, el) => {
39
- const $positionField = $(el).find("input[name$=\\[position\\]]");
40
- const position = parseInt($positionField.val(), 10);
41
- if (position > lastPosition) {
42
- lastPosition = position;
43
- }
44
- });
45
- return lastPosition;
46
- }
47
-
48
- _normalize() {
49
- $(this.wrapperField).find(".collection-input .position").each((idx, el) => {
50
- const $positionField = $(el).parent().find("input[name$=\\[position\\]]");
51
- if ($positionField.val()) {
52
- $positionField.val(idx);
53
- $positionField.prop("disabled", false);
54
- $(el).html(`${idx + 1}. `);
55
- }
56
- });
57
- }
58
-
59
- _bindEvent() {
60
- $(this.wrapperField).find("input[type=checkbox]").on("change", (el) => {
61
- const $parentLabel = $(el.target).parents("label");
62
- const $positionSelector = $parentLabel.find(".position");
63
- const $positionField = $parentLabel.find("input[name$=\\[position\\]]");
64
- const lastPosition = this._findLastPosition();
65
-
66
- if (el.target.checked) {
67
- $positionField.val(lastPosition + 1);
68
- $positionField.prop("disabled", false);
69
- $positionSelector.html(lastPosition + 1);
70
- } else {
71
- $positionField.val("");
72
- $positionField.prop("disabled", true);
73
- $positionSelector.html("");
74
- }
75
- this._order();
76
- this._normalize();
77
- });
78
- }
79
- }
80
-
81
- export default function createAutosortableCheckboxes(options) {
82
- return new AutosortableCheckboxesComponent(options);
83
- }
@@ -1 +0,0 @@
1
- he:
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push File.expand_path("lib", __dir__)
4
-
5
- # Maintain your gem's version:
6
- require "decidim/forms/version"
7
-
8
- # Describe your gem and declare its dependencies:
9
- Gem::Specification.new do |s|
10
- s.version = Decidim::Forms.version
11
- s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva", "Rubén González Valero"]
12
- s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com", "rbngzlv@gmail.com"]
13
- s.license = "AGPL-3.0"
14
- s.homepage = "https://github.com/decidim/decidim"
15
- s.required_ruby_version = "~> 3.0.0"
16
-
17
- s.name = "decidim-forms"
18
- s.summary = "Decidim forms"
19
- s.description = "A forms gem for decidim."
20
-
21
- s.files = Dir.chdir(__dir__) do
22
- `git ls-files -z`.split("\x0").select do |f|
23
- (File.expand_path(f) == __FILE__) ||
24
- f.start_with?(*%w(app/ config/ db/ lib/ Rakefile README.md))
25
- end
26
- end
27
-
28
- s.add_dependency "decidim-core", Decidim::Forms.version
29
- s.add_dependency "wicked_pdf", "~> 2.1"
30
- s.add_dependency "wkhtmltopdf-binary", "~> 0.12"
31
-
32
- s.add_development_dependency "decidim-admin", Decidim::Forms.version
33
- s.add_development_dependency "decidim-dev", Decidim::Forms.version
34
- end