decidim-admin 0.29.2 → 0.30.0.rc2

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 (236) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/admin/multi_select_picker/show.erb +10 -0
  3. data/app/cells/decidim/admin/multi_select_picker_cell.rb +38 -0
  4. data/app/commands/decidim/admin/bulk_action.rb +92 -0
  5. data/app/commands/decidim/admin/bulk_block_users.rb +75 -0
  6. data/app/commands/decidim/admin/bulk_unblock_users.rb +66 -0
  7. data/app/commands/decidim/admin/bulk_unreport_users.rb +69 -0
  8. data/app/commands/decidim/admin/content_blocks/update_content_block.rb +1 -1
  9. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +3 -1
  10. data/app/commands/decidim/admin/create_share_token.rb +39 -0
  11. data/app/commands/decidim/admin/create_taxonomy.rb +23 -0
  12. data/app/commands/decidim/admin/create_taxonomy_filter.rb +24 -0
  13. data/app/commands/decidim/admin/destroy_share_token.rb +22 -0
  14. data/app/commands/decidim/admin/destroy_taxonomy.rb +18 -0
  15. data/app/commands/decidim/admin/destroy_taxonomy_filter.rb +20 -0
  16. data/app/commands/decidim/admin/hide_menu_component.rb +37 -0
  17. data/app/commands/decidim/admin/hide_resource.rb +4 -3
  18. data/app/commands/decidim/admin/publish_all_participatory_space_private_users.rb +50 -0
  19. data/app/commands/decidim/admin/publish_component.rb +3 -0
  20. data/app/commands/decidim/admin/reorder_components.rb +47 -0
  21. data/app/commands/decidim/admin/reorder_taxonomies.rb +76 -0
  22. data/app/commands/decidim/admin/unhide_resource.rb +11 -3
  23. data/app/commands/decidim/admin/unpublish_all_participatory_space_private_users.rb +50 -0
  24. data/app/commands/decidim/admin/unreport_resource.rb +11 -3
  25. data/app/commands/decidim/admin/update_component_permissions.rb +53 -13
  26. data/app/commands/decidim/admin/update_participatory_space_private_user.rb +11 -0
  27. data/app/commands/decidim/admin/update_share_token.rb +24 -0
  28. data/app/commands/decidim/admin/update_taxonomy.rb +20 -0
  29. data/app/commands/decidim/admin/update_taxonomy_filter.rb +28 -0
  30. data/app/controllers/concerns/decidim/admin/component_taxonomies_helper.rb +19 -0
  31. data/app/controllers/concerns/decidim/admin/filterable.rb +15 -18
  32. data/app/controllers/concerns/decidim/admin/has_trashable_resources.rb +170 -0
  33. data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +2 -29
  34. data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +12 -2
  35. data/app/controllers/concerns/decidim/admin/taxonomies/filterable.rb +27 -0
  36. data/app/controllers/decidim/admin/application_controller.rb +1 -2
  37. data/app/controllers/decidim/admin/areas_controller.rb +1 -0
  38. data/app/controllers/decidim/admin/block_user_controller.rb +42 -0
  39. data/app/controllers/decidim/admin/component_permissions_controller.rb +2 -4
  40. data/app/controllers/decidim/admin/components_controller.rb +50 -9
  41. data/app/controllers/decidim/admin/concerns/has_private_users.rb +59 -2
  42. data/app/controllers/decidim/admin/global_moderations_controller.rb +4 -0
  43. data/app/controllers/decidim/admin/moderated_users_controller.rb +26 -0
  44. data/app/controllers/decidim/admin/moderations_controller.rb +18 -0
  45. data/app/controllers/decidim/admin/newsletters_controller.rb +50 -7
  46. data/app/controllers/decidim/admin/resource_permissions_controller.rb +1 -1
  47. data/app/controllers/decidim/admin/scopes_controller.rb +1 -0
  48. data/app/controllers/decidim/admin/share_tokens_controller.rb +109 -7
  49. data/app/controllers/decidim/admin/taxonomies_controller.rb +129 -0
  50. data/app/controllers/decidim/admin/taxonomy_filters_controller.rb +112 -0
  51. data/app/controllers/decidim/admin/taxonomy_filters_selector_controller.rb +81 -0
  52. data/app/controllers/decidim/admin/taxonomy_items_controller.rb +91 -0
  53. data/app/forms/concerns/decidim/has_taxonomy_form_attributes.rb +57 -0
  54. data/app/forms/decidim/admin/block_users_form.rb +21 -0
  55. data/app/forms/decidim/admin/import_example_form.rb +1 -1
  56. data/app/forms/decidim/admin/newsletter_form.rb +1 -1
  57. data/app/forms/decidim/admin/participatory_space_private_user_form.rb +5 -0
  58. data/app/forms/decidim/admin/selective_newsletter_form.rb +46 -11
  59. data/app/forms/decidim/admin/share_token_form.rb +55 -0
  60. data/app/forms/decidim/admin/taxonomy_filter_form.rb +85 -0
  61. data/app/forms/decidim/admin/taxonomy_form.rb +20 -0
  62. data/app/forms/decidim/admin/taxonomy_item_form.rb +54 -0
  63. data/app/helpers/decidim/admin/application_helper.rb +0 -1
  64. data/app/helpers/decidim/admin/bulk_actions_helper.rb +0 -31
  65. data/app/helpers/decidim/admin/moderations/reports_helper.rb +1 -1
  66. data/app/helpers/decidim/admin/moderations_helper.rb +1 -1
  67. data/app/helpers/decidim/admin/newsletters_helper.rb +57 -27
  68. data/app/helpers/decidim/admin/scopes_helper.rb +0 -6
  69. data/app/helpers/decidim/admin/search_form_helper.rb +1 -1
  70. data/app/helpers/decidim/admin/settings_helper.rb +85 -11
  71. data/app/jobs/decidim/admin/newsletter_job.rb +3 -1
  72. data/app/packs/entrypoints/decidim_admin.js +4 -0
  73. data/app/packs/src/decidim/admin/application.js +2 -0
  74. data/app/packs/src/decidim/admin/draggable-table.js +33 -0
  75. data/app/packs/src/decidim/admin/form.js +0 -1
  76. data/app/packs/src/decidim/admin/global_moderations.js +186 -0
  77. data/app/packs/src/decidim/admin/managed_moderated_users.js +186 -0
  78. data/app/packs/src/decidim/admin/newsletters.js +164 -82
  79. data/app/packs/src/decidim/admin/proposal_infinite_edit.js +3 -6
  80. data/app/packs/src/decidim/admin/sortable.js +28 -16
  81. data/app/packs/src/decidim/admin/taxonomy_filters.js +93 -0
  82. data/app/packs/stylesheets/decidim/admin/_component-show.scss +66 -5
  83. data/app/packs/stylesheets/decidim/admin/_legacy_foundation.scss +13 -0
  84. data/app/packs/stylesheets/decidim/admin/_select_picker.scss +20 -0
  85. data/app/packs/stylesheets/decidim/admin/_table-list.scss +22 -0
  86. data/app/packs/stylesheets/decidim/admin/_taxonomies.scss +74 -0
  87. data/app/packs/stylesheets/decidim/admin/application.scss +3 -0
  88. data/app/permissions/decidim/admin/permissions.rb +32 -1
  89. data/app/queries/decidim/admin/newsletter_recipients.rb +50 -14
  90. data/app/views/decidim/admin/areas/index.html.erb +3 -0
  91. data/app/views/decidim/admin/block_user/bulk_new.html.erb +45 -0
  92. data/app/views/decidim/admin/components/_actions.html.erb +50 -33
  93. data/app/views/decidim/admin/components/{_component.html.erb → _component_row.html.erb} +10 -5
  94. data/app/views/decidim/admin/components/_components_table.html.erb +18 -0
  95. data/app/views/decidim/admin/components/_form.html.erb +0 -12
  96. data/app/views/decidim/admin/components/_taxonomy_filters_drawer.html.erb +2 -0
  97. data/app/views/decidim/admin/components/_visibility_label.html.erb +9 -0
  98. data/app/views/decidim/admin/components/index.html.erb +12 -14
  99. data/app/views/decidim/admin/components/manage_trash.html.erb +11 -0
  100. data/app/views/decidim/admin/moderated_users/_bulk-actions.html.erb +6 -0
  101. data/app/views/decidim/admin/moderated_users/bulk_actions/_block.html.erb +20 -0
  102. data/app/views/decidim/admin/moderated_users/bulk_actions/_dropdown.html.erb +40 -0
  103. data/app/views/decidim/admin/moderated_users/bulk_actions/_unblock.html.erb +20 -0
  104. data/app/views/decidim/admin/moderated_users/bulk_actions/_unreport.html.erb +20 -0
  105. data/app/views/decidim/admin/moderated_users/index.html.erb +14 -6
  106. data/app/views/decidim/admin/moderations/_bulk-actions.html.erb +7 -0
  107. data/app/views/decidim/admin/moderations/_moderation-tr.html.erb +50 -0
  108. data/app/views/decidim/admin/moderations/_moderations-thead.html.erb +18 -0
  109. data/app/views/decidim/admin/moderations/bulk_actions/_dropdown.html.erb +43 -0
  110. data/app/views/decidim/admin/moderations/bulk_actions/_hide.html.erb +20 -0
  111. data/app/views/decidim/admin/moderations/bulk_actions/_unhide.html.erb +20 -0
  112. data/app/views/decidim/admin/moderations/bulk_actions/_unreport.html.erb +20 -0
  113. data/app/views/decidim/admin/moderations/index.html.erb +13 -81
  114. data/app/views/decidim/admin/newsletters/confirm_recipients.html.erb +64 -0
  115. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +44 -20
  116. data/app/views/decidim/admin/participatory_space_private_users/_form.html.erb +6 -0
  117. data/app/views/decidim/admin/participatory_space_private_users/edit.html.erb +19 -0
  118. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +15 -1
  119. data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +5 -0
  120. data/app/views/decidim/admin/resource_permissions/edit.html.erb +2 -2
  121. data/app/views/decidim/admin/scope_types/index.html.erb +3 -0
  122. data/app/views/decidim/admin/scopes/index.html.erb +3 -0
  123. data/app/views/decidim/admin/share_tokens/_form.html.erb +52 -0
  124. data/app/views/decidim/admin/share_tokens/edit.html.erb +33 -0
  125. data/app/views/decidim/admin/share_tokens/index.html.erb +47 -0
  126. data/app/views/decidim/admin/share_tokens/new.html.erb +69 -0
  127. data/app/views/decidim/admin/taxonomies/_filters.html.erb +19 -0
  128. data/app/views/decidim/admin/taxonomies/_form.html.erb +5 -0
  129. data/app/views/decidim/admin/taxonomies/_row.html.erb +40 -0
  130. data/app/views/decidim/admin/taxonomies/_row_children.html.erb +8 -0
  131. data/app/views/decidim/admin/taxonomies/_table.html.erb +86 -0
  132. data/app/views/decidim/admin/taxonomies/_taxonomy_actions.html.erb +15 -0
  133. data/app/views/decidim/admin/taxonomies/edit.html.erb +87 -0
  134. data/app/views/decidim/admin/taxonomies/index.html.erb +28 -0
  135. data/app/views/decidim/admin/taxonomies/new.html.erb +16 -0
  136. data/app/views/decidim/admin/taxonomy_filters/_check_boxes.html.erb +10 -0
  137. data/app/views/decidim/admin/taxonomy_filters/_form.html.erb +96 -0
  138. data/app/views/decidim/admin/taxonomy_filters/_table.html.erb +33 -0
  139. data/app/views/decidim/admin/taxonomy_filters/edit.html.erb +22 -0
  140. data/app/views/decidim/admin/taxonomy_filters/index.html.erb +26 -0
  141. data/app/views/decidim/admin/taxonomy_filters/new.html.erb +32 -0
  142. data/app/views/decidim/admin/taxonomy_filters_selector/_check_boxes.html.erb +7 -0
  143. data/app/views/decidim/admin/taxonomy_filters_selector/_component_table.html.erb +25 -0
  144. data/app/views/decidim/admin/taxonomy_filters_selector/_taxonomies_select.html.erb +16 -0
  145. data/app/views/decidim/admin/taxonomy_filters_selector/index.html.erb +1 -0
  146. data/app/views/decidim/admin/taxonomy_filters_selector/new.html.erb +27 -0
  147. data/app/views/decidim/admin/taxonomy_filters_selector/show.html.erb +18 -0
  148. data/app/views/decidim/admin/taxonomy_items/_form.html.erb +8 -0
  149. data/app/views/decidim/admin/taxonomy_items/edit.html.erb +12 -0
  150. data/app/views/decidim/admin/taxonomy_items/new.html.erb +12 -0
  151. data/app/views/layouts/decidim/admin/taxonomy_filters.html.erb +17 -0
  152. data/app/views/layouts/decidim/admin/taxonomy_filters_selector.html.erb +10 -0
  153. data/config/locales/ar.yml +45 -37
  154. data/config/locales/bg.yml +48 -51
  155. data/config/locales/bs-BA.yml +1 -27
  156. data/config/locales/ca.yml +301 -50
  157. data/config/locales/cs.yml +299 -46
  158. data/config/locales/de.yml +301 -50
  159. data/config/locales/el.yml +1 -50
  160. data/config/locales/en.yml +301 -50
  161. data/config/locales/es-MX.yml +298 -47
  162. data/config/locales/es-PY.yml +298 -47
  163. data/config/locales/es.yml +298 -47
  164. data/config/locales/eu.yml +302 -51
  165. data/config/locales/fi-plain.yml +298 -47
  166. data/config/locales/fi.yml +298 -47
  167. data/config/locales/fr-CA.yml +184 -47
  168. data/config/locales/fr.yml +184 -47
  169. data/config/locales/ga-IE.yml +0 -23
  170. data/config/locales/gl.yml +1 -46
  171. data/config/locales/hu.yml +1 -51
  172. data/config/locales/id-ID.yml +0 -24
  173. data/config/locales/is-IS.yml +0 -30
  174. data/config/locales/it.yml +2 -46
  175. data/config/locales/ja.yml +299 -50
  176. data/config/locales/kaa.yml +0 -7
  177. data/config/locales/ko.yml +0 -50
  178. data/config/locales/lb.yml +1 -46
  179. data/config/locales/lt.yml +1 -50
  180. data/config/locales/lv.yml +1 -28
  181. data/config/locales/nl.yml +1 -46
  182. data/config/locales/no.yml +1 -46
  183. data/config/locales/pl.yml +3 -51
  184. data/config/locales/pt-BR.yml +38 -50
  185. data/config/locales/pt.yml +29 -49
  186. data/config/locales/ro-RO.yml +38 -52
  187. data/config/locales/ru.yml +1 -24
  188. data/config/locales/sk.yml +1 -28
  189. data/config/locales/sl.yml +0 -5
  190. data/config/locales/sq-AL.yml +0 -22
  191. data/config/locales/sr-CS.yml +1 -27
  192. data/config/locales/sv.yml +296 -46
  193. data/config/locales/th-TH.yml +0 -10
  194. data/config/locales/tr-TR.yml +1 -44
  195. data/config/locales/uk.yml +0 -23
  196. data/config/locales/zh-CN.yml +0 -38
  197. data/config/locales/zh-TW.yml +1 -50
  198. data/config/routes.rb +13 -12
  199. data/decidim-admin.gemspec +1 -1
  200. data/lib/decidim/admin/engine.rb +2 -1
  201. data/lib/decidim/admin/import/creator.rb +2 -6
  202. data/lib/decidim/admin/import/readers/json.rb +1 -1
  203. data/lib/decidim/admin/menu.rb +9 -1
  204. data/lib/decidim/admin/search_form_builder.rb +1 -1
  205. data/lib/decidim/admin/test/destroy_admin_examples.rb +2 -2
  206. data/lib/decidim/admin/test/filterable_examples.rb +100 -9
  207. data/lib/decidim/admin/test/forms/attachment_collection_form_examples.rb +1 -1
  208. data/lib/decidim/admin/test/forms/attachment_form_examples.rb +1 -1
  209. data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +2 -4
  210. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
  211. data/lib/decidim/admin/test/manage_hide_content_examples.rb +0 -1
  212. data/lib/decidim/admin/test/manage_moderations_examples.rb +3 -3
  213. data/lib/decidim/admin/test/manage_resource_soft_deletion_examples.rb +113 -0
  214. data/lib/decidim/admin/test/manage_taxonomy_filters_examples.rb +127 -0
  215. data/lib/decidim/admin/test/taxonomy_filters_examples.rb +32 -0
  216. data/lib/decidim/admin/test.rb +3 -1
  217. data/lib/decidim/admin/version.rb +1 -1
  218. metadata +103 -29
  219. data/app/commands/decidim/admin/create_category.rb +0 -15
  220. data/app/commands/decidim/admin/destroy_category.rb +0 -15
  221. data/app/commands/decidim/admin/destroy_component.rb +0 -19
  222. data/app/commands/decidim/admin/update_category.rb +0 -11
  223. data/app/controllers/decidim/admin/categories_controller.rb +0 -98
  224. data/app/forms/decidim/admin/category_form.rb +0 -32
  225. data/app/helpers/decidim/admin/resource_scope_helper.rb +0 -52
  226. data/app/packs/src/decidim/admin/scope_picker_enabler.component.js +0 -12
  227. data/app/views/decidim/admin/categories/_form.html.erb +0 -18
  228. data/app/views/decidim/admin/categories/edit.html.erb +0 -19
  229. data/app/views/decidim/admin/categories/index.html.erb +0 -65
  230. data/app/views/decidim/admin/categories/new.html.erb +0 -19
  231. data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +0 -45
  232. data/lib/decidim/admin/test/commands/create_category_examples.rb +0 -74
  233. data/lib/decidim/admin/test/commands/destroy_category_examples.rb +0 -83
  234. data/lib/decidim/admin/test/commands/update_category_examples.rb +0 -76
  235. data/lib/decidim/admin/test/forms/category_form_examples.rb +0 -70
  236. data/lib/decidim/admin/test/manage_categories_examples.rb +0 -128
