decidim-forms 0.31.0.rc1 → 0.31.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/packs/src/decidim/forms/forms.js +25 -4
  3. data/app/views/decidim/forms/admin/questionnaires/_question.html.erb +0 -10
  4. data/app/views/decidim/forms/admin/questionnaires/_questions_form.html.erb +31 -2
  5. data/app/views/decidim/forms/admin/questionnaires/_separator.html.erb +0 -10
  6. data/app/views/decidim/forms/admin/questionnaires/_title_and_description.html.erb +0 -10
  7. data/config/locales/ar.yml +0 -2
  8. data/config/locales/bg.yml +0 -8
  9. data/config/locales/ca-IT.yml +1 -7
  10. data/config/locales/ca.yml +1 -7
  11. data/config/locales/cs.yml +2 -8
  12. data/config/locales/de.yml +1 -9
  13. data/config/locales/el.yml +0 -8
  14. data/config/locales/en.yml +3 -9
  15. data/config/locales/es-MX.yml +1 -7
  16. data/config/locales/es-PY.yml +1 -7
  17. data/config/locales/es.yml +1 -7
  18. data/config/locales/eu.yml +5 -11
  19. data/config/locales/fi-plain.yml +2 -8
  20. data/config/locales/fi.yml +2 -8
  21. data/config/locales/fr-CA.yml +2 -7
  22. data/config/locales/fr.yml +2 -7
  23. data/config/locales/ga-IE.yml +0 -4
  24. data/config/locales/gl.yml +0 -4
  25. data/config/locales/hu.yml +0 -4
  26. data/config/locales/id-ID.yml +0 -2
  27. data/config/locales/it.yml +0 -6
  28. data/config/locales/ja.yml +3 -9
  29. data/config/locales/lb.yml +0 -6
  30. data/config/locales/lt.yml +0 -8
  31. data/config/locales/lv.yml +0 -4
  32. data/config/locales/nl.yml +0 -8
  33. data/config/locales/no.yml +0 -8
  34. data/config/locales/pl.yml +0 -8
  35. data/config/locales/pt-BR.yml +0 -8
  36. data/config/locales/pt.yml +0 -6
  37. data/config/locales/ro-RO.yml +0 -7
  38. data/config/locales/ru.yml +0 -2
  39. data/config/locales/sk.yml +0 -2
  40. data/config/locales/sv.yml +3 -9
  41. data/config/locales/tr-TR.yml +0 -6
  42. data/config/locales/val-ES.yml +0 -2
  43. data/config/locales/zh-CN.yml +0 -6
  44. data/config/locales/zh-TW.yml +0 -8
  45. data/lib/decidim/forms/engine.rb +6 -0
  46. data/lib/decidim/forms/test/shared_examples/manage_questionnaires/update_questions.rb +122 -25
  47. data/lib/decidim/forms/version.rb +1 -1
  48. metadata +8 -8
@@ -16,8 +16,6 @@ pt:
16
16
  description: Descrição
17
17
  tos: Termos de serviço
18
18
  questionnaires:
19
- actions:
20
- back: Retroceder às perguntas
21
19
  display_condition:
22
20
  condition_question: Pergunta
23
21
  condition_type: Condição
@@ -52,20 +50,16 @@ pt:
52
50
  any: Qualquer
53
51
  collapse: Colapsar
54
52
  description: Descrição
55
- down: Abaixo
56
53
  expand: Expandir
57
54
  question: Questão
58
55
  remove: Remover
59
56
  statement: Declaração
60
- up: Acima
61
57
  responses:
62
58
  actions:
63
59
  show: Mostrar respostas
64
60
  separator:
65
- down: Abaixo
66
61
  remove: Remover
67
62
  separator: Separador
68
- up: Acima
69
63
  update:
70
64
  invalid: Ocorreu um problema ao guardar o questionário.
71
65
  success: Formulário guardado com êxito
@@ -32,7 +32,6 @@ ro:
32
32
  tos: Termenii serviciului
33
33
  questionnaires:
34
34
  actions:
35
- back: Înapoi la întrebări
36
35
  show: Răspunsuri
37
36
  display_condition:
38
37
  condition_question: Întrebare
