decidim-admin 0.29.1 → 0.30.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) 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/block_user.rb +1 -0
  5. data/app/commands/decidim/admin/bulk_action.rb +92 -0
  6. data/app/commands/decidim/admin/bulk_block_users.rb +75 -0
  7. data/app/commands/decidim/admin/bulk_unblock_users.rb +66 -0
  8. data/app/commands/decidim/admin/bulk_unreport_users.rb +69 -0
  9. data/app/commands/decidim/admin/content_blocks/update_content_block.rb +1 -1
  10. data/app/commands/decidim/admin/create_participatory_space_private_user.rb +3 -1
  11. data/app/commands/decidim/admin/create_share_token.rb +39 -0
  12. data/app/commands/decidim/admin/create_taxonomy.rb +23 -0
  13. data/app/commands/decidim/admin/create_taxonomy_filter.rb +24 -0
  14. data/app/commands/decidim/admin/destroy_share_token.rb +22 -0
  15. data/app/commands/decidim/admin/destroy_taxonomy.rb +18 -0
  16. data/app/commands/decidim/admin/destroy_taxonomy_filter.rb +20 -0
  17. data/app/commands/decidim/admin/hide_menu_component.rb +37 -0
  18. data/app/commands/decidim/admin/hide_resource.rb +4 -2
  19. data/app/commands/decidim/admin/publish_all_participatory_space_private_users.rb +50 -0
  20. data/app/commands/decidim/admin/publish_component.rb +3 -0
  21. data/app/commands/decidim/admin/reorder_components.rb +47 -0
  22. data/app/commands/decidim/admin/reorder_taxonomies.rb +76 -0
  23. data/app/commands/decidim/admin/unhide_resource.rb +11 -3
  24. data/app/commands/decidim/admin/unpublish_all_participatory_space_private_users.rb +50 -0
  25. data/app/commands/decidim/admin/unreport_resource.rb +11 -3
  26. data/app/commands/decidim/admin/update_component_permissions.rb +53 -13
  27. data/app/commands/decidim/admin/update_participatory_space_private_user.rb +11 -0
  28. data/app/commands/decidim/admin/update_share_token.rb +24 -0
  29. data/app/commands/decidim/admin/update_taxonomy.rb +20 -0
  30. data/app/commands/decidim/admin/update_taxonomy_filter.rb +28 -0
  31. data/app/controllers/concerns/decidim/admin/component_taxonomies_helper.rb +19 -0
  32. data/app/controllers/concerns/decidim/admin/filterable.rb +15 -18
  33. data/app/controllers/concerns/decidim/admin/has_trashable_resources.rb +170 -0
  34. data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +2 -29
  35. data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +12 -2
  36. data/app/controllers/concerns/decidim/admin/taxonomies/filterable.rb +27 -0
  37. data/app/controllers/decidim/admin/application_controller.rb +1 -2
  38. data/app/controllers/decidim/admin/areas_controller.rb +1 -0
  39. data/app/controllers/decidim/admin/block_user_controller.rb +43 -1
  40. data/app/controllers/decidim/admin/component_permissions_controller.rb +2 -4
  41. data/app/controllers/decidim/admin/components_controller.rb +50 -9
  42. data/app/controllers/decidim/admin/concerns/has_private_users.rb +59 -2
  43. data/app/controllers/decidim/admin/conflicts_controller.rb +1 -1
  44. data/app/controllers/decidim/admin/global_moderations_controller.rb +4 -0
  45. data/app/controllers/decidim/admin/impersonations_controller.rb +1 -0
  46. data/app/controllers/decidim/admin/moderated_users_controller.rb +26 -0
  47. data/app/controllers/decidim/admin/moderations_controller.rb +18 -0
  48. data/app/controllers/decidim/admin/newsletters_controller.rb +50 -6
  49. data/app/controllers/decidim/admin/resource_permissions_controller.rb +1 -1
  50. data/app/controllers/decidim/admin/scopes_controller.rb +1 -0
  51. data/app/controllers/decidim/admin/share_tokens_controller.rb +109 -7
  52. data/app/controllers/decidim/admin/taxonomies_controller.rb +129 -0
  53. data/app/controllers/decidim/admin/taxonomy_filters_controller.rb +112 -0
  54. data/app/controllers/decidim/admin/taxonomy_filters_selector_controller.rb +81 -0
  55. data/app/controllers/decidim/admin/taxonomy_items_controller.rb +91 -0
  56. data/app/forms/concerns/decidim/has_taxonomy_form_attributes.rb +57 -0
  57. data/app/forms/decidim/admin/block_users_form.rb +21 -0
  58. data/app/forms/decidim/admin/help_section_form.rb +1 -1
  59. data/app/forms/decidim/admin/impersonate_user_form.rb +5 -0
  60. data/app/forms/decidim/admin/import_example_form.rb +1 -1
  61. data/app/forms/decidim/admin/newsletter_form.rb +1 -1
  62. data/app/forms/decidim/admin/organization_appearance_form.rb +2 -2
  63. data/app/forms/decidim/admin/organization_form.rb +2 -2
  64. data/app/forms/decidim/admin/participatory_space_private_user_form.rb +5 -0
  65. data/app/forms/decidim/admin/selective_newsletter_form.rb +46 -11
  66. data/app/forms/decidim/admin/share_token_form.rb +55 -0
  67. data/app/forms/decidim/admin/static_page_form.rb +1 -1
  68. data/app/forms/decidim/admin/taxonomy_filter_form.rb +85 -0
  69. data/app/forms/decidim/admin/taxonomy_form.rb +20 -0
  70. data/app/forms/decidim/admin/taxonomy_item_form.rb +54 -0
  71. data/app/forms/decidim/admin/transfer_user_form.rb +15 -0
  72. data/app/helpers/decidim/admin/application_helper.rb +0 -1
  73. data/app/helpers/decidim/admin/bulk_actions_helper.rb +0 -31
  74. data/app/helpers/decidim/admin/moderations/reports_helper.rb +1 -1
  75. data/app/helpers/decidim/admin/moderations_helper.rb +1 -1
  76. data/app/helpers/decidim/admin/newsletters_helper.rb +57 -27
  77. data/app/helpers/decidim/admin/scopes_helper.rb +0 -6
  78. data/app/helpers/decidim/admin/search_form_helper.rb +1 -1
  79. data/app/helpers/decidim/admin/settings_helper.rb +85 -11
  80. data/app/jobs/decidim/admin/newsletter_job.rb +3 -1
  81. data/app/packs/entrypoints/decidim_admin.js +4 -0
  82. data/app/packs/src/decidim/admin/application.js +2 -0
  83. data/app/packs/src/decidim/admin/draggable-table.js +33 -0
  84. data/app/packs/src/decidim/admin/form.js +0 -1
  85. data/app/packs/src/decidim/admin/global_moderations.js +186 -0
  86. data/app/packs/src/decidim/admin/managed_moderated_users.js +186 -0
  87. data/app/packs/src/decidim/admin/newsletters.js +164 -73
  88. data/app/packs/src/decidim/admin/proposal_infinite_edit.js +3 -6
  89. data/app/packs/src/decidim/admin/sortable.js +28 -16
  90. data/app/packs/src/decidim/admin/taxonomy_filters.js +93 -0
  91. data/app/packs/stylesheets/decidim/admin/_component-show.scss +66 -5
  92. data/app/packs/stylesheets/decidim/admin/_legacy_foundation.scss +13 -0
  93. data/app/packs/stylesheets/decidim/admin/_moderations.scss +8 -0
  94. data/app/packs/stylesheets/decidim/admin/_select_picker.scss +20 -0
  95. data/app/packs/stylesheets/decidim/admin/_table-list.scss +22 -0
  96. data/app/packs/stylesheets/decidim/admin/_taxonomies.scss +74 -0
  97. data/app/packs/stylesheets/decidim/admin/application.scss +3 -0
  98. data/app/permissions/decidim/admin/permissions.rb +32 -1
  99. data/app/queries/decidim/admin/newsletter_recipients.rb +59 -19
  100. data/app/views/decidim/admin/areas/index.html.erb +3 -0
  101. data/app/views/decidim/admin/block_user/bulk_new.html.erb +45 -0
  102. data/app/views/decidim/admin/components/_actions.html.erb +50 -33
  103. data/app/views/decidim/admin/components/{_component.html.erb → _component_row.html.erb} +10 -5
  104. data/app/views/decidim/admin/components/_components_table.html.erb +18 -0
  105. data/app/views/decidim/admin/components/_form.html.erb +0 -12
  106. data/app/views/decidim/admin/components/_taxonomy_filters_drawer.html.erb +2 -0
  107. data/app/views/decidim/admin/components/_visibility_label.html.erb +9 -0
  108. data/app/views/decidim/admin/components/index.html.erb +12 -14
  109. data/app/views/decidim/admin/components/manage_trash.html.erb +11 -0
  110. data/app/views/decidim/admin/conflicts/edit.html.erb +21 -11
  111. data/app/views/decidim/admin/moderated_users/_bulk-actions.html.erb +6 -0
  112. data/app/views/decidim/admin/moderated_users/bulk_actions/_block.html.erb +20 -0
  113. data/app/views/decidim/admin/moderated_users/bulk_actions/_dropdown.html.erb +40 -0
  114. data/app/views/decidim/admin/moderated_users/bulk_actions/_unblock.html.erb +20 -0
  115. data/app/views/decidim/admin/moderated_users/bulk_actions/_unreport.html.erb +20 -0
  116. data/app/views/decidim/admin/moderated_users/index.html.erb +15 -7
  117. data/app/views/decidim/admin/moderations/_bulk-actions.html.erb +7 -0
  118. data/app/views/decidim/admin/moderations/_moderation-tr.html.erb +50 -0
  119. data/app/views/decidim/admin/moderations/_moderations-thead.html.erb +18 -0
  120. data/app/views/decidim/admin/moderations/bulk_actions/_dropdown.html.erb +43 -0
  121. data/app/views/decidim/admin/moderations/bulk_actions/_hide.html.erb +20 -0
  122. data/app/views/decidim/admin/moderations/bulk_actions/_unhide.html.erb +20 -0
  123. data/app/views/decidim/admin/moderations/bulk_actions/_unreport.html.erb +20 -0
  124. data/app/views/decidim/admin/moderations/index.html.erb +13 -81
  125. data/app/views/decidim/admin/newsletter_templates/index.html.erb +0 -1
  126. data/app/views/decidim/admin/newsletters/confirm_recipients.html.erb +64 -0
  127. data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +44 -20
  128. data/app/views/decidim/admin/participatory_space_private_users/_form.html.erb +6 -0
  129. data/app/views/decidim/admin/participatory_space_private_users/edit.html.erb +19 -0
  130. data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +15 -1
  131. data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +5 -0
  132. data/app/views/decidim/admin/resource_permissions/edit.html.erb +2 -2
  133. data/app/views/decidim/admin/scope_types/index.html.erb +3 -0
  134. data/app/views/decidim/admin/scopes/index.html.erb +3 -0
  135. data/app/views/decidim/admin/share_tokens/_form.html.erb +52 -0
  136. data/app/views/decidim/admin/share_tokens/edit.html.erb +33 -0
  137. data/app/views/decidim/admin/share_tokens/index.html.erb +47 -0
  138. data/app/views/decidim/admin/share_tokens/new.html.erb +69 -0
  139. data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +1 -1
  140. data/app/views/decidim/admin/taxonomies/_filters.html.erb +19 -0
  141. data/app/views/decidim/admin/taxonomies/_form.html.erb +5 -0
  142. data/app/views/decidim/admin/taxonomies/_row.html.erb +40 -0
  143. data/app/views/decidim/admin/taxonomies/_row_children.html.erb +8 -0
  144. data/app/views/decidim/admin/taxonomies/_table.html.erb +86 -0
  145. data/app/views/decidim/admin/taxonomies/_taxonomy_actions.html.erb +15 -0
  146. data/app/views/decidim/admin/taxonomies/edit.html.erb +87 -0
  147. data/app/views/decidim/admin/taxonomies/index.html.erb +28 -0
  148. data/app/views/decidim/admin/taxonomies/new.html.erb +16 -0
  149. data/app/views/decidim/admin/taxonomy_filters/_check_boxes.html.erb +10 -0
  150. data/app/views/decidim/admin/taxonomy_filters/_form.html.erb +96 -0
  151. data/app/views/decidim/admin/taxonomy_filters/_table.html.erb +33 -0
  152. data/app/views/decidim/admin/taxonomy_filters/edit.html.erb +22 -0
  153. data/app/views/decidim/admin/taxonomy_filters/index.html.erb +26 -0
  154. data/app/views/decidim/admin/taxonomy_filters/new.html.erb +32 -0
  155. data/app/views/decidim/admin/taxonomy_filters_selector/_check_boxes.html.erb +7 -0
  156. data/app/views/decidim/admin/taxonomy_filters_selector/_component_table.html.erb +25 -0
  157. data/app/views/decidim/admin/taxonomy_filters_selector/_taxonomies_select.html.erb +16 -0
  158. data/app/views/decidim/admin/taxonomy_filters_selector/index.html.erb +1 -0
  159. data/app/views/decidim/admin/taxonomy_filters_selector/new.html.erb +27 -0
  160. data/app/views/decidim/admin/taxonomy_filters_selector/show.html.erb +18 -0
  161. data/app/views/decidim/admin/taxonomy_items/_form.html.erb +8 -0
  162. data/app/views/decidim/admin/taxonomy_items/edit.html.erb +12 -0
  163. data/app/views/decidim/admin/taxonomy_items/new.html.erb +12 -0
  164. data/app/views/layouts/decidim/admin/taxonomy_filters.html.erb +17 -0
  165. data/app/views/layouts/decidim/admin/taxonomy_filters_selector.html.erb +10 -0
  166. data/config/locales/ar.yml +91 -36
  167. data/config/locales/bg.yml +48 -51
  168. data/config/locales/bn-BD.yml +1 -0
  169. data/config/locales/bs-BA.yml +499 -0
  170. data/config/locales/ca.yml +300 -50
  171. data/config/locales/cs.yml +298 -46
  172. data/config/locales/de.yml +300 -50
  173. data/config/locales/el.yml +1 -50
  174. data/config/locales/en.yml +300 -50
  175. data/config/locales/es-MX.yml +298 -48
  176. data/config/locales/es-PY.yml +298 -48
  177. data/config/locales/es.yml +298 -48
  178. data/config/locales/eu.yml +433 -171
  179. data/config/locales/fi-plain.yml +298 -48
  180. data/config/locales/fi.yml +315 -65
  181. data/config/locales/fr-CA.yml +183 -47
  182. data/config/locales/fr.yml +183 -47
  183. data/config/locales/ga-IE.yml +0 -23
  184. data/config/locales/gl.yml +1 -46
  185. data/config/locales/hu.yml +1 -51
  186. data/config/locales/id-ID.yml +0 -20
  187. data/config/locales/is-IS.yml +0 -18
  188. data/config/locales/it.yml +1 -46
  189. data/config/locales/ja.yml +303 -55
  190. data/config/locales/kaa.yml +0 -10
  191. data/config/locales/ko.yml +0 -50
  192. data/config/locales/lb.yml +1 -46
  193. data/config/locales/lt.yml +1 -50
  194. data/config/locales/lv.yml +1 -27
  195. data/config/locales/nl.yml +1 -46
  196. data/config/locales/no.yml +1 -46
  197. data/config/locales/pl.yml +3 -51
  198. data/config/locales/pt-BR.yml +38 -50
  199. data/config/locales/pt.yml +30 -46
  200. data/config/locales/ro-RO.yml +35 -50
  201. data/config/locales/ru.yml +1 -22
  202. data/config/locales/sk.yml +1 -27
  203. data/config/locales/sl.yml +0 -7
  204. data/config/locales/sq-AL.yml +0 -25
  205. data/config/locales/sr-CS.yml +1 -27
  206. data/config/locales/sv.yml +297 -47
  207. data/config/locales/tr-TR.yml +1 -44
  208. data/config/locales/uk.yml +0 -20
  209. data/config/locales/zh-CN.yml +0 -44
  210. data/config/locales/zh-TW.yml +1 -50
  211. data/config/routes.rb +14 -13
  212. data/decidim-admin.gemspec +2 -2
  213. data/lib/decidim/admin/engine.rb +3 -1
  214. data/lib/decidim/admin/import/creator.rb +2 -6
  215. data/lib/decidim/admin/import/readers/json.rb +1 -1
  216. data/lib/decidim/admin/menu.rb +9 -1
  217. data/lib/decidim/admin/search_form_builder.rb +1 -1
  218. data/lib/decidim/admin/test/destroy_admin_examples.rb +2 -2
  219. data/lib/decidim/admin/test/filterable_examples.rb +100 -9
  220. data/lib/decidim/admin/test/forms/attachment_collection_form_examples.rb +1 -1
  221. data/lib/decidim/admin/test/forms/attachment_form_examples.rb +1 -1
  222. data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +2 -4
  223. data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
  224. data/lib/decidim/admin/test/manage_hide_content_examples.rb +0 -1
  225. data/lib/decidim/admin/test/manage_moderations_examples.rb +3 -3
  226. data/lib/decidim/admin/test/manage_resource_soft_deletion_examples.rb +113 -0
  227. data/lib/decidim/admin/test/manage_taxonomy_filters_examples.rb +127 -0
  228. data/lib/decidim/admin/test/taxonomy_filters_examples.rb +32 -0
  229. data/lib/decidim/admin/test.rb +3 -1
  230. data/lib/decidim/admin/version.rb +1 -1
  231. metadata +106 -30
  232. data/app/commands/decidim/admin/create_category.rb +0 -15
  233. data/app/commands/decidim/admin/destroy_category.rb +0 -15
  234. data/app/commands/decidim/admin/destroy_component.rb +0 -19
  235. data/app/commands/decidim/admin/update_category.rb +0 -11
  236. data/app/controllers/decidim/admin/categories_controller.rb +0 -98
  237. data/app/forms/decidim/admin/category_form.rb +0 -32
  238. data/app/helpers/decidim/admin/resource_scope_helper.rb +0 -52
  239. data/app/packs/src/decidim/admin/scope_picker_enabler.component.js +0 -12
  240. data/app/views/decidim/admin/categories/_form.html.erb +0 -18
  241. data/app/views/decidim/admin/categories/edit.html.erb +0 -19
  242. data/app/views/decidim/admin/categories/index.html.erb +0 -65
  243. data/app/views/decidim/admin/categories/new.html.erb +0 -19
  244. data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +0 -45
  245. data/lib/decidim/admin/test/commands/create_category_examples.rb +0 -74
  246. data/lib/decidim/admin/test/commands/destroy_category_examples.rb +0 -83
  247. data/lib/decidim/admin/test/commands/update_category_examples.rb +0 -76
  248. data/lib/decidim/admin/test/forms/category_form_examples.rb +0 -70
  249. data/lib/decidim/admin/test/manage_categories_examples.rb +0 -128
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Admin
5
- # This module includes helpers to show scopes in admin
6
- module ResourceScopeHelper
7
- # Public: This helper shows the th with the scope label.
8
- #
9
- # scope_label - I18n translation to show
10
- #
11
- def th_resource_scope_label(scope_label = t("decidim.admin.resources.index.headers.scope"))
12
- return unless resource_with_scopes_enabled?
13
-
14
- content_tag(:th, scope_label)
15
- end
16
-
17
- # Public: This helper shows the td for the given scope.
18
- #
19
- # current_scope - Scope object to show
20
- #
21
- def td_resource_scope_for(current_scope)
22
- return unless resource_with_scopes_enabled?
23
-
24
- scope_name = if current_scope
25
- translated_attribute(current_scope.name)
26
- else
27
- t("decidim.scopes.global")
28
- end
29
- content_tag(:td, scope_name)
30
- end
31
-
32
- # Public: This helper shows th with the sort link element.
33
- def th_scope_sort_link
34
- return unless resource_with_scopes_enabled?
35
-
36
- content_tag(:th) do
37
- sort_link(query, :scope_name, t("decidim.admin.resources.index.headers.scope"))
38
- end
39
- end
40
-
41
- private
42
-
43
- def resource_with_scopes_enabled?
44
- if defined? current_component
45
- current_component.scopes_enabled? || current_participatory_space.scopes_enabled?
46
- else
47
- current_participatory_space.scopes_enabled?
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,12 +0,0 @@
1
- $(() => {
2
- const $ComponentScopeEnabled = $("#component_settings_scopes_enabled");
3
- const $ComponentScopeId = $("#component_settings_scope_id");
4
-
5
- if ($(".edit_component, .new_component").length > 0) {
6
- $ComponentScopeEnabled.on("change", (event) => {
7
- const checked = event.target.checked;
8
- $ComponentScopeId.attr("disabled", !checked);
9
- })
10
- $ComponentScopeId.attr("disabled", !$ComponentScopeEnabled.prop("checked"));
11
- }
12
- });
@@ -1,18 +0,0 @@
1
- <div class="form__wrapper">
2
- <div class="card pt-4">
3
- <div id="panel-title" class="card-section">
4
- <div class="row column">
5
- <%= form.translated :text_field, :name, autofocus: true, aria: { label: :name } %>
6
- </div>
7
-
8
- <div class="row column">
9
- <%= form.number_field :weight %>
10
- </div>
11
-
12
- <div class="row column">
13
- <%= form.label :parent_id %>
14
- <%= select :category, :parent_id, @form.parent_categories.map { |c| [c.name[current_organization.default_locale], c.id] }, include_blank: true %>
15
- </div>
16
- </div>
17
- </div>
18
- </div>
@@ -1,19 +0,0 @@
1
- <% add_decidim_page_title(t(".title")) %>
2
- <div class="item_show__header">
3
- <h1 class="item_show__header-title">
4
- <%= t("categories.edit.title", scope: "decidim.admin") %>
5
- </h1>
6
- </div>
7
-
8
- <div class="item__edit item__edit-1col">
9
- <div class="item__edit-form">
10
- <%= decidim_form_for(@form, url: category_path(@category.participatory_space, @category), html: { class: "form-defaults form edit_category" }) do |f| %>
11
- <%= render partial: "form", object: f %>
12
- <div class="item__edit-sticky">
13
- <div class="item__edit-sticky-container">
14
- <%= f.submit t("categories.edit.update", scope: "decidim.admin"), class: "button button__sm button__secondary" %>
15
- </div>
16
- </div>
17
- <% end %>
18
- </div>
19
- </div>
@@ -1,65 +0,0 @@
1
- <% add_decidim_page_title(t("categories.index.categories_title", scope: "decidim.admin")) %>
2
- <div class="card" id="categories">
3
- <div class="item_show__header">
4
- <h1 class="item_show__header-title">
5
- <%= t("categories.index.categories_title", scope: "decidim.admin") %>
6
- <% if allowed_to? :create, :category %>
7
- <%= link_to t("actions.category.new", scope: "decidim.admin"), new_category_path(current_participatory_space), class: "button button__sm button__secondary new ml-auto" %>
8
- <% end %>
9
- </h1>
10
- </div>
11
- <% if current_participatory_space.categories.any? %>
12
- <div class="table-scroll">
13
- <table class="table-list">
14
- <thead>
15
- <tr>
16
- <th><%= t("activemodel.attributes.category.name") %></th>
17
- <th></th>
18
- </tr>
19
- </thead>
20
- <tbody>
21
- <% current_participatory_space.categories.first_class.each do |category| %>
22
- <tr>
23
- <td>
24
- <%= link_to translated_attribute(category.name), edit_category_path(current_participatory_space, category) %><br>
25
- </td>
26
- <td class="table-list__actions">
27
- <% if allowed_to? :update, :category, category: category %>
28
- <%= icon_link_to "pencil-line", edit_category_path(current_participatory_space, category), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
29
- <% end %>
30
-
31
- <% if allowed_to? :destroy, :category, category: category %>
32
- <% if category.unused? %>
33
- <%= icon_link_to "delete-bin-line", category_path(current_participatory_space, category), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
34
- <% else %>
35
- <%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", "aria-hidden": true %>
36
- <% end %>
37
- <% end %>
38
- </td>
39
- </tr>
40
- <% category.subcategories.each do |subcategory| %>
41
- <tr>
42
- <td>
43
- <%= link_to translated_attribute(subcategory.name), edit_category_path(current_participatory_space, subcategory) %><br>
44
- </td>
45
- <td class="table-list__actions">
46
- <% if allowed_to? :update, :category, category: subcategory %>
47
- <%= icon_link_to "pencil-line", edit_category_path(current_participatory_space, subcategory), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %>
48
- <% end %>
49
-
50
- <% if allowed_to? :destroy, :category, category: subcategory %>
51
- <% if subcategory.unused? %>
52
- <%= icon_link_to "delete-bin-line", category_path(current_participatory_space, subcategory), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
53
- <% else %>
54
- <%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", "aria-hidden": true %>
55
- <% end %>
56
- <% end %>
57
- </td>
58
- </tr>
59
- <% end %>
60
- <% end %>
61
- </tbody>
62
- </table>
63
- </div>
64
- <% end %>
65
- </div>
@@ -1,19 +0,0 @@
1
- <% add_decidim_page_title(t("categories.new.title", scope: "decidim.admin")) %>
2
- <div class="item_show__header">
3
- <h1 class="item_show__header-title">
4
- <%= t("categories.new.title", scope: "decidim.admin") %>
5
- </h1>
6
- </div>
7
-
8
- <div class="item__edit item__edit-1col">
9
- <div class="item__edit-form">
10
- <%= decidim_form_for(@form, url: categories_path(current_participatory_space), html: { class: "form-defaults form new_category" }) do |f| %>
11
- <%= render partial: "form", object: f %>
12
- <div class="item__edit-sticky">
13
- <div class="item__edit-sticky-container">
14
- <%= f.submit t("categories.new.create", scope: "decidim.admin"), class: "button button__sm button__secondary" %>
15
- </div>
16
- </div>
17
- <% end %>
18
- </div>
19
- </div>
@@ -1,45 +0,0 @@
1
- <div class="share_tokens">
2
- <div class="card-divider">
3
- <legend><%= t ".title" %></legend>
4
- </div>
5
- <div class="card-section">
6
- <div class="help-text">
7
- <p><%= t ".help" %></p>
8
- </div>
9
- <% if share_tokens.any? %>
10
- <div class="table-scroll">
11
- <table class="table-list">
12
- <thead>
13
- <tr>
14
- <th><%= t("models.share_token.fields.token", scope: "decidim.admin") %></th>
15
- <th><%= t("models.share_token.fields.user", scope: "decidim.admin") %></th>
16
- <th><%= t("models.share_token.fields.times_used", scope: "decidim.admin") %></th>
17
- <th><%= t("models.share_token.fields.last_used_at", scope: "decidim.admin") %></th>
18
- <th><%= t("models.share_token.fields.created_at", scope: "decidim.admin") %></th>
19
- <th><%= t("models.share_token.fields.expires_at", scope: "decidim.admin") %></th>
20
- <th></th>
21
- </tr>
22
- </thead>
23
- <tbody>
24
- <% share_tokens.each do |share_token| %>
25
- <tr>
26
- <td><%= share_token.token %></td>
27
- <td><%= share_token.user.name %></td>
28
- <td><%= share_token.times_used %></td>
29
- <td><%= l share_token.last_used_at, format: :short if share_token.last_used_at.present? %></td>
30
- <td><%= l share_token.created_at, format: :short %></td>
31
- <td><%= l share_token.expires_at, format: :short if share_token.expires_at.present? %></td>
32
- <td class="table-list__actions">
33
- <%= icon_link_to "share-line", share_token.url, t("actions.share", scope: "decidim.admin.share_tokens"), class: "action-icon--share", target: :blank %>
34
- <%= icon_link_to "delete-bin-line", decidim_admin.share_token_path(share_token, url: request.fullpath), t("actions.destroy", scope: "decidim.admin.share_tokens"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin.share_tokens") } %>
35
- </td>
36
- </tr>
37
- <% end %>
38
- </tbody>
39
- </table>
40
- </div>
41
- <% else %>
42
- <p><%= t ".empty" %></p>
43
- <% end %>
44
- </div>
45
- </div>
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- module Decidim
6
- module Admin
7
- shared_examples_for "CreateCategory command" do
8
- describe "call" do
9
- let(:organization) { create(:organization) }
10
- let(:user) { create(:user, organization:) }
11
- let(:form_params) do
12
- {
13
- "category" => {
14
- "name_en" => Decidim::Faker::Localized.paragraph(sentence_count: 3),
15
- "name_es" => Decidim::Faker::Localized.paragraph(sentence_count: 3),
16
- "name_ca" => Decidim::Faker::Localized.paragraph(sentence_count: 3)
17
- }
18
- }
19
- end
20
- let(:form) do
21
- CategoryForm.from_params(
22
- form_params,
23
- current_participatory_space: participatory_space
24
- ).with_context(
25
- current_organization: organization,
26
- current_participatory_space: participatory_space,
27
- current_user: user
28
- )
29
- end
30
- let(:command) { described_class.new(form) }
31
-
32
- describe "when the form is not valid" do
33
- before do
34
- allow(form).to receive(:invalid?).and_return(true)
35
- end
36
-
37
- it "broadcasts invalid" do
38
- expect { command.call }.to broadcast(:invalid)
39
- end
40
-
41
- it "does not create a category" do
42
- expect do
43
- command.call
44
- end.not_to change(Category, :count)
45
- end
46
- end
47
-
48
- describe "when the form is valid" do
49
- it "broadcasts ok" do
50
- expect { command.call }.to broadcast(:ok)
51
- end
52
-
53
- it "creates a new category" do
54
- expect do
55
- command.call
56
- end.to change(participatory_space.categories, :count).by(1)
57
- end
58
-
59
- it "traces the action", versioning: true do
60
- expect(Decidim.traceability)
61
- .to receive(:perform_action!)
62
- .with(:create, Decidim::Category, user, {})
63
- .and_call_original
64
-
65
- expect { command.call }.to change(Decidim::ActionLog, :count)
66
- action_log = Decidim::ActionLog.last
67
- expect(action_log.action).to eq("create")
68
- expect(action_log.version).to be_present
69
- end
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- module Decidim
6
- module Admin
7
- shared_examples_for "DestroyCategory command" do
8
- describe "call" do
9
- let(:organization) { create(:organization) }
10
- let(:user) { create(:user, organization:) }
11
- let(:category) { create(:category, participatory_space:) }
12
- let(:command) { described_class.new(category, user) }
13
-
14
- describe "when the category is not present" do
15
- let(:category) { nil }
16
-
17
- it "broadcasts invalid" do
18
- expect { command.call }.to broadcast(:invalid)
19
- end
20
- end
21
-
22
- context "when the category is being used by a resource" do
23
- let(:component) { create(:dummy_component, participatory_space:) }
24
- let!(:resource) { create(:dummy_resource, component:, category:) }
25
-
26
- it "broadcasts invalid" do
27
- expect { command.call }.to broadcast(:invalid)
28
- end
29
- end
30
-
31
- context "when the category is not empty" do
32
- let!(:subcategory) { create :subcategory, parent: category }
33
-
34
- it "does not destroy the category" do
35
- expect do
36
- command.call
37
- end.not_to change(Category, :count)
38
- end
39
- end
40
-
41
- context "when the category is a subcategory" do
42
- let!(:parent_category) { create :category, participatory_space: }
43
-
44
- before do
45
- category.parent = parent_category
46
- end
47
-
48
- it "destroy the category" do
49
- category
50
- expect do
51
- command.call
52
- end.to change(Category, :count).by(-1)
53
- end
54
- end
55
-
56
- describe "when the data is valid" do
57
- it "broadcasts ok" do
58
- expect { command.call }.to broadcast(:ok)
59
- end
60
-
61
- it "destroys the category in the process" do
62
- category
63
- expect do
64
- command.call
65
- end.to change(Category, :count).by(-1)
66
- end
67
-
68
- it "traces the action", versioning: true do
69
- expect(Decidim.traceability)
70
- .to receive(:perform_action!)
71
- .with(:delete, category, user)
72
- .and_call_original
73
-
74
- expect { command.call }.to change(Decidim::ActionLog, :count)
75
- action_log = Decidim::ActionLog.last
76
- expect(action_log.action).to eq("delete")
77
- expect(action_log.version).to be_present
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- module Decidim
6
- module Admin
7
- shared_examples_for "UpdateCategory command" do
8
- describe "call" do
9
- let(:organization) { create(:organization) }
10
- let(:user) { create(:user, organization:) }
11
- let(:category) { create(:category, participatory_space:) }
12
- let(:form_params) do
13
- {
14
- "category" => {
15
- "name_en" => "New title",
16
- "name_es" => "Title",
17
- "name_ca" => "Title"
18
- }
19
- }
20
- end
21
- let(:form) do
22
- CategoryForm.from_params(
23
- form_params,
24
- current_participatory_space: participatory_space
25
- ).with_context(
26
- current_organization: organization,
27
- current_user: user
28
- )
29
- end
30
- let(:command) { described_class.new(form, category) }
31
-
32
- describe "when the form is not valid" do
33
- before do
34
- allow(form).to receive(:invalid?).and_return(true)
35
- end
36
-
37
- it "broadcasts invalid" do
38
- expect { command.call }.to broadcast(:invalid)
39
- end
40
-
41
- it "does not update the category" do
42
- command.call
43
- category.reload
44
-
45
- expect(translated(category.name)).not_to eq("New title")
46
- end
47
- end
48
-
49
- describe "when the form is valid" do
50
- it "broadcasts ok" do
51
- expect { command.call }.to broadcast(:ok)
52
- end
53
-
54
- it "updates the category in the process" do
55
- command.call
56
- category.reload
57
-
58
- expect(translated(category.name)).to eq("New title")
59
- end
60
-
61
- it "traces the action", versioning: true do
62
- expect(Decidim.traceability)
63
- .to receive(:perform_action!)
64
- .with(:update, Decidim::Category, user, {})
65
- .and_call_original
66
-
67
- expect { command.call }.to change(Decidim::ActionLog, :count)
68
- action_log = Decidim::ActionLog.last
69
- expect(action_log.action).to eq("update")
70
- expect(action_log.version).to be_present
71
- end
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "spec_helper"
4
-
5
- module Decidim
6
- module Admin
7
- shared_examples_for "category form" do
8
- subject do
9
- described_class.from_params(
10
- attributes
11
- ).with_context(
12
- current_participatory_space: participatory_space,
13
- current_organization: organization
14
- )
15
- end
16
-
17
- let(:name) do
18
- {
19
- en: "Name",
20
- es: "Nombre",
21
- ca: "Nom"
22
- }
23
- end
24
- let(:parent_id) { nil }
25
- let(:attributes) do
26
- {
27
- "category" => {
28
- "name_en" => name[:en],
29
- "name_es" => name[:es],
30
- "name_ca" => name[:ca],
31
- "parent_id" => parent_id
32
- }
33
- }
34
- end
35
- let(:organization) { create :organization }
36
-
37
- context "when everything is OK" do
38
- it { is_expected.to be_valid }
39
- end
40
-
41
- context "when default language in name is missing" do
42
- let(:name) do
43
- {
44
- ca: "Nom",
45
- es: "Nombre"
46
- }
47
- end
48
-
49
- it { is_expected.to be_invalid }
50
- end
51
-
52
- context "when the parent_id is set" do
53
- let!(:category) { create :category, participatory_space: }
54
-
55
- context "and it is set to a first-class category" do
56
- let(:parent_id) { category.id }
57
-
58
- it { is_expected.to be_valid }
59
- end
60
-
61
- context "and it is set to a subcategory" do
62
- let!(:subcategory) { create :subcategory, parent: category }
63
- let(:parent_id) { subcategory.id }
64
-
65
- it { is_expected.not_to be_valid }
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- shared_examples "manage categories examples" do
4
- let(:attributes) { attributes_for(:category) }
5
- it "lists all the categories for the process" do
6
- within "#categories table" do
7
- expect(page).to have_content(translated(category.name, locale: :en))
8
- end
9
- end
10
-
11
- it "can view a category detail" do
12
- within "#categories table" do
13
- click_on translated(category.name, locale: :en)
14
- end
15
-
16
- expect(page).to have_css("input#category_name_en[value='#{translated(category.name, locale: :en)}']")
17
- expect(page).to have_css("input#category_weight[value='#{category.weight}']")
18
-
19
- expect(page).to have_select(id: "category_parent_id")
20
- end
21
-
22
- it "creates a new category" do
23
- click_on "New category"
24
-
25
- within ".new_category" do
26
- fill_in_i18n(
27
- :category_name,
28
- "#category-name-tabs",
29
- **attributes[:name].except("machine_translations")
30
- )
31
-
32
- find("*[type=submit]").click
33
- end
34
-
35
- expect(page).to have_admin_callout("successfully")
36
-
37
- within "#categories table" do
38
- expect(page).to have_content(translated(attributes[:name]))
39
- end
40
-
41
- visit decidim_admin.root_path
42
- expect(page).to have_content("added the #{translated(attributes[:name])} category to the")
43
- end
44
-
45
- it "updates a category" do
46
- within "#categories" do
47
- within "tr", text: translated(category.name) do
48
- click_on "Edit"
49
- end
50
- end
51
-
52
- within ".edit_category" do
53
- fill_in_i18n(
54
- :category_name,
55
- "#category-name-tabs",
56
- **attributes[:name].except("machine_translations")
57
- )
58
-
59
- find("*[type=submit]").click
60
- end
61
-
62
- expect(page).to have_admin_callout("successfully")
63
-
64
- within "#categories table" do
65
- expect(page).to have_content(translated(attributes[:name]))
66
- end
67
-
68
- visit decidim_admin.root_path
69
- expect(page).to have_content("updated the #{translated(attributes[:name])} category in the")
70
- end
71
-
72
- context "when deleting a category" do
73
- let!(:category2) { create(:category, participatory_space:) }
74
-
75
- context "when the category has no associated content" do
76
- context "when the category has no subcategories" do
77
- before do
78
- visit current_path
79
- end
80
-
81
- it "deletes a category" do
82
- within "tr", text: translated(category2.name) do
83
- accept_confirm { click_on "Delete" }
84
- end
85
-
86
- expect(page).to have_admin_callout("successfully")
87
-
88
- within "#categories table" do
89
- expect(page).to have_no_content(translated(category2.name))
90
- end
91
- end
92
- end
93
-
94
- context "when the category has some subcategories" do
95
- let!(:subcategory) { create(:subcategory, parent: category2) }
96
-
97
- before do
98
- visit current_path
99
- end
100
-
101
- it "deletes a category" do
102
- within "tr", text: translated(category2.name) do
103
- accept_confirm { click_on "Delete" }
104
- end
105
-
106
- expect(page).to have_admin_callout("problem deleting")
107
-
108
- within "#categories table" do
109
- expect(page).to have_content(translated(category2.name))
110
- end
111
- end
112
- end
113
- end
114
-
115
- context "when the category has associated content" do
116
- let!(:component) { create(:component, participatory_space:) }
117
- let!(:dummy_resource) { create(:dummy_resource, component:, category:) }
118
-
119
- it "cannot delete it" do
120
- visit current_path
121
-
122
- within "tr", text: translated(category.name) do
123
- expect(page).to have_no_css("a.action-icon--remove")
124
- end
125
- end
126
- end
127
- end
128
- end