decidim-decidim_awesome 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -9
  3. data/app/assets/config/decidim_admin_decidim_awesome_manifest.css +2 -2
  4. data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +1 -2
  5. data/app/assets/config/decidim_decidim_awesome_manifest.css +2 -2
  6. data/app/assets/config/decidim_decidim_awesome_manifest.js +3 -2
  7. data/app/assets/config/legacy_decidim_admin_decidim_awesome_manifest.js +2 -0
  8. data/app/assets/config/legacy_decidim_decidim_awesome_manifest.js +4 -0
  9. data/app/assets/javascripts/decidim/decidim_awesome/admin/auto_edit.js.es6 +77 -0
  10. data/app/assets/javascripts/decidim/decidim_awesome/admin/codemirror.js.es6 +2 -3
  11. data/app/assets/javascripts/decidim/decidim_awesome/admin/form_builder.js.es6 +80 -0
  12. data/app/assets/javascripts/decidim/decidim_awesome/admin/legacy_form_builder.js.es6 +80 -0
  13. data/app/assets/javascripts/decidim/decidim_awesome/admin/user_picker.js.es6 +24 -0
  14. data/app/assets/javascripts/decidim/decidim_awesome/awesome_admin.js +7 -0
  15. data/app/assets/javascripts/decidim/decidim_awesome/{application.js → awesome_application.js} +1 -2
  16. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/layers.js.es6 +3 -2
  17. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/load_map.js.es6 +15 -0
  18. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +52 -56
  19. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +2 -2
  20. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +1 -1
  21. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/utilities.js.es6 +33 -24
  22. data/app/assets/javascripts/decidim/decidim_awesome/editors/legacy_quill_editor.js.es6 +14 -2
  23. data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +18 -4
  24. data/app/assets/javascripts/decidim/decidim_awesome/editors/tabs_focus.js.es6 +24 -0
  25. data/app/assets/javascripts/decidim/decidim_awesome/forms/custom_fields_builder.js.es6 +211 -0
  26. data/app/assets/javascripts/decidim/decidim_awesome/forms/rich_text_plugin.js.es6 +106 -0
  27. data/app/assets/javascripts/decidim/decidim_awesome/legacy_admin.js +5 -1
  28. data/app/assets/javascripts/decidim/decidim_awesome/legacy_application.js +0 -1
  29. data/app/assets/javascripts/decidim/decidim_awesome/proposals/custom_fields.js.es6 +21 -0
  30. data/app/assets/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss +15 -0
  31. data/app/assets/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +15 -4
  32. data/app/assets/stylesheets/decidim/decidim_awesome/admin/constraints.scss +12 -0
  33. data/app/assets/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +66 -0
  34. data/app/assets/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +35 -0
  35. data/app/assets/stylesheets/decidim/decidim_awesome/{admin.scss → awesome_admin.scss} +12 -0
  36. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_application.scss +22 -0
  37. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +0 -1
  38. data/app/assets/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +16 -1
  39. data/app/awesome_overrides/forms/decidim/proposals/proposal_wizard_create_step_form_override.rb +28 -0
  40. data/app/cells/decidim/decidim_awesome/content_blocks/map/show.erb +74 -0
  41. data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +54 -0
  42. data/app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb +61 -0
  43. data/app/cells/decidim/decidim_awesome/content_blocks/map_form_cell.rb +19 -0
  44. data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +32 -0
  45. data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +45 -0
  46. data/app/commands/decidim/decidim_awesome/admin/create_scoped_admin.rb +38 -0
  47. data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +4 -0
  48. data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +40 -0
  49. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb +40 -0
  50. data/app/commands/decidim/decidim_awesome/admin/destroy_scoped_style.rb +1 -1
  51. data/app/commands/decidim/decidim_awesome/admin/rename_scope_label.rb +58 -0
  52. data/app/commands/decidim/decidim_awesome/admin/update_config.rb +1 -0
  53. data/app/controllers/concerns/decidim/decidim_awesome/admin_not_found_redirect.rb +39 -0
  54. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +31 -18
  55. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +4 -0
  56. data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +38 -0
  57. data/app/controllers/decidim/decidim_awesome/admin/scoped_admins_controller.rb +38 -0
  58. data/app/controllers/decidim/decidim_awesome/admin/scoped_styles_controller.rb +38 -0
  59. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +39 -0
  60. data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +3 -1
  61. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +11 -7
  62. data/app/helpers/decidim/decidim_awesome/amendments_helper_override.rb +48 -0
  63. data/app/helpers/decidim/decidim_awesome/map_helper.rb +67 -16
  64. data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +78 -0
  65. data/app/middleware/decidim/decidim_awesome/current_config.rb +182 -0
  66. data/app/models/decidim/decidim_awesome/awesome_config.rb +15 -0
  67. data/app/models/decidim/decidim_awesome/user_override.rb +25 -0
  68. data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +2 -0
  69. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -1
  70. data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -0
  71. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +2 -2
  72. data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +21 -0
  73. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +0 -3
  74. data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +25 -0
  75. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +0 -2
  76. data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +4 -7
  77. data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +4 -0
  78. data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +6 -0
  79. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +0 -2
  80. data/app/views/decidim/proposals/admin/proposals/_form.html.erb +101 -0
  81. data/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb +83 -0
  82. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -0
  83. data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +25 -11
  84. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +4 -0
  85. data/app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb +1 -1
  86. data/app/views/v0.23/decidim/proposals/collaborative_drafts/_show.html.erb +134 -0
  87. data/app/views/v0.23/layouts/decidim/_head.html.erb +1 -1
  88. data/app/views/v0.23/layouts/decidim/admin/_header.html.erb +1 -1
  89. data/app/views/v0.24/decidim/proposals/collaborative_drafts/_show.html.erb +128 -0
  90. data/app/views/v0.24/layouts/decidim/_head.html.erb +2 -2
  91. data/app/views/v0.24/layouts/decidim/admin/_header.html.erb +2 -2
  92. data/config/locales/ca.yml +62 -3
  93. data/config/locales/cs.yml +62 -3
  94. data/config/locales/en.yml +90 -11
  95. data/config/locales/es.yml +61 -2
  96. data/config/locales/eu.yml +63 -4
  97. data/config/locales/fr.yml +62 -3
  98. data/config/locales/it.yml +284 -0
  99. data/config/locales/ja.yml +284 -0
  100. data/config/locales/nl.yml +62 -3
  101. data/config/locales/sv.yml +62 -3
  102. data/db/migrate/20210628150825_change_awesome_config_var_type.rb +12 -0
  103. data/lib/decidim/decidim_awesome/admin_engine.rb +16 -4
  104. data/lib/decidim/decidim_awesome/awesome_helpers.rb +17 -10
  105. data/lib/decidim/decidim_awesome/checksums.yml +17 -4
  106. data/lib/decidim/decidim_awesome/config.rb +53 -6
  107. data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +27 -21
  108. data/lib/decidim/decidim_awesome/custom_fields.rb +94 -0
  109. data/lib/decidim/decidim_awesome/engine.rb +62 -6
  110. data/lib/decidim/decidim_awesome/test/shared_examples/box_label_editor.rb +116 -0
  111. data/lib/decidim/decidim_awesome/test/shared_examples/current_config_examples.rb +143 -0
  112. data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +4 -0
  113. data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +428 -0
  114. data/lib/decidim/decidim_awesome/version.rb +1 -1
  115. data/lib/decidim/decidim_awesome.rb +41 -8
  116. data/vendor/assets/javascripts/delta.min.js +405 -0
  117. data/vendor/assets/javascripts/delta.min.js.map +1 -0
  118. data/vendor/assets/javascripts/europa.min.js +4 -0
  119. data/vendor/assets/javascripts/form-builder.min.js +19 -0
  120. data/vendor/assets/javascripts/form-render.min.js +19 -0
  121. data/vendor/assets/javascripts/inscrybmde.min.js +1 -1
  122. data/vendor/assets/javascripts/jquery-ui.min.js +13 -0
  123. data/vendor/assets/javascripts/select2.js +6147 -0
  124. data/vendor/assets/langs/en-US.lang +110 -0
  125. data/vendor/assets/stylesheets/inscrybmde.min.scss +14 -0
  126. data/vendor/assets/stylesheets/jquery-ui.min.css +7 -0
  127. data/vendor/assets/stylesheets/select2-foundation-theme.css +249 -0
  128. data/vendor/assets/stylesheets/select2.css +515 -0
  129. metadata +68 -27
  130. data/app/assets/images/decidim/decidim_awesome/loading.gif +0 -0
  131. data/app/assets/javascripts/decidim/decidim_awesome/admin.js +0 -3
  132. data/app/assets/javascripts/decidim/decidim_awesome/editors/markdown_view.js.es6 +0 -12
  133. data/app/assets/stylesheets/decidim/decidim_awesome/application.scss +0 -8
  134. data/app/assets/stylesheets/decidim/decidim_awesome/editors/markdown_view.scss +0 -27
  135. data/app/awesome_overrides/presenters/decidim/proposals/proposal_presenter_override.rb +0 -58
  136. data/lib/decidim/decidim_awesome/content_renderers/markdown_renderer.rb +0 -18
  137. data/lib/decidim/decidim_awesome/content_renderers.rb +0 -9
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "same environment" do
4
+ it "do not modify the environment" do
5
+ code, new_env = middleware.call(env)
6
+
7
+ expect(new_env).to eq(env)
8
+ expect(code).to eq(200)
9
+ end
10
+
11
+ it "has current organization in env" do
12
+ _code, new_env = middleware.call(env)
13
+
14
+ expect(new_env["decidim.current_organization"]).to eq(env["decidim.current_organization"])
15
+ expect(new_env["decidim_awesome.current_config"]).to be_a Decidim::DecidimAwesome::Config
16
+ end
17
+ end
18
+
19
+ shared_examples "untampered user model" do
20
+ it "user model is reset" do
21
+ # ensure model is always reset after calling the middleware
22
+ Decidim::User.awesome_admins_for_current_scope = [123]
23
+ middleware.call(env)
24
+
25
+ expect(Decidim::User.awesome_admins_for_current_scope).not_to be_present
26
+ end
27
+ end
28
+
29
+ shared_examples "tampered users model" do
30
+ it "user model is tampered" do
31
+ # ensure model is always reset after calling the middleware
32
+ Decidim::User.awesome_admins_for_current_scope = [123]
33
+ middleware.call(env)
34
+
35
+ expect(Decidim::User.awesome_admins_for_current_scope).to match_array([user.id, admin.id])
36
+ end
37
+ end
38
+
39
+ shared_examples "tampered user model" do
40
+ it "user model is tampered" do
41
+ # ensure model is always reset after calling the middleware
42
+ Decidim::User.awesome_admins_for_current_scope = [123]
43
+ middleware.call(env)
44
+
45
+ expect(Decidim::User.awesome_admins_for_current_scope).to match_array([user.id])
46
+ end
47
+ end
48
+
49
+ shared_examples "tampered admin model" do
50
+ it "user model is tampered" do
51
+ # ensure model is always reset after calling the middleware
52
+ Decidim::User.awesome_admins_for_current_scope = [123]
53
+ middleware.call(env)
54
+
55
+ expect(Decidim::User.awesome_admins_for_current_scope).to match_array([admin.id])
56
+ end
57
+ end
58
+
59
+ shared_examples "generic admin routes" do
60
+ context "when admin index" do
61
+ let(:path) { "admin/" }
62
+
63
+ it_behaves_like "tampered users model"
64
+
65
+ context "when additional slashes" do
66
+ let(:path) { "/admin/" }
67
+
68
+ it_behaves_like "untampered user model"
69
+ end
70
+
71
+ context "when multiple slashes" do
72
+ let(:path) { "//admin/" }
73
+
74
+ it_behaves_like "untampered user model"
75
+ end
76
+
77
+ context "when POST" do
78
+ let(:method) { "POST" }
79
+
80
+ it_behaves_like "untampered user model"
81
+ end
82
+
83
+ context "when PATCH" do
84
+ let(:method) { "PATCH" }
85
+
86
+ it_behaves_like "untampered user model"
87
+ end
88
+ end
89
+
90
+ context "when admin terms" do
91
+ let(:path) { "admin/admin_terms" }
92
+
93
+ it_behaves_like "tampered users model"
94
+
95
+ context "when POST" do
96
+ let(:method) { "POST" }
97
+
98
+ it_behaves_like "tampered users model"
99
+ end
100
+ end
101
+
102
+ context "when admin out of scope" do
103
+ let(:path) { "admin/some_path" }
104
+
105
+ it_behaves_like "untampered user model"
106
+ end
107
+
108
+ context "when admin an assembly" do
109
+ let(:path) { "admin/assemblies/#{assembly.slug}" }
110
+
111
+ it_behaves_like "tampered users model"
112
+
113
+ context "and accessing assemblies index" do
114
+ let(:path) { "admin/assemblies" }
115
+
116
+ it_behaves_like "tampered users model"
117
+
118
+ context "when POST" do
119
+ let(:method) { "POST" }
120
+
121
+ it_behaves_like "untampered user model"
122
+ end
123
+
124
+ context "when PATCH" do
125
+ let(:method) { "PATCH" }
126
+
127
+ it_behaves_like "untampered user model"
128
+ end
129
+ end
130
+ end
131
+
132
+ context "and accessing another assemblies index" do
133
+ let(:path) { "admin/assemblies/#{another_assembly.slug}" }
134
+
135
+ it_behaves_like "untampered user model"
136
+ end
137
+
138
+ context "when admin a participatory process" do
139
+ let(:path) { "admin/participatory_processes/some-process" }
140
+
141
+ it_behaves_like "tampered admin model"
142
+ end
143
+ end
@@ -11,10 +11,12 @@ shared_examples "has no drag and drop" do |rte|
11
11
  end