@@ -17,6 +17,19 @@ shared_context "with filterable context" do
17
17
  end
18
18
  end
19
19
 
20
+ def apply_sub_filter(option1, option2, filter)
21
+ within(".filters__section") do
22
+ find_link("Filter").hover
23
+ find_link(option1).hover
24
+ within ".submenu > .is-active > .submenu" do
25
+ find_link(option2).hover
26
+ within ".submenu > .is-active > .submenu" do
27
+ click_on(filter)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
20
33
  def remove_applied_filter(filter)
21
34
  within("[data-applied-filters-tags] .label", text: /#{filter}/i) do
22
35
  click_on("Cancel")
@@ -30,6 +43,20 @@ shared_context "with filterable context" do
30
43
  end
31
44
  end
32
45
 
46
+ def page_has_content(text)
47
+ text = [text] unless text.is_a?(Array)
48
+ text.each do |t|
49
+ expect(page).to have_content(t)
50
+ end
51
+ end
52
+
53
+ def page_has_no_content(text)
54
+ text = [text] unless text.is_a?(Array)
55
+ text.each do |t|
56
+ expect(page).to have_no_content(t)
57
+ end
58
+ end
59
+
33
60
  shared_examples "paginating a collection" do
34
61
  unless block_given?
35
62
  let!(:collection) do
@@ -41,18 +68,42 @@ shared_context "with filterable context" do
41
68
  end
42
69
 
43
70
  shared_examples "searching by text" do
44
- before { search_by_text(ActionView::Base.full_sanitizer.sanitize(text)) }
45
-
46
- it { expect(page).to have_content(ActionView::Base.full_sanitizer.sanitize(text)) }
47
-
48
- after { search_by_text("") }
71
+ it "finds content" do
72
+ txt = text.is_a?(Array) ? text : [text]
73
+ txt.each do |t|
74
+ search_by_text(ActionView::Base.full_sanitizer.sanitize(t))
75
+ page_has_content(ActionView::Base.full_sanitizer.sanitize(t))
76
+ end
77
+ end
49
78
  end
50
79
 
51
80
  shared_examples "a filtered collection" do |options:, filter:|
52
81
  before { apply_filter(options, filter) }
53
82
 
54
- it { expect(page).to have_content(in_filter) }
55
- it { expect(page).to have_no_content(not_in_filter) }
83
+ it { page_has_content(in_filter) }
84
+ it { page_has_no_content(not_in_filter) }
85
+
86
+ it_behaves_like "searching by text" do
87
+ let(:text) { in_filter }
88
+ end
89
+
90
+ context "when removing applied filter" do
91
+ before { remove_applied_filter(filter) }
92
+
93
+ it { page_has_content(in_filter) }
94
+ it { page_has_content(not_in_filter) }
95
+
96
+ it_behaves_like "searching by text" do
97
+ let(:text) { not_in_filter }
98
+ end
99
+ end
100
+ end
101
+
102
+ shared_examples "a sub-filtered collection" do |option1:, option2:, filter:|
103
+ before { apply_sub_filter(option1, option2, filter) }
104
+
105
+ it { page_has_content(in_filter) }
106
+ it { page_has_no_content(not_in_filter) }
56
107
 
57
108
  it_behaves_like "searching by text" do
58
109
  let(:text) { in_filter }
@@ -61,8 +112,8 @@ shared_context "with filterable context" do
61
112
  context "when removing applied filter" do
62
113
  before { remove_applied_filter(filter) }
63
114
 
64
- it { expect(page).to have_content(in_filter) }
65
- it { expect(page).to have_content(not_in_filter) }
115
+ it { page_has_content(in_filter) }
116
+ it { page_has_content(not_in_filter) }
66
117
 
67
118
  it_behaves_like "searching by text" do
68
119
  let(:text) { not_in_filter }
@@ -122,3 +173,43 @@ shared_examples "filtering collection by private/public" do
122
173
 
123
174
  it_behaves_like "paginating a collection"
124
175
  end
176
+
177
+ shared_examples "a collection filtered by taxonomies" do
178
+ let(:root_taxonomy1) { create(:taxonomy, organization:, name: { "en" => "Root1" }) }
179
+ let(:root_taxonomy2) { create(:taxonomy, organization:, name: { "en" => "Root2" }) }
180
+ let!(:taxonomy11) { create(:taxonomy, parent: root_taxonomy1, organization:, name: { "en" => "Taxonomy11" }) }
181
+ let!(:taxonomy12) { create(:taxonomy, parent: root_taxonomy1, organization:, name: { "en" => "Taxonomy12" }) }
182
+ let!(:taxonomy21) { create(:taxonomy, parent: root_taxonomy2, organization:, name: { "en" => "Taxonomy21" }) }
183
+ let!(:taxonomy22) { create(:taxonomy, parent: root_taxonomy2, organization:, name: { "en" => "Taxonomy22" }) }
184
+ let(:taxonomy1_filter1) { create(:taxonomy_filter, root_taxonomy: root_taxonomy1, participatory_space_manifests: [participatory_space.manifest.name]) }
185
+ let(:taxonomy2_filter1) { create(:taxonomy_filter, root_taxonomy: root_taxonomy2, participatory_space_manifests: [participatory_space.manifest.name]) }
186
+ let!(:taxonomy_filter_item11) { create(:taxonomy_filter_item, taxonomy_filter: taxonomy1_filter1, taxonomy_item: taxonomy11) }
187
+ let!(:taxonomy_filter_item12) { create(:taxonomy_filter_item, taxonomy_filter: taxonomy1_filter1, taxonomy_item: taxonomy12) }
188
+ let!(:taxonomy_filter_item21) { create(:taxonomy_filter_item, taxonomy_filter: taxonomy2_filter1, taxonomy_item: taxonomy21) }
189
+ let!(:taxonomy_filter_item22) { create(:taxonomy_filter_item, taxonomy_filter: taxonomy2_filter1, taxonomy_item: taxonomy22) }
190
+
191
+ before do
192
+ component.update!(settings: { taxonomy_filters: [taxonomy1_filter1.id, taxonomy2_filter1.id] })
193
+ visit current_path
194
+ end
195
+
196
+ it_behaves_like "a sub-filtered collection", option1: "Taxonomy", option2: "Root1", filter: "Taxonomy11" do
197
+ let(:in_filter) { resource_with_taxonomy11_title }
198
+ let(:not_in_filter) { [resource_with_taxonomy12_title, resource_with_taxonomy21_title, resource_with_taxonomy22_title] }
199
+ end
200
+
201
+ it_behaves_like "a sub-filtered collection", option1: "Taxonomy", option2: "Root2", filter: "Taxonomy21" do
202
+ let(:in_filter) { resource_with_taxonomy21_title }
203
+ let(:not_in_filter) { [resource_with_taxonomy11_title, resource_with_taxonomy12_title, resource_with_taxonomy22_title] }
204
+ end
205
+
206
+ it_behaves_like "a filtered collection", options: "Taxonomy", filter: "Root1" do
207
+ let(:in_filter) { [resource_with_taxonomy11_title, resource_with_taxonomy12_title] }
208
+ let(:not_in_filter) { [resource_with_taxonomy21_title, resource_with_taxonomy22_title] }
209
+ end
210
+
211
+ it_behaves_like "a filtered collection", options: "Taxonomy", filter: "Root2" do
212
+ let(:in_filter) { [resource_with_taxonomy21_title, resource_with_taxonomy22_title] }
213
+ let(:not_in_filter) { [resource_with_taxonomy11_title, resource_with_taxonomy12_title] }
214
+ end
215
+ end
@@ -41,7 +41,7 @@ module Decidim
41
41
  }
