decidim-dev 0.24.3 → 0.25.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/decidim/dev/needs_development_tools.rb +25 -0
  3. data/app/mailers/decidim/dummy_resources/dummy_resource_mailer.rb +8 -2
  4. data/app/packs/entrypoints/decidim_dev.js +7 -0
  5. data/app/packs/entrypoints/decidim_dev.scss +1 -0
  6. data/app/{assets/images/decidim/dummy.svg → packs/images/decidim/decidim_dev_dummy.svg} +0 -0
  7. data/app/{assets/images/decidim/gamification/badges/test.svg → packs/images/decidim/gamification/badges/decidim_gamification_badges_test.svg} +0 -0
  8. data/app/packs/src/decidim/dev/accessibility.js +168 -0
  9. data/app/packs/stylesheets/decidim/dev.scss +1 -0
  10. data/app/packs/stylesheets/decidim/dev/_accessibility.scss +133 -0
  11. data/config/assets.rb +8 -0
  12. data/config/locales/ar.yml +5 -11
  13. data/config/locales/bg.yml +5 -11
  14. data/config/locales/ca.yml +5 -11
  15. data/config/locales/cs.yml +5 -11
  16. data/config/locales/de.yml +5 -11
  17. data/config/locales/el.yml +5 -11
  18. data/config/locales/en.yml +5 -11
  19. data/config/locales/es-MX.yml +5 -11
  20. data/config/locales/es-PY.yml +5 -11
  21. data/config/locales/es.yml +5 -11
  22. data/config/locales/eu.yml +5 -11
  23. data/config/locales/fi-plain.yml +5 -11
  24. data/config/locales/fi.yml +5 -11
  25. data/config/locales/fr-CA.yml +5 -11
  26. data/config/locales/fr-LU.yml +50 -0
  27. data/config/locales/fr.yml +5 -11
  28. data/config/locales/gl.yml +5 -11
  29. data/config/locales/hu.yml +5 -11
  30. data/config/locales/id-ID.yml +5 -11
  31. data/config/locales/is-IS.yml +0 -4
  32. data/config/locales/it.yml +5 -11
  33. data/config/locales/ja.yml +5 -11
  34. data/config/locales/lb-LU.yml +1 -0
  35. data/config/locales/lv.yml +3 -9
  36. data/config/locales/nl.yml +5 -11
  37. data/config/locales/no.yml +5 -11
  38. data/config/locales/pl.yml +5 -11
  39. data/config/locales/pt-BR.yml +21 -11
  40. data/config/locales/pt.yml +5 -11
  41. data/config/locales/ro-RO.yml +5 -11
  42. data/config/locales/ru.yml +5 -11
  43. data/config/locales/sk.yml +5 -11
  44. data/config/locales/sv.yml +5 -11
  45. data/config/locales/tr-TR.yml +5 -11
  46. data/config/locales/uk.yml +5 -11
  47. data/config/locales/zh-CN.yml +5 -11
  48. data/lib/decidim-dev.rb +3 -0
  49. data/lib/decidim/dev/assets/import_participatory_space_private_users_with_bom.csv +1 -0
  50. data/lib/decidim/dev/assets/import_proposals.xlsx +0 -0
  51. data/lib/decidim/dev/assets/import_voting_census.csv +5 -0
  52. data/lib/decidim/dev/assets/import_voting_census_with_ballot_styles.csv +5 -0
  53. data/lib/decidim/dev/engine.rb +17 -0
  54. data/lib/decidim/dev/test/rspec_support/accessibility_examples.rb +19 -0
  55. data/lib/decidim/dev/test/rspec_support/capybara.rb +2 -0
  56. data/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb +1 -1
  57. data/lib/decidim/dev/test/rspec_support/capybara_scopes_picker.rb +7 -1
  58. data/lib/decidim/dev/test/rspec_support/component.rb +10 -1
  59. data/lib/decidim/dev/test/rspec_support/geocoder.rb +1 -1
  60. data/lib/decidim/dev/test/rspec_support/migration.rb +50 -0
  61. data/lib/decidim/dev/test/rspec_support/time_helpers.rb +5 -0
  62. data/lib/decidim/dev/test/rspec_support/webmock.rb +1 -1
  63. data/lib/decidim/dev/test/rspec_support/wicked_pdf_assets_mock.rb +17 -0
  64. data/lib/decidim/dev/test/spec_helper.rb +2 -0
  65. data/lib/decidim/dev/version.rb +1 -1
  66. data/lib/tasks/generators.rake +4 -1
  67. metadata +59 -45
  68. data/config/locales/ja-JP.yml +0 -56
  69. data/lib/decidim/dev/assets/import_proposals.xls +0 -0
  70. data/lib/decidim/dev/test/rspec_support/attachments.rb +0 -13
  71. data/lib/decidim/dev/test/rspec_support/puffing_billy.rb +0 -55
  72. data/lib/decidim/dev/test/rspec_support/vcr.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd34a11d4198ec838481af201c0906aba46206093a6eed5cd60ad6fb32c10309