12
12
  else
13
13
  it "has no paste event" do
14
+ sleep 1
14
15
  expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').paste")).to eq("undefined")
15
16
  end
16
17
 
17
18
  it "has no drop event" do
19
+ sleep 1
18
20
  expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').drop")).to eq("undefined")
19
21
  end
20
22
  end
@@ -31,10 +33,12 @@ shared_examples "has drag and drop" do |rte|
31
33
  end
32
34
  else
33
35
  it "has paste event" do
36
+ sleep 1
34
37
  expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').paste")).to eq("object")
35
38
  end
36
39
 
37
40
  it "has drop event" do
41
+ sleep 1
38
42
  expect(page.execute_script("return typeof $._data($('#{editor_selector}')[0], 'events').drop")).to eq("object")
39
43
  end
40
44
  end
@@ -0,0 +1,428 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "redirects to index" do |_link|
4
+ it "display index page" do
5
+ expect(page).to have_content("You are not authorized to perform this action")
6
+ expect(page).to have_content("Welcome to the Decidim Admin Panel.")
7
+ expect(page).to have_current_path(decidim_admin.root_path, ignore_query: true)
8
+ end
9
+ end
10
+
11
+ shared_examples "forbids awesome access" do
12
+ it "does not have awesome link" do
13
+ visit decidim_admin.root_path
14
+ expect(page).not_to have_content("Decidim awesome")
15
+ end
16
+
17
+ describe "forbids module access" do
18
+ before do
19
+ visit decidim_admin_decidim_awesome.config_path(:editors)
20
+ end
21
+
22
+ it_behaves_like "redirects to index"
23
+ end
24
+ end
25
+
26
+ shared_examples "allows awesome access" do
27
+ it "does not have awesome link" do
28
+ visit decidim_admin.root_path
29
+ expect(page).to have_link("Decidim awesome")
30
+ end
31
+
32
+ it "allows module access" do
33
+ visit decidim_admin_decidim_awesome.config_path(:editors)
34
+ expect(page).to have_content("Tweaks for editors")
35
+ end
36
+ end
37
+
38
+ shared_examples "forbids external accesses" do
39
+ describe "forbids newsletter access" do
40
+ before do
41
+ visit decidim_admin.newsletters_path
42
+ end
43
+
44
+ it_behaves_like "redirects to index"
45
+ end
46
+
47
+ describe "forbids participants access" do
48
+ before do
49
+ visit decidim_admin.users_path
50
+ end
51
+
52
+ it_behaves_like "redirects to index"
53
+ end
54
+
55
+ describe "forbids pages access" do
56
+ before do
57
+ visit decidim_admin.static_pages_path
58
+ end
59
+
60
+ it_behaves_like "redirects to index"
61
+ end
62
+
63
+ unless legacy_version?
64
+ describe "forbids moderation access" do
65
+ before do
66
+ visit decidim_admin.moderations_path
67
+ end
68
+
69
+ it_behaves_like "redirects to index"
70
+ end
71
+ end
72
+
73
+ describe "forbids organization access" do
74
+ before do
75
+ visit decidim_admin.edit_organization_path
76
+ end
77
+
78
+ it_behaves_like "redirects to index"
79
+ end
80
+ end
81
+
82
+ shared_examples "allows external accesses" do
83
+ it "shows newsletter access" do
84
+ visit decidim_admin.newsletters_path
85
+ expect(page).to have_content("New newsletter")
86
+ end
87
+
88
+ it "shows participants access" do
89
+ visit decidim_admin.users_path
90
+ if legacy_version?
91
+ expect(page).to have_content("New Participant")
92
+ else
93
+ expect(page).to have_content("New user")
94
+ end
95
+ end
96
+
97
+ it "shows pages access" do
98
+ visit decidim_admin.static_pages_path
99
+ expect(page).to have_content("Pages without topic")
100
+ end
101
+
102
+ unless legacy_version?
103
+ it "shows moderation access" do
104
+ visit decidim_admin.moderations_path
105
+ expect(page).to have_content("Reported content URL")
106
+ end
107
+ end
108
+
109
+ it "shows organization access" do
110
+ visit decidim_admin.edit_organization_path
111
+ expect(page).to have_content("Edit organization")
112
+ end
113
+ end
114
+
115
+ shared_examples "allows all admin routes" do
116
+ before do
117
+ visit decidim_admin.root_path
118
+ end
119
+
120
+ it "allows the admin root page" do
121
+ expect(page).to have_content("Welcome to the Decidim Admin Panel.")
122
+ end
123
+
124
+ it "allows the assemblies page" do
125
+ click_link "Assemblies"
126
+
127
+ expect(page).to have_content("New assembly")
128
+ end
129
+
130
+ it "allows the processes page" do
131
+ click_link "Processes"
132
+
133
+ expect(page).to have_content("New process")
134
+ end
135
+ end
136
+
137
+ shared_examples "allows scoped admin routes" do
138
+ before do
139
+ visit decidim_admin.root_path
140
+ end
141
+
142
+ it "allows the admin root page" do
143
+ expect(page).to have_content("Welcome to the Decidim Admin Panel.")
144
+ end
145
+
146
+ it "allows the assemblies page" do
147
+ click_link "Assemblies"
148
+
149
+ expect(page).to have_content("New assembly")
150
+ end
151
+
152
+ describe "forbids processes" do
153
+ before do
154
+ click_link "Processes"
155
+ end
156
+
157
+ it_behaves_like "redirects to index"
158
+
159
+ it "is not a process page" do
160
+ expect(page).not_to have_content("New process")
161
+ end
162
+ end
163
+ end
164
+
165
+ shared_examples "has admin link" do
166
+ it "has menu link" do
167
+ within ".topbar__dropmenu.topbar__user__logged" do
168
+ expect(page).to have_selector("#user-menu li", text: "Admin dashboard", visible: :hidden)
169
+ end
170
+ end
171
+ end
172
+
173
+ shared_examples "has no admin link" do
174
+ it "has menu link" do
175
+ within ".topbar__dropmenu.topbar__user__logged" do
176
+ expect(page).not_to have_selector("#user-menu li", text: "Admin dashboard", visible: :hidden)
177
+ end
178
+ end
179
+ end
180
+
181
+ shared_examples "shows partial admin links in the frontend" do
182
+ describe "shows the link in the homepage" do
183
+ before do
184
+ visit decidim.root_path
185
+ end
186
+
187
+ it_behaves_like "has admin link"
188
+ end
189
+
190
+ describe "shows the link in assemblies" do
191
+ before do
192
+ visit decidim_assemblies.assemblies_path
193
+ end
194
+
195
+ it_behaves_like "has admin link"
196
+ it "has a Edit button" do
197
+ expect(page).to have_link(href: "/admin/assemblies")
198
+ end
199
+ end
200
+
201
+ describe "do not show the link in processes" do
202
+ before do
203
+ visit decidim_participatory_processes.participatory_processes_path
204
+ end
205
+
206
+ it_behaves_like "has no admin link"
207
+ it "has no Edit button" do
208
+ expect(page).not_to have_link(href: "/admin/processes")
209
+ end
210
+ end
211
+ end
212
+
213
+ shared_examples "can edit assembly" do
214
+ it "can save" do
215
+ visit decidim_admin_assemblies.edit_assembly_path(assembly.slug)
216
+ expect(page).to have_content("General Information")
217
+ fill_in_i18n(
218
+ :assembly_title,
219
+ "#assembly-title-tabs",
220
+ en: "Edited assembly",
221
+ ca: "Assamblea editada",
222
+ es: "Asamblea editada"
223
+ )
224
+ find("*[type=submit]").click
225
+ expect(page).to have_admin_callout("successfully")
226
+ end
227
+ end
228
+
229
+ shared_examples "edits all assemblies" do
230
+ before do
231
+ visit decidim_admin.root_path
232
+ end
233
+
234
+ it_behaves_like "can edit assembly"
235
+
236
+ it "can edit another assembly" do
237
+ visit decidim_admin_assemblies.edit_assembly_path(another_assembly.slug)
238
+ expect(page).to have_content("General Information")
239
+ end
240
+ end
241
+
242
+ shared_examples "edits allowed assemblies" do
243
+ before do
244
+ visit decidim_admin.root_path
245
+ end
246
+
247
+ it_behaves_like "can edit assembly"
248
+
249
+ describe "forbids unallowed assembly" do
250
+ before do
251
+ visit decidim_admin_assemblies.edit_assembly_path(another_assembly.slug)
252
+ end
253
+
254
+ it_behaves_like "redirects to index"
255
+ end
256
+
257
+ describe "create new assemblies" do
258
+ before do
259
+ visit decidim_admin_assemblies.new_assembly_path
260
+ end
261
+
262
+ it_behaves_like "redirects to index"
263
+ end
264
+ end
265
+
266
+ shared_examples "can manage component" do
267
+ it "can update proposal" do
268
+ visit manage_component_path(component)
269
+ expect(page).to have_content("Proposals")
270
+ expect(page).to have_content("Title")
271
+ expect(page).to have_content(proposal.title["en"])
272
+
273
+ click_link "Edit proposal"
274
+ expect(page).to have_content("Update proposal")
275
+ fill_in_i18n(
276
+ :proposal_title,
277
+ "#proposal-title-tabs",
278
+ en: "Edited proposal",
279
+ ca: "Proposta editada",
280
+ es: "Propuesta editada"
281
+ )
282
+ find("*[type=submit]").click
283
+ expect(page).to have_admin_callout("successfully")
284
+ end
285
+
286
+ it "can create a proposal" do
287
+ visit manage_component_path(component)
288
+
289
+ click_link "New proposal"
290
+ expect(page).to have_content("Create proposal")
291
+ fill_in_i18n(
292
+ :proposal_title,
293
+ "#proposal-title-tabs",
294
+ en: "Create proposal",
295
+ ca: "Proposta creada",
296
+ es: "Propuesta creada"
297
+ )
298
+ fill_in_i18n_editor(
299
+ :proposal_body,
300
+ "#proposal-body-tabs",
301
+ en: "Create body",
302
+ ca: "Body creat",
303
+ es: "Body creat"
304
+ )
305
+ find("*[type=submit]").click
306
+ expect(page).to have_admin_callout("successfully")
307
+ end
308
+ end
309
+
310
+ shared_examples "edits allowed components" do
311
+ before do
312
+ visit decidim_admin.root_path
313
+ end
314
+
315
+ it_behaves_like "can manage component"
316
+ it "can edit component" do
317
+ visit Decidim::EngineRouter.admin_proxy(component.participatory_space).edit_component_path(component.id)
318
+ expect(page).to have_content("Edit component")
319
+ end
320
+
321
+ it "set permissions in component" do
322
+ visit Decidim::EngineRouter.admin_proxy(component.participatory_space).edit_component_permissions_path(component.id)
323
+ expect(page).to have_content("Edit permissions")
324
+ end
325
+
326
+ describe "forbids unallowed component" do
327
+ before do
328
+ visit manage_component_path(another_component)
329
+ end
330
+
331
+ it_behaves_like "redirects to index"
332
+ end
333
+ end
334
+
335
+ shared_examples "shows component partial admin links in the frontend" do
336
+ describe "shows the link in the homepage" do
337
+ before do
338
+ visit decidim.root_path
339
+ end
340
+
341
+ it_behaves_like "has admin link"
342
+ end
343
+
344
+ describe "shows the link in the component" do
345
+ before do
346
+ visit main_component_path(component)
347
+ end
348
+
349
+ it_behaves_like "has admin link"
350
+ it "has a Edit button" do
351
+ expect(page).to have_link(href: manage_component_path(component))
352
+ end
353
+ end
354
+
355
+ describe "do not show the link in another compoenent" do
356
+ before do
357
+ visit main_component_path(another_component)
358
+ end
359
+
360
+ it_behaves_like "has no admin link"
361
+ it "has no Edit button" do
362
+ expect(page).not_to have_link(href: manage_component_path(another_component))
363
+ end
364
+ end
365
+ end
366
+
367
+ shared_examples "allows access to group processes" do
368
+ before do
369
+ visit decidim_admin_participatory_processes.participatory_processes_path
370
+ end
371
+
372
+ it "shows the list of processes" do
373
+ expect(page).to have_content("Participatory processes")
374
+ expect(page).to have_content(participatory_process.title["en"])
375
+ end
376
+
377
+ describe "forbids editing processes" do
378
+ before do
379
+ visit decidim_admin_participatory_processes.edit_participatory_process_path(participatory_process.slug)
380
+ end
381
+
382
+ it_behaves_like "redirects to index"
383
+ end
384
+
385
+ describe "allows listing group process" do
386
+ before do
387
+ visit decidim_admin_participatory_processes.participatory_process_groups_path
388
+ end
389
+
390
+ it "shows the list of groups" do
391
+ expect(page).to have_content("Participatory process groups")
392
+ expect(page).to have_content(process_group.title["en"])
393
+ end
394
+ end
395
+ end
396
+
397
+ shared_examples "allows edit any group process" do
398
+ before do
399
+ visit decidim_admin_participatory_processes.edit_participatory_process_group_path(another_process_group.id)
400
+ end
401
+
402
+ it "allows to edit group processes" do
403
+ expect(page).to have_content("Edit process group")
404
+ fill_in_i18n(
405
+ :participatory_process_group_title,
406
+ "#participatory_process_group-title-tabs",
407
+ en: "Edited process group",
408
+ ca: "Proces grup editat",
409
+ es: "Grupo de procesos editado"
410
+ )
411
+ find("*[type=submit]").click
412
+ expect(page).to have_admin_callout("successfully")
413
+ end
414
+ end
415
+
416
+ shared_examples "allows edit only allowed group process" do
417
+ before do
418
+ visit decidim_admin_participatory_processes.participatory_processes_path
419
+ end
420
+
421
+ describe "forbids editing group" do
422
+ before do
423
+ visit decidim_admin_participatory_processes.edit_participatory_process_group_path(another_process_group.id)
424
+ end
425
+
426
+ it_behaves_like "redirects to index"
427
+ end
428
+ end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  # This holds the decidim-decidim_awesome version.
5
5
  module DecidimAwesome