@@ -68,12 +67,10 @@ ro:
68
67
  any: Oricare
69
68
  collapse: Restrângeți
70
69
  description: Descriere
71
- down: Mergi în jos
72
70
  expand: Extindeți
73
71
  question: Întrebare
74
72
  remove: Eliminați
75
73
  statement: Declarație
76
- up: Mergi în sus
77
74
  response_option:
78
75
  free_text: Text liber
79
76
  remove: Eliminați
@@ -88,19 +85,15 @@ ro:
88
85
  show: Afișați răspunsurile
89
86
  empty: Nu există răspunsuri încă
90
87
  separator:
91
- down: Mergi în jos
92
88
  remove: Elimină
93
89
  separator: Separator
94
- up: Mergi în sus
95
90
  title_and_description:
96
91
  collapse: Restrângeți
97
92
  description: Descriere
98
- down: Mergi în jos
99
93
  expand: Extindeți
100
94
  remove: Șterge
101
95
  title: Titlu
102
96
  title_and_description: Titlu și descriere
103
- up: Mergi în sus
104
97
  update:
105
98
  invalid: A apărut o eroare la salvarea chestionarului.
106
99
  success: Chestionarul a fost salvat cu succes.
@@ -16,10 +16,8 @@ ru:
16
16
  remove: Удалить
17
17
  question:
18
18
  any: Любые
19
- down: Вниз
20
19
  question: Вопрос
21
20
  remove: Удалить
22
- up: Вверх
23
21
  update:
24
22
  invalid: При попытке сохранить форму произошли ошибки.
25
23
  question_types:
@@ -25,11 +25,9 @@ sk:
25
25
  question:
26
26
  any: Akékoľvek
27
27
  description: Popis
28
- down: Nadol
29
28
  question: Otázka
30
29
  remove: Odstrániť
31
30
  statement: Prehlásenie
32
- up: Hore
33
31
  update:
34
32
  invalid: Vyskytol sa problém s ukladaním formulára.
35
33
  question_types:
@@ -43,8 +43,8 @@ sv:
43
43
  components:
44
44
  allow_editing_responses: Tillåt registrerade användare att redigera egna enkätsvar
45
45
  allow_responses: Tillåt svar
46
- allow_unregistered: Tillåt ej registrerade användare att besvara enkäten
47
- allow_unregistered_help: Om aktiv kommer ingen inloggning att krävas för att besvara enkäten. Detta kan leda till dålig eller opålitlig data och det kommer att vara mer sårbart för automatiserade attacker. Använd med försiktighet! Tänk på att en deltagare kunde svara på samma enkät flera gånger, genom att använda olika webbläsare eller "privat surfning" i sin webbläsare.
46
+ allow_unregistered: Tillåt oregistrerade användare att besvara enkäten
47
+ allow_unregistered_help: Om aktiv kommer ingen inloggning att krävas för att besvara enkäten. Detta kan leda till dålig eller opålitlig data och det kommer att vara mer sårbart för automatiserade attacker. Använd med försiktighet! Tänk på att en deltagare kan svara på samma enkät flera gånger, genom att använda olika webbläsare eller "privat surfning" i sin webbläsare.
48
48
  announcement: Meddelande
49
49
  clean_after_publish: Ta bort svar vid publicering av enkäten
50
50
  description: Beskrivning
@@ -55,7 +55,7 @@ sv:
55
55
  tos: Användarvillkor
56
56
  questionnaires:
57
57
  actions:
58
- back: Tillbaka till frågor
58
+ back: Tillbaka till svar
59
59
  publish_responses: Publicera svar
60
60
  show: Svar
61
61
  display_condition:
@@ -103,12 +103,10 @@ sv:
103
103
  any: Valfritt
104
104
  collapse: Dölj
105
105
  description: Beskrivning
106
- down: Ner
107
106
  expand: Visa
108
107
  question: Fråga
109
108
  remove: Ta bort
110
109
  statement: Titel
111
- up: Upp
112
110
  questions_form:
113
111
  already_responded_warning: Formuläret har redan besvarats av en användare, så du kan inte längre redigera frågorna.
114
112
  collapse: Dölj alla frågor