42
42
  }
43
43
  end
44
- let(:organization) { create :organization }
44
+ let(:organization) { create(:organization) }
45
45
 
46
46
  context "with correct data" do
47
47
  it "is valid" do
@@ -32,7 +32,7 @@ module Decidim
32
32
  let(:file) { Decidim::Dev.test_file("city.jpeg", "image/jpeg") }
33
33
  let(:attachment_collection) { create(:attachment_collection, collection_for: attached_to) }
34
34
  let(:attachment_collection_id) { attachment_collection.id }
35
- let(:organization) { create :organization }
35
+ let(:organization) { create(:organization) }
36
36
 
37
37
  let(:attributes) do
38
38
  {
@@ -14,10 +14,9 @@ shared_examples "inviting participatory space admins" do |check_private_space: t
14
14
  expect(page).to have_content("Landing page") if check_landing_page
15
15
  expect(page).to have_content("Phases") if participatory_space.is_a?(Decidim::ParticipatoryProcess)
16
16
  expect(page).to have_content("Components")
17
- expect(page).to have_content("Categories")
18
17
  expect(page).to have_content("Attachments")
19
18
  expect(page).to have_content(space_admins_label)
20
- expect(page).to have_no_content("Private participants") if participatory_space.respond_to?(:private_space)
19
+ expect(page).to have_no_content("Members") if participatory_space.respond_to?(:private_space)
21
20
  expect(page).to have_content("Moderations")
22
21
  end
23
22
  end
@@ -30,10 +29,9 @@ shared_examples "inviting participatory space admins" do |check_private_space: t
30
29
  expect(page).to have_content("Landing page") if check_landing_page
31
30
  expect(page).to have_content("Phases") if participatory_space.is_a?(Decidim::ParticipatoryProcess)
32
31
  expect(page).to have_content("Components")
33
- expect(page).to have_content("Categories")
34
32
  expect(page).to have_content("Attachments")
35
33
  expect(page).to have_content(space_admins_label)
36
- expect(page).to have_content("Private participants") if participatory_space.respond_to?(:private_space)
34
+ expect(page).to have_content("Members") if participatory_space.respond_to?(:private_space)
37
35
  expect(page).to have_content("Moderations")
38
36
  end
39
37
  end
@@ -42,7 +42,7 @@ shared_examples "Managing component permissions" do
42
42
  include(
43
43
  "authorization_handlers" => {
44
44
  "dummy_authorization_handler" => {
45
- "options" => { "allowed_postal_codes" => "08002", "allowed_scope_id" => "" }
45
+ "options" => { "allowed_postal_codes" => "08002" }
46
46
  }
47
47
  }
48
48
  )
@@ -164,7 +164,7 @@ shared_examples "Managing component permissions" do
164
164
  include(
165
165
  "authorization_handlers" => {
166
166
  "dummy_authorization_handler" => {
167
- "options" => { "allowed_postal_codes" => "08002", "allowed_scope_id" => "" }
167
+ "options" => { "allowed_postal_codes" => "08002" }
168
168
  },
169
169
  "another_dummy_authorization_handler" => {
170
170
  "options" => { "passport_number" => "AXXXXXXXX" }
@@ -226,7 +226,7 @@ shared_examples "Managing component permissions" do
226
226
  include(
227
227
  "authorization_handlers" => {
228
228
  "dummy_authorization_handler" => {
229
- "options" => { "allowed_postal_codes" => "08002", "allowed_scope_id" => "" }
229
+ "options" => { "allowed_postal_codes" => "08002" }
230
230
  }
231
231
  }
232
232
  )
@@ -325,7 +325,7 @@ shared_examples "Managing component permissions" do
325
325
  include(
326
326
  "authorization_handlers" => {
327
327
  "dummy_authorization_handler" => {
328
- "options" => { "allowed_postal_codes" => "08002", "allowed_scope_id" => "" }
328
+ "options" => { "allowed_postal_codes" => "08002" }
329
329
  },
330
330
  "another_dummy_authorization_handler" => {
331
331
  "options" => { "passport_number" => "AXXXXXXXX" }
@@ -393,7 +393,7 @@ shared_examples "Managing component permissions" do
393
393
  include(
394
394
  "authorization_handlers" => {
395
395
  "dummy_authorization_handler" => {
396
- "options" => { "allowed_postal_codes" => "08002", "allowed_scope_id" => "" }
396
+ "options" => { "allowed_postal_codes" => "08002" }
397
397
  },
398
398
  "another_dummy_authorization_handler" => {
399
399
  "options" => { "passport_number" => "AXXXXXXXX" }
@@ -57,7 +57,6 @@ shared_examples "hideable resource during block" do
57
57
 
58
58
  visit decidim_admin.root_path
59
59
  expect(page).to have_content("blocked user")
60
- expect(page).to have_content("hid a resource of type")
61
60
  end
62
61
  end
63
62
  end
@@ -27,7 +27,7 @@ shared_examples "sorted moderations" do
27
27
  click_on link_text
28
28
  end
29
29
  all("tbody tr").each_with_index do |row, _index|
30
- expect(row.find("td:first-child")).to have_content(reportables.first.id)
30
+ expect(row.find("td:nth-child(2)")).to have_content(reportables.first.id)
31
31
  end
32
32
  end
33
33
  end
@@ -62,7 +62,7 @@ shared_examples "manage moderations" do
62
62
 
63
63
  context "when listing moderations" do
64
64
  it "only lists moderations for the current organization" do
65
- external_reportable = create :dummy_resource
65
+ external_reportable = create(:dummy_resource)
66
66
  external_moderation = create(:moderation, reportable: external_reportable, report_count: 1, reported_content: external_reportable.reported_searchable_content_text)
67
67
  create(:report, moderation: external_moderation)
68
68
 
@@ -106,7 +106,7 @@ shared_examples "manage moderations" do
106
106
 
107
107
  all("tbody tr").each_with_index do |row, index|
108
108
  reportable_id = moderations_ordered_by_report_count_asc[index].reportable.id
109
- expect(row.find("td:first-child")).to have_content(reportable_id)
109
+ expect(row.find("td:nth-child(2)")).to have_content(reportable_id)
110
110
  end
111
111
  end
112
112
  end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "manage soft deletable component or space" do |resource_name|
4
+ before do
5
+ switch_to_host(organization.host)
6
+ login_as user, scope: :user
7
+ end
8
+
9
+ context "when the participatory space is unpublished" do
10
+ before do
11
+ resource.unpublish!
12
+ resource.reload
13
+ visit admin_resource_path
14
+ end
15
+
16
+ it "moves the #{resource_name} to the trash and displays success message" do
17
+ within "table" do
18
+ expect(page).to have_content(title[:en])
19
+ end
20
+
21
+ accept_confirm { click_on "Soft delete" }
22
+
23
+ expect(page).to have_admin_callout("successfully")
24
+
25
+ within "table" do
26
+ expect(page).to have_no_content(title[:en])
27
+ end
28
+ end
29
+ end
30
+
31
+ context "when the participatory space is published" do
32
+ before do
33
+ visit admin_resource_path
34
+ end
35
+
36
+ it "does not allow to move it to the trash" do
37
+ expect(page).to have_no_content("Soft delete")
38
+ end
39
+ end
40
+
41
+ context "when the participatory space is trashed" do
42
+ before do
43
+ resource.destroy!
44
+ resource.reload
45
+ visit trash_path
46
+ click_on title[:en]
47
+ end
48
+
49
+ it "shows warning message" do
50
+ expect(page).to have_content("You are currently viewing deleted items.")
51
+ end
52
+ end
53
+ end
54
+
55
+ shared_examples "manage soft deletable resource" do |resource_name|
56
+ let(:deleted_at) { nil }
57
+
58
+ before do
59
+ switch_to_host(organization.host)
60
+ login_as user, scope: :user
61
+ visit admin_resource_path
62
+ end
63
+
64
+ it "moves the #{resource_name} to the trash and displays success message" do
65
+ resource_row = "tr[data-id='#{resource.id}']"
66
+
67
+ expect(page).to have_content(title[:en])
68
+
69
+ within(resource_row) do
70
+ accept_confirm { click_on "Soft delete" }
71
+ end
72
+
73
+ expect(page).to have_admin_callout("successfully")
74
+
75
+ within "table" do
76
+ expect(page).to have_no_content(title[:en])
77
+ end
78
+ end
79
+ end
80
+
81
+ shared_examples "manage trashed resource" do |resource_name|
82
+ before do
83
+ switch_to_host(organization.host)
84
+ login_as user, scope: :user
85
+ resource.destroy!
86
+ end
87
+
88
+ context "when the #{resource_name} is trashed" do
89
+ before do
90
+ visit trash_path
91
+ end
92
+
93
+ it "shows page title" do
94
+ expect(page).to have_content("Deleted #{resource_name.pluralize}")
95
+ end
96
+
97
+ it "displays the #{resource_name} in the trash" do
98
+ within "table" do
99
+ expect(page).to have_content(title[:en])
100
+ end
101
+ end
102
+
103
+ it "restores the #{resource_name} from the trash" do
104
+ click_on "Restore"
105
+
106
+ expect(page).to have_admin_callout("successfully")
107
+ visit trash_path
108
+ within "table" do
109
+ expect(page).to have_no_content(title[:en])
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_examples "manage taxonomy filters in settings" do
4
+ let(:participatory_space_manifests) { [participatory_space.manifest.name] }
5
+ let!(:root_taxonomy) { create(:taxonomy, organization:, name: { en: "A root taxonomy" }) }
6
+ let!(:another_taxonomy) { create(:taxonomy, organization:, parent: root_taxonomy) }
7
+ let(:filters_path) { decidim_admin.taxonomies_path }
8
+
9
+ before do
10
+ within "#admin-sidebar-menu-settings" do
11
+ click_on "Components"
12
+ end
13
+ end
14
+
15
+ context "when taxonomy filter exist" do
16
+ let!(:another_taxonomy_filter) do
17
+ create(:taxonomy_filter, internal_name: { en: "Another filter" }, participatory_space_manifests: [participatory_space.manifest.name], root_taxonomy:)
18
+ end
19
+ before do
20
+ click_on "Configure"
21
+ end
22
+
23
+ it "can be added to settings" do
24
+ click_on "Add filter"
25
+ within "#taxonomy_filters-dialog-content" do
26
+ select "A root taxonomy", from: "taxonomy_id"
27
+ select "Internal taxonomy filter name", from: "taxonomy_filter_id"
28
+ within "#save-taxonomy-filter-form" do
29
+ expect(page).to have_content("Public taxonomy filter name")
30
+ expect(page).to have_content(decidim_sanitize_translated(taxonomy.name))
31
+ end
32
+ click_on "Save"
33
+ end
34
+
35
+ expect(page).to have_no_css("#taxonomy_filters-dialog-content")
36
+ within ".js-current-filters" do
37
+ expect(page).to have_css("td", text: "Internal taxonomy filter name")
38
+ expect(page).to have_css("td", text: "Public taxonomy filter name")
39
+ expect(page).to have_link("Edit")
40
+ end
41
+ expect(component.reload.settings.taxonomy_filters).to eq([taxonomy_filter.id.to_s])
42
+
43
+ click_on "Add filter"
44
+ within "#taxonomy_filters-dialog-content" do
45
+ select "A root taxonomy", from: "taxonomy_id"
46
+ select "Another filter", from: "taxonomy_filter_id"
47
+ click_on "Save"
48
+ end
49
+
50
+ expect(page).to have_no_css("#taxonomy_filters-dialog-content")
51
+ within ".js-current-filters" do
52
+ expect(page).to have_css("td", text: "Internal taxonomy filter name")
53
+ expect(page).to have_css("td", text: "Public taxonomy filter name")
54
+ expect(page).to have_css("td", text: "Another filter")
55
+ expect(page).to have_link("Edit", count: 2)
56
+ end
57
+ expect(component.reload.settings.taxonomy_filters).to contain_exactly(taxonomy_filter.id.to_s, another_taxonomy_filter.id.to_s)
58
+
59
+ click_on "Update"
60
+ click_on "Configure"
61
+ within ".js-current-filters" do
62
+ expect(page).to have_css("td", text: "Internal taxonomy filter name")
63
+ expect(page).to have_css("td", text: "Public taxonomy filter name")
64
+ end
65
+ end
66
+ end
67
+
68
+ context "when taxonomy filter does not exist" do
69
+ let(:taxonomy_filter_item) { nil }
70
+ let(:taxonomy_filter) { nil }
71
+ before do
72
+ click_on "Configure"
73
+ end
74
+
75
+ it "shows a configuration message" do
76
+ expect(page).to have_content("No taxonomy filters found.")
77
+ expect(page).to have_link("Please define some filters for this participatory space before using this setting", href: filters_path)
78
+ end
79
+ end
80
+
81
+ context "when a taxonomy filter is already in settings" do
82
+ let!(:another_taxonomy_filter) { create(:taxonomy_filter, root_taxonomy:, name: { en: "Another taxonomy filter name" }) }
83
+
84
+ before do
85
+ component.update!(settings: { taxonomy_filters: [another_taxonomy_filter.id.to_s, taxonomy_filter.id.to_s] })
86
+ click_on "Configure"
87
+ end
88
+
89
+ it "can be removed from settings" do
90
+ within ".js-current-filters" do
91
+ within "tr", text: "Internal taxonomy filter name" do
92
+ click_on "Edit"
93
+ end
94
+ end
95
+
96
+ within "#taxonomy_filters-dialog-content" do
97
+ click_on "Remove"
98
+ end
99
+ sleep 1
100
+ expect(component.reload.settings.taxonomy_filters).to eq([another_taxonomy_filter.id.to_s])
101
+ expect(page).to have_css("td", text: "Another taxonomy filter name")
102
+ expect(page).to have_no_css("#taxonomy_filters-dialog-content")
103
+ expect(page).to have_no_content("Internal taxonomy filter name")
104
+
105
+ click_on "Add filter"
106
+ within "#taxonomy_filters-dialog-content" do
107
+ select "A root taxonomy", from: "taxonomy_id"
108
+ select "Internal taxonomy filter name", from: "taxonomy_filter_id"
109
+ click_on "Save"
110
+ end
111
+
112
+ within ".js-current-filters" do
113
+ expect(page).to have_css("td", text: "Another taxonomy filter name")
114
+ expect(page).to have_css("td", text: "Internal taxonomy filter name")
115
+ expect(page).to have_css("td", text: "Public taxonomy filter name")
116
+ expect(page).to have_link("Edit", count: 2)
117
+ end
118
+
119
+ click_on "Update"
120
+ click_on "Configure"
121
+ within ".js-current-filters" do
122
+ expect(page).to have_css("td", text: "Internal taxonomy filter name")
123
+ expect(page).to have_css("td", text: "Public taxonomy filter name")
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ shared_context "with taxonomy filters context" do
4
+ let(:organization) { create(:organization) }
5
+ let!(:user) { create(:user, :admin, :confirmed, organization:) }
6
+ let!(:root_taxonomy) { create(:taxonomy, organization:) }
7
+ let!(:another_root_taxonomy) { create(:taxonomy, organization:) }
8
+ let!(:taxonomy) { create(:taxonomy, skip_injection: true, organization:, parent: root_taxonomy) }
9
+ let!(:another_taxonomy) { create(:taxonomy, organization:, parent: root_taxonomy) }
10
+ let!(:taxonomy_with_child) { create(:taxonomy, organization:, parent: root_taxonomy) }
11
+ let!(:taxonomy_child) { create(:taxonomy, organization:, parent: taxonomy_with_child) }
12
+ let!(:taxonomy_filter) { create(:taxonomy_filter, name:, internal_name:, root_taxonomy:, participatory_space_manifests:) }
13
+ let(:name) { { "en" => "The name for regular users" } }
14
+ let(:internal_name) { { "en" => "The name for admins only" } }
15
+ let!(:another_taxonomy_filter) { create(:taxonomy_filter, root_taxonomy: another_root_taxonomy, participatory_space_manifests:) }
16
+ let!(:taxonomy_filter_item) { create(:taxonomy_filter_item, taxonomy_filter:, taxonomy_item: taxonomy) }
17
+ let!(:another_taxonomy_filter_item) { create(:taxonomy_filter_item, taxonomy_filter:, taxonomy_item: another_taxonomy) }
18
+ let(:participatory_space_manifests) { %w(participatory_processes assemblies) }
19
+ end
20
+
21
+ shared_examples "having no taxonomy filters defined" do
22
+ let!(:taxonomy_filter) { create(:taxonomy_filter) }
23
+ let!(:taxonomy_filter_item) { nil }
24
+ let!(:another_taxonomy_filter) { create(:taxonomy_filter) }
25
+ let!(:another_taxonomy_filter_item) { nil }
26
+
27
+ it "shows no taxonomy filters" do
28
+ expect(page).to have_content("Taxonomies")
29
+ expect(page).to have_content("No taxonomy filters found.")
30
+ expect(page).to have_link("Please define some filters for this participatory space before using this setting")
31
+ end
32
+ end
@@ -2,11 +2,12 @@
2
2
 
3
3
  require "decidim/admin/test/manage_attachments_examples"
4
4
  require "decidim/admin/test/manage_attachment_collections_examples"
5
- require "decidim/admin/test/manage_categories_examples"
6
5
  require "decidim/admin/test/manage_component_permissions_examples"
7
6
  require "decidim/admin/test/manage_moderations_examples"
7
+ require "decidim/admin/test/manage_taxonomy_filters_examples"
8
8
  require "decidim/admin/test/manage_paginated_collection_examples"
9
9
  require "decidim/admin/test/manage_participatory_space_publications_examples"
10
+ require "decidim/admin/test/manage_resource_soft_deletion_examples"
10
11
  require "decidim/admin/test/filterable_examples"
11
12
  require "decidim/admin/test/filters_participatory_space_users_examples"
12
13
  require "decidim/admin/test/filters_participatory_space_user_roles_examples"
@@ -15,3 +16,4 @@ require "decidim/admin/test/needs_admin_tos_accepted_examples"
15
16
  require "decidim/admin/test/destroy_admin_examples"
16
17
  require "decidim/admin/test/commands/publish_participatory_space_examples"
17
18
  require "decidim/admin/test/invite_participatory_space_users_shared_context"
19
+ require "decidim/admin/test/taxonomy_filters_examples"
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-admin version.
5
5
  module Admin
6
6
  def self.version
7
- "0.29.2"
7
+ "0.30.0.rc2"
8
8
  end
9
9
  end
10
10
  end