6
- VERSION = "0.7.0"
6
+ VERSION = "0.7.2"
7
7
  COMPAT_DECIDIM_VERSION = [">= 0.23.0", "< 0.25"].freeze
8
8
  end
9
9
  end
@@ -3,7 +3,6 @@
3
3
  require "decidim/decidim_awesome/admin"
4
4
  require "decidim/decidim_awesome/engine"
5
5
  require "decidim/decidim_awesome/admin_engine"
6
- require "decidim/decidim_awesome/content_renderers"
7
6
  require "decidim/decidim_awesome/context_analyzers"
8
7
  require "decidim/decidim_awesome/map_component/engine"
9
8
  require "decidim/decidim_awesome/map_component/component"
@@ -16,9 +15,9 @@ module Decidim
16
15
 
17
16
  autoload :Config, "decidim/decidim_awesome/config"
18
17
  autoload :SystemChecker, "decidim/decidim_awesome/system_checker"
19
- autoload :ContentRenderes, "decidim/decidim_awesome/content_renderers"
20
18
  autoload :ContextAnalyzers, "decidim/decidim_awesome/context_analyzers"
21
19
  autoload :MenuHacker, "decidim/decidim_awesome/menu_hacker"
20
+ autoload :CustomFields, "decidim/decidim_awesome/custom_fields"
22
21
 