@@ -139,19 +137,15 @@ sv:
139
137
  show:
140
138
  title: 'Svar #%{number}'
141
139
  separator:
142
- down: Ner
143
140
  remove: Ta bort
144
141
  separator: Avgränsare
145
- up: Upp
146
142
  title_and_description:
147
143
  collapse: Dölj
148
144
  description: Beskrivning
149
- down: Ner
150
145
  expand: Visa
151
146
  remove: Ta bort
152
147
  title: Titel
153
148
  title_and_description: Titel och beskrivning
154
- up: Upp
155
149
  update:
156
150
  invalid: Det gick inte att spara formuläret.
157
151
  success: Formuläret har sparats.
@@ -15,8 +15,6 @@ tr:
15
15
  description: Açıklama
16
16
  tos: Kullanım Şartları
17
17
  questionnaires:
18
- actions:
19
- back: Sorulara geri dön
20
18
  display_condition:
21
19
  condition_question: Soru
22
20
  condition_type: Durum
@@ -51,20 +49,16 @@ tr:
51
49
  any: herhangi
52
50
  collapse: Daralt
53
51
  description: Açıklama
54
- down: Aşağı
55
52
  expand: Genişlet
56
53
  question: Soru
57
54
  remove: Kaldır
58
55
  statement: Beyan
59
- up: yukarı
60
56
  responses:
61
57
  actions:
62
58
  show: Yanıtları göster
63
59
  separator:
64
- down: Aşağı
65
60
  remove: Kaldır
66
61
  separator: Ayraç
67
- up: Yukarı
68
62
  update:
69
63
  invalid: Formu kaydederken bir sorun oluştu.
70
64
  success: Başarıyla kaydedildi.
@@ -7,11 +7,9 @@ val:
7
7
  title_and_description:
8
8
  collapse: Redueix
9
9
  description: Descripció
10
- down: Baixar
11
10
  expand: Expandeix
12
11
  remove: Elimina
13
12
  title: Títol
14
13
  title_and_description: Títol i descripció
15
- up: Pujar
16
14
  question_types:
17
15
  title_and_description: Títol i descripció
@@ -15,8 +15,6 @@ zh-CN:
15
15
  description: 描述
16
16
  tos: 服务条款
17
17
  questionnaires:
18
- actions:
19
- back: 返回问题
20
18
  display_condition:
21
19
  condition_question: 问
22
20
  condition_type: 条件
@@ -50,20 +48,16 @@ zh-CN:
50
48
  any: 任何
51
49
  collapse: 收起
52
50
  description: 描述
53
- down: 向下
54
51
  expand: 扩展
55
52
  question: 问
56
53
  remove: 删除
57
54
  statement: 声明
58
- up: 上移
59
55
  responses:
60
56
  actions:
61
57
  show: 显示回复
62
58
  separator:
63
- down: 向下
64
59
  remove: 删除
65
60
  separator: 分隔符
66
- up: 上移
67
61
  update:
68
62
  invalid: 保存表单时出错。
69
63
  success: 表单保存成功。
@@ -16,8 +16,6 @@ zh-TW:
16
16
  description: 說明
17
17
  tos: 服務條款
18
18
  questionnaires:
19
- actions:
20
- back: 返回問題
21
19
  display_condition:
22
20
  condition_question: 問題
23
21
  condition_type: 條件
@@ -52,29 +50,23 @@ zh-TW:
52
50
  any: 任何
53
51
  collapse: 收回
54
52
  description: 說明
55
- down: 向下
56
53
  expand: 展開
57
54
  question: 問題
58
55
  remove: 移除
59
56
  statement: 聲明
60
- up: 往上
61
57
  responses:
62
58
  actions:
63
59
  show: 顯示回應
64
60
  separator:
65
- down: 向下
66
61
  remove: 移除
67
62
  separator: 分隔線
68
- up: 往上
69
63
  title_and_description:
70
64
  collapse: 收回
71
65
  description: 說明
72
- down: 向下
73
66
  expand: 展開
74
67
  remove: 移除
75
68
  title: 標題
76
69
  title_and_description: 標題和描述
77
- up: 往上
78
70
  update:
79
71
  invalid: 儲存表單時發生問題。