4
- data.tar.gz: 4dca88d6cfbf939e4397cc50d606d5d6a2960d82e3b07444241ee4b3167c0940
3
+ metadata.gz: 9aba426c40ed9db49b093290768b3259090e9d848ce4d75e0c09b32c96c46be0
4
+ data.tar.gz: 565ba64637d47bc4728ceee547925a78ffee3921150c32f0d2eb0ca532260cde
5
5
  SHA512:
6
- metadata.gz: 562a35cb82aa67aa363ea3d6cbc0b594af0fa4b36b963c8f8c433f819afa2860943af1b8a49c720c364602de06d81f96ec61a82ce69334d3e1af5f0c2e3601f9
7
- data.tar.gz: 89255e7b805b6072d12dbcb837aaae6cac3dd6272a0f7547a71913f3fe31dc9255bccd37df6ea103edc4c597964f1f529472dec612e640fa116b8ddcbb95ffc2
6
+ metadata.gz: b35b529f119a29986c1c94e99ca8dd568bab021481756e2fde1fd016cebfff3249ec0fd697253e4e7b7e713f89e9da63e889cecaef257ec69dc36a87a9cacf26
7
+ data.tar.gz: 2ca207da7cf3f2c11c19fd7844d1de75afb6a480b4cbc9fd5eba3a327517731446970a2f52056c325f78a11e714cf479f3f242f130e11ede1f9b2da505eeabcd
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Dev
5
+ # This concern adds development tools, such as the accessibility checks
6
+ # to the views where this is included for development purposes. This should
7
+ # be only included in the development environment.
8
+ module NeedsDevelopmentTools
9
+ extend ActiveSupport::Concern
10
+
11
+ included do
12
+ before_action :apply_development_tools
13
+ end
14
+
15
+ private
16
+
17
+ def apply_development_tools
18
+ return unless respond_to?(:snippets)
19
+
20
+ snippets.add(:head, helpers.stylesheet_pack_tag("decidim_dev"))
21
+ snippets.add(:head, helpers.javascript_pack_tag("decidim_dev"))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -3,11 +3,17 @@
3
3
  module Decidim
4
4
  module DummyResources
5
5
  class DummyResourceMailer < ApplicationMailer
6
- def send_email(user, organization)
6
+ def send_email(user, organization, subject, reply_to)
7
7
  @user = user
8
8
  @organization = organization
9
9
 
10
- mail(to: "#{user.name} <#{user.email}>") do |format|
10
+ hash = { to: "#{user.name} <#{user.email}>" }
11
+ hash[:subject] = subject if subject
12
+ hash[:reply_to] = reply_to if reply_to
13
+
14
+ mail(
15
+ hash
16
+ ) do |format|
11
17
  format.text { "This is the test" }
12
18
  format.html { "<p>This is a mail </p>" }
13
19
  end