23
22
  # Boolean configuration options
24
23
  #
@@ -72,6 +71,19 @@ module Decidim
72
71
  {}
73
72
  end
74
73
 
74
+ # custom fields for proposals using JSON specification:
75
+ # https://github.com/jsonform/jsonform/wiki
76
+ # Valid values uses the same structure as :scoped_styles
77
+ # :disabled => false and non available, hidden from admins
78
+ # Hash => hash of different JSON texts, each key will be used for the contraints
79
+ # Admins can create this hash dynamically but some pre-defined css boxes can be created here as:
80
+ # {
81
+ # some_identifier: "{ ... some definition... }"
82
+ # }
83
+ config_accessor :proposal_custom_fields do
84
+ {}
85
+ end
86
+
75
87
  # allows to keep modifications for the main menu
76
88
  # can return :disabled to completly remove this feature
77
89
  # otherwise it should be an array (some overrides can be specified by default):
@@ -86,6 +98,18 @@ module Decidim
86
98
  []
87
99
  end
88
100
 
101
+ # Allows admins to assignate "fake" admins scoped to some admin zones using the
102
+ # same scope editor as :scoped_styles, valid values uses the same convention:
103
+ # :disabled => false and non available, hidden from admins
104
+ # Hash => hash of different admin ids, each key will be used for the contraints
105
+ # Admins create this hash dynamically but some pre-defined admin boxes can be created here as:
106
+ # {
107
+ # some_identifier: [1234, 5678, 90123]
108
+ # }
109
+ config_accessor :scoped_admins do
110
+ {}
111
+ end
112
+
89
113
  # these settings do not follow the :disabled convention but