80
72
  success: 表單已成功儲存。
@@ -16,6 +16,12 @@ module Decidim
16
16
  Decidim.register_assets_path File.expand_path("app/packs", root)
17
17
  end
18
18
 
19
+ initializer "decidim_forms.data_migrate", after: "decidim_core.data_migrate" do
20
+ DataMigrate.configure do |config|
21
+ config.data_migrations_path << root.join("db/data").to_s
22
+ end
23
+ end
24
+
19
25
  initializer "decidim_forms.authorization_transfer" do
20
26
  config.to_prepare do
21
27
  Decidim::AuthorizationTransfer.register(:forms) do |transfer|
@@ -317,6 +317,10 @@ shared_examples_for "update questions" do
317
317
  create(:questionnaire_question, questionnaire:, body: second_body, position: 1)
318
318
  end
319
319
 
320
+ let!(:question3) do
321
+ create(:questionnaire_question, questionnaire:, body: third_body, position: 2)
322
+ end
323
+
320
324
  let(:first_body) do
321
325
  { en: "First", ca: "Primera", es: "Primera" }
322
326
  end
@@ -325,6 +329,10 @@ shared_examples_for "update questions" do
325
329
  { en: "Second", ca: "Segona", es: "Segunda" }
326
330
  end
327
331
 
332
+ let(:third_body) do
333
+ { en: "Third", ca: "Tercera", es: "Tercera" }
334
+ end
335
+
328
336
  before do
329
337
  click_on "Save"
330
338
  visit_manage_questions_and_expand_all
@@ -344,26 +352,6 @@ shared_examples_for "update questions" do
344
352
  end
345
353
  end
346
354
 
347
- context "when moving a question up" do
348
- before do
349
- within ".questionnaire-question:last-of-type" do
350
- click_on "Up"
351
- end
352
- end
353
-
354
- it_behaves_like "switching questions order"
355
- end
356
-
357
- context "when moving a question down" do
358
- before do
359
- within ".questionnaire-question:first-of-type" do
360
- click_on "Down"
361
- end
362
- end
363
-
364
- it_behaves_like "switching questions order"
365
- end
366
-
367
355
  describe "collapsible questions" do
368
356
  context "when clicking on Expand all button" do
369
357
  it "expands all questions" do
@@ -459,16 +447,37 @@ shared_examples_for "update questions" do
459
447
  click_on "Add question"
460
448
  expand_all_questions
461
449
 
462
- expect(page.find(".questionnaire-question:nth-of-type(1)")).to look_like_first_question
463
- expect(page.find(".questionnaire-question:nth-of-type(2)")).to look_like_intermediate_question
464
- expect(page.find(".questionnaire-question:nth-of-type(3)")).to look_like_last_question
450
+ question_cards = page.all(".questionnaire-question")
451
+ expect(question_cards.size).to eq(4)
452
+
453
+ within question_cards[1] do
454
+ expect(find("input[name*='[body_en]']").value).to eq("Second")
455
+ end
456
+ within question_cards[2] do
457
+ expect(find("input[name*='[body_en]']").value).to eq("Third")
458
+ end
465
459
 
466
460
  within ".questionnaire-question:first-of-type" do
467
461
  click_on "Remove"
468
462
  end
469
463
 
470
- expect(page.all(".questionnaire-question").first).to look_like_first_question
471
- expect(page.all(".questionnaire-question").last).to look_like_last_question
464
+ remaining_cards = page.all(".questionnaire-question")
465
+ expect(remaining_cards.size).to eq(3)
466
+
467
+ # Check that the first question is now what was previously the second
468
+ within remaining_cards.first do
469
+ expect(find("input[name*='[body_en]']").value).to eq("Second")
470
+ end
471
+
472
+ # Check that the second question is now what was previously the third
473
+ within remaining_cards[1] do
474
+ expect(find("input[name*='[body_en]']").value).to eq("Third")
475
+ end
476
+
477
+ # The last question should be the new empty question
478
+ within remaining_cards.last do
479
+ expect(find("input[name*='[body_en]']").value).to eq("")
480
+ end
472
481
  end
473
482
 