@@ -0,0 +1,7 @@
1
+ // Images
2
+ require.context("../images", true)
3
+
4
+ // CSS
5
+ import "entrypoints/decidim_dev.scss";
6
+
7
+ import "src/decidim/dev/accessibility";
@@ -0,0 +1 @@
1
+ @import "stylesheets/decidim/dev";
@@ -0,0 +1,168 @@
1
+ import axe from "axe-core"
2
+ import icon from "src/decidim/icon"
3
+
4
+ const positionIndicators = () => {
5
+ $(".decidim-accessibility-indicator").each((_i, el) => {
6
+ const $indicator = $(el);
7
+ const $target = $indicator.data("accessibility-target");
8
+ const offset = $target.offset();
9
+
10
+ $indicator.css({
11
+ top: offset.top - 30,
12
+ left: offset.left - 30
13
+ });
14
+ });
15
+ };
16
+
17
+ const moveScreenTo = ($target) => {
18
+ // Scroll the view where the indicator is visible
19
+ const targetTop = $target.offset().top;
20
+ const screenHeight = $(window).height();
21
+ const screenTop = $(window).scrollTop();
22
+ const screenBottom = screenTop + screenHeight;
23
+ if (targetTop < screenTop || targetTop > screenBottom) {
24
+ $(window).scrollTop(targetTop - Math.round(screenHeight / 2));
25
+ }
26
+
27
+ // Scroll horizontally so that the element is visible (240 is the
28
+ // accessibility sidebar width).
29
+ const targetLeft = $target.offset().left;
30
+ const screenWidth = $(window).width() - 240;
31
+ const screenLeft = $(window).scrollLeft() + 240;
32
+ const screenRight = screenLeft + screenWidth;
33
+ if (targetLeft < screenLeft || targetLeft > screenRight) {
34
+ $(window).scrollLeft(targetLeft - Math.round(screenWidth / 2));
35
+ }
36
+ };
37
+
38
+ const htmlEncode = (text) => {
39
+ return $("<div />").text(text).html();
40
+ };
41
+
42
+ $(() => {
43
+ const $badge = $(`
44
+ <div lang="en" class="decidim-accessibility-badge" tabindex="0" aria-label="Toggle accessibility report">
45
+ <div class="decidim-accessibility-title">WAI WCAG</div>
46
+ <div class="decidim-accessibility-info"></div>
47
+ </div>
48
+ `);
49
+ const $report = $('<div lang="en" class="decidim-accessibility-report"></div>');
50
+
51
+ let resizeTimeout = null;
52
+ $(window).on("resize", () => {
53
+ clearTimeout(resizeTimeout);
54
+ resizeTimeout = setTimeout(() => {
55
+ positionIndicators();
56
+ }, 500);
57
+ });
58
+
59
+ $badge.on("click", () => {
60
+ $("body").toggleClass("decidim-accessibility-report-open");
61
+ positionIndicators();
62
+ });
63
+
64
+ axe.run().then((results) => {
65
+ $("body").prepend($report).prepend($badge);
66
+
67
+ if (results.violations.length < 1) {
68
+ $badge.addClass("decidim-accessibility-success");
69
+ $(".decidim-accessibility-info", $badge).append(icon("check"));
70
+ $report.append(`
71
+ <div class="decidim-accessibility-report-item">
72
+ <div class="decidim-accessibility-report-item-title">
73
+ No accessibility violations found
74
+ </div>
75
+ </div>
76
+ `);
77
+ return;
78
+ }
79
+
80
+ $badge.addClass("decidim-accessibility-violation");
81
+ $(".decidim-accessibility-info", $badge).append(icon("warning")).append(`
82
+ <span class="decidim-accessibility-info-amount">
83
+ ${results.violations.length}
84
+ </span>
85
+ `);
86
+
87
+ results.violations.forEach((violation) => {
88
+ const $item = $(`
89
+ <div class="decidim-accessibility-report-item" data-accessibility-violation-id="${violation.id}">
90
+ <div class="decidim-accessibility-report-item-title">
91
+ ${violation.id} - ${htmlEncode(violation.help)}
92
+ </div>
93
+ <div class="decidim-accessibility-report-item-description">
94
+ <div>Impact: ${violation.impact}</div>
95
+ <div>
96
+ ${htmlEncode(violation.description)}
97
+ </div>
98
+ <div class="decidim-accessibility-report-item-nodes">
99
+ Nodes:
100
+ </div>
101
+ </div>
102
+ </div>
103
+ `);
104
+ const $violationNodes = $("<ul></ul>");
105
+ $(".decidim-accessibility-report-item-nodes", $item).append($violationNodes);
106
+
107
+ violation.nodes.forEach((node) => {
108
+ node.target.forEach((target) => {
109
+ // The selectors can have IDs starting with numbers which may not
110
+ // be correctly indicated by axe. E.g. if the selector is `#123aa`,
111
+ // axe might report it as `#\31 23aa`. It always adds `#\3` and a
112
+ // space after the following number.
113
+ const selector = target.replace(/#\\3([0-9]) /g, "#$1")
114
+ const $target = $(selector);
115
+ const $indicator = $(`
116
+ <div class="decidim-accessibility-indicator" aria-hidden="true">${icon("warning")}</div>
117
+ `);
118
+ $indicator.data("accessibility-target", $target);
119
+ $target.data("accessibility-indicator", $indicator);
120
+ $target.attr("data-accessibility-violation", true);
121
+ $("body").append($indicator);
122
+
123
+ const $link = $(`<a href="#">${selector}</a>`);
124
+ $link.data("accessibility-target", $target);
125
+
126
+ $violationNodes.append($("<li></li>").append($link));
127
+
128
+ $indicator.on("click", () => {
129
+ clearTimeout($item.data("blink-timeout"));
130
+ clearTimeout($link.data("blink-timeout"));
131
+
132
+ $item.addClass("decidim-accessibility-report-item-blink");
133
+ $item.data("blink-timeout", setTimeout(() => {
134
+ $item.removeClass("decidim-accessibility-report-item-blink");
135
+ }, 1000));
136
+ $link.addClass("decidim-accessibility-report-item-nodes-item-blink");
137
+ $link.data("blink-timeout", setTimeout(() => {
138
+ $link.removeClass("decidim-accessibility-report-item-nodes-item-blink");
139
+ }, 1000));
140
+ });
141
+ });
142
+ });
143
+
144
+ $(".decidim-accessibility-report-item-nodes a", $item).on("click", (ev) => {
145
+ ev.preventDefault();
146
+ const $target = $(ev.target).data("accessibility-target");
147
+ const $indicator = $target.data("accessibility-indicator");
148
+ clearTimeout($indicator.data("blink-timeout"));
149
+
150
+ moveScreenTo($target);
151
+
152
+ setTimeout(() => {
153
+ // From base color to blink color (1s)
154
+ $indicator.addClass("decidim-accessibility-indicator-blink")
155
+ $target.attr("data-accessibility-violation", "blink");
156
+
157
+ // From blink color to base color (1s)
158
+ $indicator.data("blink-timeout", setTimeout(() => {
159
+ $indicator.removeClass("decidim-accessibility-indicator-blink");
160
+ $target.attr("data-accessibility-violation", true);
161
+ }, 1000));
162
+ }, 10);
163
+ });
164
+
165
+ $report.append($item);
166
+ });
167
+ });
168
+ });
@@ -0,0 +1 @@
1
+ @import "stylesheets/decidim/dev/accessibility";
@@ -0,0 +1,133 @@
1
+ .decidim-accessibility-badge{
2
+ position: fixed;
3
+ display: flex;
4
+ z-index: 9999;
5
+ top: 60px;
6
+ left: 0;
7
+ background: #fff;
8
+ border: 1px solid #888;
9
+ align-items: stretch;
10
+ user-select: none;
11
+ cursor: pointer;
12
+
13
+ &.decidim-accessibility-success{
14
+ .decidim-accessibility-info{
15
+ color: #339833;
16
+ }
17
+ }
18
+
19
+ &.decidim-accessibility-violation{
20
+ .decidim-accessibility-info{
21
+ color: #f00;
22
+ }
23
+ }
24
+
25
+ > *{
26
+ border-left: 1px solid #888;
27
+ padding: 2px 10px;
28
+
29
+ &:first-child{
30
+ border-left: 0;
31
+ }
32
+ }
33
+
34
+ .decidim-accessibility-info{
35
+ display: flex;
36
+ text-align: center;
37
+ align-items: center;
38
+ }
39
+ }
40
+
41
+ .decidim-accessibility-report{
42
+ position: fixed;
43
+ z-index: 99999;
44
+ display: none;
45
+ overflow: auto;
46
+ padding: 10px 0;
47
+ background-color: #fff;
48
+ border-right: 1px solid #888;
49
+
50
+ .decidim-accessibility-report-item{
51
+ background-color: #fff;
52
+ border-top: 1px solid #888;
53
+ padding: 10px 20px;
54
+ transition: background-color 1s;
55
+
56
+ &:first-child{
57
+ border-top: 0;
58
+ }
59
+
60
+ &.decidim-accessibility-report-item-blink{
61
+ background-color: #fff9d5;
62
+ }
63
+
64
+ .decidim-accessibility-report-item-title{
65
+ font-size: 18px;
66
+ font-weight: bold;
67
+ }
68
+
69
+ .decidim-accessibility-report-item-nodes{
70
+ a{
71
+ background-color: rgba(255, 255, 255, 0);
72
+ transition: background-color 1s;
73
+
74
+ &.decidim-accessibility-report-item-nodes-item-blink{
75
+ background-color: #ffbdad;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ .decidim-accessibility-indicator{
83
+ position: absolute;
84
+ z-index: 9999;
85
+ display: none;
86
+ opacity: 0;
87
+ width: 40px;
88
+ height: 40px;
89
+ background-color: #fff;
90
+ border: 5px solid #f00;
91
+ color: #f00;
92
+ border-radius: 50%;
93
+ align-items: center;
94
+ justify-content: center;
95
+ transition: opacity 1s, border-color 1s, background-color 1s, color 1s;
96
+ user-select: none;
97
+ cursor: pointer;
98
+
99
+ &.decidim-accessibility-indicator-blink{
100
+ border-color: #f19d00;
101
+ background-color: #f19d00;
102
+ color: #fff;
103
+ }
104
+ }
105
+
106
+ body.decidim-accessibility-report-open{
107
+ .decidim-accessibility-report{
108
+ display: block;
109
+ width: 240px;
110
+ height: 100%;
111
+ }
112
+
113
+ .decidim-accessibility-badge,
114
+ .off-canvas-wrapper,
115
+ .profiler-results.profiler-top.profiler-left{
116
+ left: 240px;
117
+ }
118
+
119
+ .decidim-accessibility-indicator{
120
+ display: flex;
121
+ opacity: 1;
122
+ }
123
+
124
+ [data-accessibility-violation]{
125
+ outline: 5px dashed #f00 !important;
126
+ outline-offset: 3px !important;
127
+ transition: outline-color 1s;
128
+
129
+ &[data-accessibility-violation="blink"]{
130
+ outline-color: #f19d00 !important;
131
+ }
132
+ }
133
+ }
data/config/assets.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ base_path = File.expand_path("..", __dir__)
4
+
5
+ Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
+ Decidim::Webpacker.register_entrypoints(
7
+ decidim_dev: "#{base_path}/app/packs/entrypoints/decidim_dev.js"
8
+ )
@@ -25,17 +25,11 @@ ar:
25
25
  next_level_in: إنشاء %{score} اختبارات أخرى للوصول إلى المستوى التالي!
26
26
  unearned_another: لم ينشئ هذا المشارك أي اختبارات حتى الآن.
27
27
  unearned_own: لم تنشئ أية اختبارات بعد.
28
- pages:
29
- home:
30
- statistics:
31
- bar: شريط
32
- dummies_count_high: الدمى عالية
33
- dummies_count_medium: الدمى المتوسطة
34
- foo: فو
35
- participatory_processes:
36
- statistics:
37
- dummies_count_high: الدمى عالية
38
- dummies_count_medium: الدمى المتوسطة
39
28
  resource_links:
40
29
  test_link:
41
30
  dummy_resource_dummy: الدمية ذات الصلة
31
+ statistics:
32
+ bar: شريط
33
+ dummies_count_high: الدمى عالية
34
+ dummies_count_medium: الدمى المتوسطة
35
+ foo: فو
@@ -40,17 +40,11 @@ bg:
40
40
  next_level_in: Създайте още %{score} теста за да достигнете следващо ниво!
41
41
  unearned_another: Този участник все още не е създал тест.
42
42
  unearned_own: Вие все още не сте създали тест.
43
- pages:
44
- home:
45
- statistics:
46
- bar: Нещо1
47
- dummies_count_high: Пример за максимум
48
- dummies_count_medium: Пример за средно
49
- foo: Нещо2
50
- participatory_processes:
51
- statistics:
52
- dummies_count_high: Пример за максимум
53
- dummies_count_medium: Пример за средно
54
43
  resource_links:
55
44
  test_link:
56
45
  dummy_resource_dummy: Пример за свързан
46
+ statistics:
47
+ bar: Нещо1
48
+ dummies_count_high: Пример за максимум
49
+ dummies_count_medium: Пример за средно
50
+ foo: Нещо2
@@ -40,17 +40,11 @@ ca:
40
40
  next_level_in: Crea %{score} més proves per arribar al següent nivell!
41
41
  unearned_another: Aquesta participant encara no ha creat cap prova.
42
42
  unearned_own: Encara no has creat cap prova.
43
- pages:
44
- home:
45
- statistics:
46
- bar: Barra
47
- dummies_count_high: Fals alt
48
- dummies_count_medium: Fals mitjà
49
- foo: Foo
50
- participatory_processes:
51
- statistics:
52
- dummies_count_high: Prova alt
53
- dummies_count_medium: Prova mig
54
43
  resource_links:
55
44
  test_link:
56
45
  dummy_resource_dummy: Prova relacionada
46
+ statistics:
47
+ bar: Barra
48
+ dummies_count_high: Fals alt
49
+ dummies_count_medium: Fals mitjà
50
+ foo: Foo