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.
- checksums.yaml +4 -4
- data/app/cells/decidim/admin/multi_select_picker/show.erb +10 -0
- data/app/cells/decidim/admin/multi_select_picker_cell.rb +38 -0
- data/app/commands/decidim/admin/block_user.rb +1 -0
- data/app/commands/decidim/admin/bulk_action.rb +92 -0
- data/app/commands/decidim/admin/bulk_block_users.rb +75 -0
- data/app/commands/decidim/admin/bulk_unblock_users.rb +66 -0
- data/app/commands/decidim/admin/bulk_unreport_users.rb +69 -0
- data/app/commands/decidim/admin/content_blocks/update_content_block.rb +1 -1
- data/app/commands/decidim/admin/create_participatory_space_private_user.rb +3 -1
- data/app/commands/decidim/admin/create_share_token.rb +39 -0
- data/app/commands/decidim/admin/create_taxonomy.rb +23 -0
- data/app/commands/decidim/admin/create_taxonomy_filter.rb +24 -0
- data/app/commands/decidim/admin/destroy_share_token.rb +22 -0
- data/app/commands/decidim/admin/destroy_taxonomy.rb +18 -0
- data/app/commands/decidim/admin/destroy_taxonomy_filter.rb +20 -0
- data/app/commands/decidim/admin/hide_menu_component.rb +37 -0
- data/app/commands/decidim/admin/hide_resource.rb +4 -2
- data/app/commands/decidim/admin/publish_all_participatory_space_private_users.rb +50 -0
- data/app/commands/decidim/admin/publish_component.rb +3 -0
- data/app/commands/decidim/admin/reorder_components.rb +47 -0
- data/app/commands/decidim/admin/reorder_taxonomies.rb +76 -0
- data/app/commands/decidim/admin/unhide_resource.rb +11 -3
- data/app/commands/decidim/admin/unpublish_all_participatory_space_private_users.rb +50 -0
- data/app/commands/decidim/admin/unreport_resource.rb +11 -3
- data/app/commands/decidim/admin/update_component_permissions.rb +53 -13
- data/app/commands/decidim/admin/update_participatory_space_private_user.rb +11 -0
- data/app/commands/decidim/admin/update_share_token.rb +24 -0
- data/app/commands/decidim/admin/update_taxonomy.rb +20 -0
- data/app/commands/decidim/admin/update_taxonomy_filter.rb +28 -0
- data/app/controllers/concerns/decidim/admin/component_taxonomies_helper.rb +19 -0
- data/app/controllers/concerns/decidim/admin/filterable.rb +15 -18
- data/app/controllers/concerns/decidim/admin/has_trashable_resources.rb +170 -0
- data/app/controllers/concerns/decidim/admin/needs_admin_tos_accepted.rb +2 -29
- data/app/controllers/concerns/decidim/admin/participatory_space_admin_context.rb +12 -2
- data/app/controllers/concerns/decidim/admin/taxonomies/filterable.rb +27 -0
- data/app/controllers/decidim/admin/application_controller.rb +1 -2
- data/app/controllers/decidim/admin/areas_controller.rb +1 -0
- data/app/controllers/decidim/admin/block_user_controller.rb +43 -1
- data/app/controllers/decidim/admin/component_permissions_controller.rb +2 -4
- data/app/controllers/decidim/admin/components_controller.rb +50 -9
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +59 -2
- data/app/controllers/decidim/admin/conflicts_controller.rb +1 -1
- data/app/controllers/decidim/admin/global_moderations_controller.rb +4 -0
- data/app/controllers/decidim/admin/impersonations_controller.rb +1 -0
- data/app/controllers/decidim/admin/moderated_users_controller.rb +26 -0
- data/app/controllers/decidim/admin/moderations_controller.rb +18 -0
- data/app/controllers/decidim/admin/newsletters_controller.rb +50 -6
- data/app/controllers/decidim/admin/resource_permissions_controller.rb +1 -1
- data/app/controllers/decidim/admin/scopes_controller.rb +1 -0
- data/app/controllers/decidim/admin/share_tokens_controller.rb +109 -7
- data/app/controllers/decidim/admin/taxonomies_controller.rb +129 -0
- data/app/controllers/decidim/admin/taxonomy_filters_controller.rb +112 -0
- data/app/controllers/decidim/admin/taxonomy_filters_selector_controller.rb +81 -0
- data/app/controllers/decidim/admin/taxonomy_items_controller.rb +91 -0
- data/app/forms/concerns/decidim/has_taxonomy_form_attributes.rb +57 -0
- data/app/forms/decidim/admin/block_users_form.rb +21 -0
- data/app/forms/decidim/admin/help_section_form.rb +1 -1
- data/app/forms/decidim/admin/impersonate_user_form.rb +5 -0
- data/app/forms/decidim/admin/import_example_form.rb +1 -1
- data/app/forms/decidim/admin/newsletter_form.rb +1 -1
- data/app/forms/decidim/admin/organization_appearance_form.rb +2 -2
- data/app/forms/decidim/admin/organization_form.rb +2 -2
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +5 -0
- data/app/forms/decidim/admin/selective_newsletter_form.rb +46 -11
- data/app/forms/decidim/admin/share_token_form.rb +55 -0
- data/app/forms/decidim/admin/static_page_form.rb +1 -1
- data/app/forms/decidim/admin/taxonomy_filter_form.rb +85 -0
- data/app/forms/decidim/admin/taxonomy_form.rb +20 -0
- data/app/forms/decidim/admin/taxonomy_item_form.rb +54 -0
- data/app/forms/decidim/admin/transfer_user_form.rb +15 -0
- data/app/helpers/decidim/admin/application_helper.rb +0 -1
- data/app/helpers/decidim/admin/bulk_actions_helper.rb +0 -31
- data/app/helpers/decidim/admin/moderations/reports_helper.rb +1 -1
- data/app/helpers/decidim/admin/moderations_helper.rb +1 -1
- data/app/helpers/decidim/admin/newsletters_helper.rb +57 -27
- data/app/helpers/decidim/admin/scopes_helper.rb +0 -6
- data/app/helpers/decidim/admin/search_form_helper.rb +1 -1
- data/app/helpers/decidim/admin/settings_helper.rb +85 -11
- data/app/jobs/decidim/admin/newsletter_job.rb +3 -1
- data/app/packs/entrypoints/decidim_admin.js +4 -0
- data/app/packs/src/decidim/admin/application.js +2 -0
- data/app/packs/src/decidim/admin/draggable-table.js +33 -0
- data/app/packs/src/decidim/admin/form.js +0 -1
- data/app/packs/src/decidim/admin/global_moderations.js +186 -0
- data/app/packs/src/decidim/admin/managed_moderated_users.js +186 -0
- data/app/packs/src/decidim/admin/newsletters.js +164 -73
- data/app/packs/src/decidim/admin/proposal_infinite_edit.js +3 -6
- data/app/packs/src/decidim/admin/sortable.js +28 -16
- data/app/packs/src/decidim/admin/taxonomy_filters.js +93 -0
- data/app/packs/stylesheets/decidim/admin/_component-show.scss +66 -5
- data/app/packs/stylesheets/decidim/admin/_legacy_foundation.scss +13 -0
- data/app/packs/stylesheets/decidim/admin/_moderations.scss +8 -0
- data/app/packs/stylesheets/decidim/admin/_select_picker.scss +20 -0
- data/app/packs/stylesheets/decidim/admin/_table-list.scss +22 -0
- data/app/packs/stylesheets/decidim/admin/_taxonomies.scss +74 -0
- data/app/packs/stylesheets/decidim/admin/application.scss +3 -0
- data/app/permissions/decidim/admin/permissions.rb +32 -1
- data/app/queries/decidim/admin/newsletter_recipients.rb +59 -19
- data/app/views/decidim/admin/areas/index.html.erb +3 -0
- data/app/views/decidim/admin/block_user/bulk_new.html.erb +45 -0
- data/app/views/decidim/admin/components/_actions.html.erb +50 -33
- data/app/views/decidim/admin/components/{_component.html.erb → _component_row.html.erb} +10 -5
- data/app/views/decidim/admin/components/_components_table.html.erb +18 -0
- data/app/views/decidim/admin/components/_form.html.erb +0 -12
- data/app/views/decidim/admin/components/_taxonomy_filters_drawer.html.erb +2 -0
- data/app/views/decidim/admin/components/_visibility_label.html.erb +9 -0
- data/app/views/decidim/admin/components/index.html.erb +12 -14
- data/app/views/decidim/admin/components/manage_trash.html.erb +11 -0
- data/app/views/decidim/admin/conflicts/edit.html.erb +21 -11
- data/app/views/decidim/admin/moderated_users/_bulk-actions.html.erb +6 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_block.html.erb +20 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_dropdown.html.erb +40 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_unblock.html.erb +20 -0
- data/app/views/decidim/admin/moderated_users/bulk_actions/_unreport.html.erb +20 -0
- data/app/views/decidim/admin/moderated_users/index.html.erb +15 -7
- data/app/views/decidim/admin/moderations/_bulk-actions.html.erb +7 -0
- data/app/views/decidim/admin/moderations/_moderation-tr.html.erb +50 -0
- data/app/views/decidim/admin/moderations/_moderations-thead.html.erb +18 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_dropdown.html.erb +43 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_hide.html.erb +20 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_unhide.html.erb +20 -0
- data/app/views/decidim/admin/moderations/bulk_actions/_unreport.html.erb +20 -0
- data/app/views/decidim/admin/moderations/index.html.erb +13 -81
- data/app/views/decidim/admin/newsletter_templates/index.html.erb +0 -1
- data/app/views/decidim/admin/newsletters/confirm_recipients.html.erb +64 -0
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +44 -20
- data/app/views/decidim/admin/participatory_space_private_users/_form.html.erb +6 -0
- data/app/views/decidim/admin/participatory_space_private_users/edit.html.erb +19 -0
- data/app/views/decidim/admin/participatory_space_private_users/index.html.erb +15 -1
- data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +5 -0
- data/app/views/decidim/admin/resource_permissions/edit.html.erb +2 -2
- data/app/views/decidim/admin/scope_types/index.html.erb +3 -0
- data/app/views/decidim/admin/scopes/index.html.erb +3 -0
- data/app/views/decidim/admin/share_tokens/_form.html.erb +52 -0
- data/app/views/decidim/admin/share_tokens/edit.html.erb +33 -0
- data/app/views/decidim/admin/share_tokens/index.html.erb +47 -0
- data/app/views/decidim/admin/share_tokens/new.html.erb +69 -0
- data/app/views/decidim/admin/shared/landing_page_content_blocks/edit.html.erb +1 -1
- data/app/views/decidim/admin/taxonomies/_filters.html.erb +19 -0
- data/app/views/decidim/admin/taxonomies/_form.html.erb +5 -0
- data/app/views/decidim/admin/taxonomies/_row.html.erb +40 -0
- data/app/views/decidim/admin/taxonomies/_row_children.html.erb +8 -0
- data/app/views/decidim/admin/taxonomies/_table.html.erb +86 -0
- data/app/views/decidim/admin/taxonomies/_taxonomy_actions.html.erb +15 -0
- data/app/views/decidim/admin/taxonomies/edit.html.erb +87 -0
- data/app/views/decidim/admin/taxonomies/index.html.erb +28 -0
- data/app/views/decidim/admin/taxonomies/new.html.erb +16 -0
- data/app/views/decidim/admin/taxonomy_filters/_check_boxes.html.erb +10 -0
- data/app/views/decidim/admin/taxonomy_filters/_form.html.erb +96 -0
- data/app/views/decidim/admin/taxonomy_filters/_table.html.erb +33 -0
- data/app/views/decidim/admin/taxonomy_filters/edit.html.erb +22 -0
- data/app/views/decidim/admin/taxonomy_filters/index.html.erb +26 -0
- data/app/views/decidim/admin/taxonomy_filters/new.html.erb +32 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/_check_boxes.html.erb +7 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/_component_table.html.erb +25 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/_taxonomies_select.html.erb +16 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/index.html.erb +1 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/new.html.erb +27 -0
- data/app/views/decidim/admin/taxonomy_filters_selector/show.html.erb +18 -0
- data/app/views/decidim/admin/taxonomy_items/_form.html.erb +8 -0
- data/app/views/decidim/admin/taxonomy_items/edit.html.erb +12 -0
- data/app/views/decidim/admin/taxonomy_items/new.html.erb +12 -0
- data/app/views/layouts/decidim/admin/taxonomy_filters.html.erb +17 -0
- data/app/views/layouts/decidim/admin/taxonomy_filters_selector.html.erb +10 -0
- data/config/locales/ar.yml +91 -36
- data/config/locales/bg.yml +48 -51
- data/config/locales/bn-BD.yml +1 -0
- data/config/locales/bs-BA.yml +499 -0
- data/config/locales/ca.yml +300 -50
- data/config/locales/cs.yml +298 -46
- data/config/locales/de.yml +300 -50
- data/config/locales/el.yml +1 -50
- data/config/locales/en.yml +300 -50
- data/config/locales/es-MX.yml +298 -48
- data/config/locales/es-PY.yml +298 -48
- data/config/locales/es.yml +298 -48
- data/config/locales/eu.yml +433 -171
- data/config/locales/fi-plain.yml +298 -48
- data/config/locales/fi.yml +315 -65
- data/config/locales/fr-CA.yml +183 -47
- data/config/locales/fr.yml +183 -47
- data/config/locales/ga-IE.yml +0 -23
- data/config/locales/gl.yml +1 -46
- data/config/locales/hu.yml +1 -51
- data/config/locales/id-ID.yml +0 -20
- data/config/locales/is-IS.yml +0 -18
- data/config/locales/it.yml +1 -46
- data/config/locales/ja.yml +303 -55
- data/config/locales/kaa.yml +0 -10
- data/config/locales/ko.yml +0 -50
- data/config/locales/lb.yml +1 -46
- data/config/locales/lt.yml +1 -50
- data/config/locales/lv.yml +1 -27
- data/config/locales/nl.yml +1 -46
- data/config/locales/no.yml +1 -46
- data/config/locales/pl.yml +3 -51
- data/config/locales/pt-BR.yml +38 -50
- data/config/locales/pt.yml +30 -46
- data/config/locales/ro-RO.yml +35 -50
- data/config/locales/ru.yml +1 -22
- data/config/locales/sk.yml +1 -27
- data/config/locales/sl.yml +0 -7
- data/config/locales/sq-AL.yml +0 -25
- data/config/locales/sr-CS.yml +1 -27
- data/config/locales/sv.yml +297 -47
- data/config/locales/tr-TR.yml +1 -44
- data/config/locales/uk.yml +0 -20
- data/config/locales/zh-CN.yml +0 -44
- data/config/locales/zh-TW.yml +1 -50
- data/config/routes.rb +14 -13
- data/decidim-admin.gemspec +2 -2
- data/lib/decidim/admin/engine.rb +3 -1
- data/lib/decidim/admin/import/creator.rb +2 -6
- data/lib/decidim/admin/import/readers/json.rb +1 -1
- data/lib/decidim/admin/menu.rb +9 -1
- data/lib/decidim/admin/search_form_builder.rb +1 -1
- data/lib/decidim/admin/test/destroy_admin_examples.rb +2 -2
- data/lib/decidim/admin/test/filterable_examples.rb +100 -9
- data/lib/decidim/admin/test/forms/attachment_collection_form_examples.rb +1 -1
- data/lib/decidim/admin/test/forms/attachment_form_examples.rb +1 -1
- data/lib/decidim/admin/test/invite_participatory_space_admins_shared_examples.rb +2 -4
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +5 -5
- data/lib/decidim/admin/test/manage_hide_content_examples.rb +0 -1
- data/lib/decidim/admin/test/manage_moderations_examples.rb +3 -3
- data/lib/decidim/admin/test/manage_resource_soft_deletion_examples.rb +113 -0
- data/lib/decidim/admin/test/manage_taxonomy_filters_examples.rb +127 -0
- data/lib/decidim/admin/test/taxonomy_filters_examples.rb +32 -0
- data/lib/decidim/admin/test.rb +3 -1
- data/lib/decidim/admin/version.rb +1 -1
- metadata +106 -30
- data/app/commands/decidim/admin/create_category.rb +0 -15
- data/app/commands/decidim/admin/destroy_category.rb +0 -15
- data/app/commands/decidim/admin/destroy_component.rb +0 -19
- data/app/commands/decidim/admin/update_category.rb +0 -11
- data/app/controllers/decidim/admin/categories_controller.rb +0 -98
- data/app/forms/decidim/admin/category_form.rb +0 -32
- data/app/helpers/decidim/admin/resource_scope_helper.rb +0 -52
- data/app/packs/src/decidim/admin/scope_picker_enabler.component.js +0 -12
- data/app/views/decidim/admin/categories/_form.html.erb +0 -18
- data/app/views/decidim/admin/categories/edit.html.erb +0 -19
- data/app/views/decidim/admin/categories/index.html.erb +0 -65
- data/app/views/decidim/admin/categories/new.html.erb +0 -19
- data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +0 -45
- data/lib/decidim/admin/test/commands/create_category_examples.rb +0 -74
- data/lib/decidim/admin/test/commands/destroy_category_examples.rb +0 -83
- data/lib/decidim/admin/test/commands/update_category_examples.rb +0 -76
- data/lib/decidim/admin/test/forms/category_form_examples.rb +0 -70
- 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
|