474
483
  it "does not duplicate editors when adding new questions" do
@@ -512,6 +521,94 @@ shared_examples_for "update questions" do
512
521
  end
513
522
  end
514
523
 
524
+ context "when reordering questions with drag and drop", :js do
525
+ before do
526
+ expand_all_questions
527
+ end
528
+
529
+ it "allows moving questions using drag and drop" do
530
+ question_cards = all(".questionnaire-question")
531
+
532
+ # Verify initial order by checking the body field values
533
+ within question_cards[0] do
534
+ expect(find("input[name*='[body_en]']").value).to eq("First")
535
+ end
536
+ within question_cards[1] do
537
+ expect(find("input[name*='[body_en]']").value).to eq("Second")
538
+ end
539
+ within question_cards[2] do
540
+ expect(find("input[name*='[body_en]']").value).to eq("Third")
541
+ end
542
+
543
+ # JavaScript to simulate drag and drop.
544
+ page.execute_script(<<~JS)
545
+ var questions = document.querySelectorAll('.questionnaire-question');
546
+ var container = questions[0].parentNode;
547
+ var second = questions[1];
548
+ var first = questions[0];
549
+
550
+ // Move second question before first
551
+ container.insertBefore(second, first);
552
+
553
+ // Update position values
554
+ var updatedQuestions = container.querySelectorAll('.questionnaire-question');
555
+ updatedQuestions.forEach(function(question, index) {
556
+ var positionInput = question.querySelector('input[name$="[position]"]');
557
+ if (positionInput) positionInput.value = index;
558
+ });
559
+ JS
560
+
561
+ sleep 0.5
562
+
563
+ question_cards = all(".questionnaire-question")
564
+ within question_cards[0] do
565
+ expect(find("input[name*='[body_en]']").value).to eq("Second")
566
+ end
567
+ within question_cards[1] do
568
+ expect(find("input[name*='[body_en]']").value).to eq("First")
569
+ end
570
+ within question_cards[2] do
571
+ expect(find("input[name*='[body_en]']").value).to eq("Third")
572
+ end
573
+ end
574
+
575
+ it "persists drag and drop changes when saving" do
576
+ # Move second question to last position
577
+ page.execute_script(<<~JS)
578
+ var questions = document.querySelectorAll('.questionnaire-question');
579
+ var container = questions[0].parentNode;
580
+ var second = questions[1];
581
+
582
+ container.appendChild(second);
583
+
584
+ // Update the positions of questions
585
+ var updatedQuestions = container.querySelectorAll('.questionnaire-question');
586
+ updatedQuestions.forEach(function(question, index) {
587
+ var positionInput = question.querySelector('input[name$="[position]"]');
588
+ if (positionInput) positionInput.value = index;
589
+ });
590
+ JS
591
+
592
+ sleep 0.5
593
+
594
+ click_on "Save"
595
+ expect(page).to have_admin_callout("successfully")
596
+
597
+ visit_manage_questions_and_expand_all
598
+
599
+ question_cards = all(".questionnaire-question")
600
+ within question_cards[0] do
601
+ expect(find("input[name*='[body_en]']").value).to eq("First")
602
+ end
603
+ within question_cards[1] do
604
+ expect(find("input[name*='[body_en]']").value).to eq("Third")
605
+ end
606
+ within question_cards[2] do
607
+ expect(find("input[name*='[body_en]']").value).to eq("Second")
608
+ end
609
+ end
610
+ end
611
+
515
612
  private
516
613
 
517
614
  def look_like_first_question
@@ -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.31.0.rc1"
7
+ "0.31.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.31.0.rc1
4
+ version: 0.31.0
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-09-25 00:00:00.000000000 Z
14
+ date: 2025-11-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: decidim-core
@@ -19,42 +19,42 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.31.0.rc1
22
+ version: 0.31.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.31.0.rc1
29
+ version: 0.31.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.31.0.rc1
36
+ version: 0.31.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.31.0.rc1
43
+ version: 0.31.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.31.0.rc1
50
+ version: 0.31.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.31.0.rc1
57
+ version: 0.31.0
58
58
  description: A forms gem for decidim.
59
59
  email:
60
60
  - josepjaume@gmail.com