90
114
  # depends on the previous intergram configurations
91
115
  config_accessor :intergram_url do
@@ -119,6 +143,21 @@ module Decidim
119
143
  auto_no_response: nil
120
144
  }
121
145
  end
146
+
147
+ # additional correspondences between participatory spaces manifests and routes
148
+ # ie: /admin/assemblies and /admin/assemblies_types are both treated as a "assembly" participatory space in terms of permission scoping
149
+ # This can be tuned in a initialized if some other hacks over routes are applied
150
+ # if a registered participatory space is not listed here then the name manifest will be used as a default route /manifest_name /admin/manifes_name
151
+ config_accessor :participatory_spaces_routes_context do
152
+ {
153
+ # route in admin is diferent than in the frontend: /processes, /admin/participatory_processes
154
+ participatory_processes: [:participatory_processes, :processes],
155
+ # both /admin/assemblies and /admin/assemblies_types are considered assemblies
156
+ assemblies: [:assemblies, :assemblies_types],
157
+ # route in admin is diferent than in the frontend: /process_groups, /admin/participatory_process_groups
158
+ process_groups: [:processes_groups, :participatory_process_groups]
159
+ }
160
+ end
122
161
  end
123
162
  end
124
163
 
@@ -129,9 +168,3 @@ Decidim.register_global_engine(
129
168
  ::Decidim::DecidimAwesome::Engine,
130
169
  at: "/decidim_awesome"
131
170
  )
132
-
133
- # Decidim.register_global_engine(
134
- # :decidim_admin_action_awesome,
135
- # ::Decidim::DecidimAwesome::AdminEngine,
136
- # at: "/admin/action_awesome"
137
- # )