decidim-admin 0.20.1 → 0.23.1
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.
Potentially problematic release.
This version of decidim-admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/assets/javascripts/decidim/admin/application.js.es6 +8 -0
- data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +52 -0
- data/app/assets/javascripts/decidim/admin/bundle.js +26 -32
- data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/admin/choose_language.js +12 -0
- data/app/assets/javascripts/decidim/admin/dynamic_fields.component.js.es6 +24 -5
- data/app/assets/javascripts/decidim/admin/form.js.es6 +24 -10
- data/app/assets/javascripts/decidim/admin/gallery.js.es6 +5 -0
- data/app/assets/javascripts/decidim/admin/newsletters.js.es6 +12 -0
- data/app/assets/javascripts/decidim/admin/officializations.js.es6 +20 -0
- data/app/assets/javascripts/decidim/admin/scope_picker_enabler.component.js.es6 +14 -0
- data/app/assets/stylesheets/decidim/admin/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/_variables.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/extra/_action-icon.scss +6 -0
- data/app/assets/stylesheets/decidim/admin/extra/_cards.scss +11 -0
- data/app/assets/stylesheets/decidim/admin/extra/_newsletter-templates-gallery.scss +3 -0
- data/app/assets/stylesheets/decidim/admin/extra/_organization-appearance.scss +141 -0
- data/app/assets/stylesheets/decidim/admin/extra/_show_email.scss +31 -0
- data/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +4 -0
- data/app/assets/stylesheets/decidim/admin/modules/_buttons.scss +15 -1
- data/app/assets/stylesheets/decidim/admin/modules/_callouts.scss +11 -0
- data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +13 -2
- data/app/assets/stylesheets/decidim/admin/modules/_filters.scss +78 -1
- data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +16 -2
- data/app/assets/stylesheets/decidim/admin/modules/_import_result.scss +10 -0
- data/app/assets/stylesheets/decidim/admin/modules/_layout.scss +1 -1
- data/app/assets/stylesheets/decidim/admin/modules/_loading-spinner.scss +19 -0
- data/app/assets/stylesheets/decidim/admin/modules/_main-nav.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_modules.scss +5 -1
- data/app/assets/stylesheets/decidim/admin/modules/_process-header.scss +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_secondary-nav.scss +5 -2
- data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +23 -7
- data/app/assets/stylesheets/decidim/admin/modules/_tabs.scss +7 -0
- data/app/assets/stylesheets/decidim/admin/modules/_users_statistics.scss +18 -0
- data/app/assets/stylesheets/decidim/admin/utils/_mixins.scss +42 -0
- data/app/assets/stylesheets/decidim/admin/utils/_settings.scss +4 -1
- data/app/cells/decidim/admin/content_block/show.erb +2 -2
- data/app/cells/decidim/admin/results_per_page/show.erb +16 -0
- data/app/cells/decidim/admin/results_per_page_cell.rb +14 -0
- data/app/commands/decidim/admin/create_attachment.rb +2 -2
- data/app/commands/decidim/admin/create_newsletter.rb +34 -9
- data/app/commands/decidim/admin/deliver_newsletter.rb +1 -1
- data/app/commands/decidim/admin/destroy_share_token.rb +46 -0
- data/app/commands/decidim/admin/reorder_content_blocks.rb +1 -1
- data/app/commands/decidim/admin/update_component.rb +27 -3
- data/app/commands/decidim/admin/update_content_block.rb +25 -1
- data/app/commands/decidim/admin/update_newsletter.rb +31 -9
- data/app/commands/decidim/admin/update_organization.rb +15 -1
- data/app/commands/decidim/admin/update_organization_appearance.rb +3 -1
- data/app/controllers/concerns/decidim/admin/filterable.rb +152 -0
- data/app/controllers/concerns/decidim/admin/officializations/filterable.rb +31 -0
- data/app/controllers/concerns/decidim/admin/paginable.rb +20 -0
- data/app/controllers/concerns/decidim/admin/participatory_space_export.rb +8 -2
- data/app/controllers/decidim/admin/admin_terms_controller.rb +20 -0
- data/app/controllers/decidim/admin/application_controller.rb +3 -0
- data/app/controllers/decidim/admin/authorization_workflows_controller.rb +6 -0
- data/app/controllers/decidim/admin/components/base_controller.rb +5 -1
- data/app/controllers/decidim/admin/components_controller.rb +30 -23
- data/app/controllers/decidim/admin/concerns/has_private_users.rb +4 -0
- data/app/controllers/decidim/admin/dashboard_controller.rb +33 -1
- data/app/controllers/decidim/admin/metrics_controller.rb +22 -0
- data/app/controllers/decidim/admin/newsletter_templates_controller.rb +41 -0
- data/app/controllers/decidim/admin/newsletters_controller.rb +43 -4
- data/app/controllers/decidim/admin/officializations_controller.rb +15 -6
- data/app/controllers/decidim/admin/organization_appearance_controller.rb +1 -0
- data/app/controllers/decidim/admin/organization_controller.rb +4 -3
- data/app/controllers/decidim/admin/organization_homepage_content_blocks_controller.rb +2 -1
- data/app/controllers/decidim/admin/share_tokens_controller.rb +30 -0
- data/app/forms/decidim/admin/attachment_form.rb +3 -0
- data/app/forms/decidim/admin/component_form.rb +5 -22
- data/app/forms/decidim/admin/newsletter_form.rb +15 -3
- data/app/forms/decidim/admin/organization_appearance_form.rb +7 -4
- data/app/forms/decidim/admin/organization_form.rb +27 -0
- data/app/forms/decidim/admin/participatory_space_private_user_csv_import_form.rb +14 -0
- data/app/forms/decidim/admin/participatory_space_private_user_form.rb +8 -2
- data/app/frontend/components/autocomplete.component.test.tsx +2 -1
- data/app/frontend/components/autocomplete.component.tsx +29 -0
- data/app/helpers/decidim/admin/admin_terms_helper.rb +47 -0
- data/app/helpers/decidim/admin/application_helper.rb +2 -0
- data/app/helpers/decidim/admin/dashboard_helper.rb +25 -0
- data/app/helpers/decidim/admin/filterable_helper.rb +129 -0
- data/app/helpers/decidim/admin/icon_link_helper.rb +1 -1
- data/app/helpers/decidim/admin/newsletters_helper.rb +20 -0
- data/app/helpers/decidim/admin/paginable/per_page_helper.rb +22 -0
- data/app/helpers/decidim/admin/resource_scope_helper.rb +43 -0
- data/app/helpers/decidim/admin/scopes_helper.rb +6 -0
- data/app/helpers/decidim/admin/settings_helper.rb +56 -47
- data/app/helpers/decidim/admin/uploader_image_dimensions_helper.rb +30 -0
- data/app/helpers/decidim/admin/user_roles_helper.rb +19 -0
- data/app/models/decidim/admin/fake_newsletter.rb +49 -0
- data/app/permissions/decidim/admin/permissions.rb +30 -7
- data/app/presenters/decidim/admin/dashboard_metric_charts_presenter.rb +57 -0
- data/app/queries/decidim/admin/active_users_counter.rb +35 -0
- data/app/queries/decidim/admin/newsletter_recipients.rb +20 -9
- data/app/views/decidim/admin/admin_terms/show.html.erb +26 -0
- data/app/views/decidim/admin/attachment_collections/index.html.erb +1 -1
- data/app/views/decidim/admin/authorization_workflows/index.html.erb +1 -0
- data/app/views/decidim/admin/categories/index.html.erb +1 -1
- data/app/views/decidim/admin/components/_component.html.erb +40 -33
- data/app/views/decidim/admin/components/_form.html.erb +4 -0
- data/app/views/decidim/admin/components/_settings_fields.html.erb +2 -2
- data/app/views/decidim/admin/components/index.html.erb +11 -8
- data/app/views/decidim/admin/dashboard/show.html.erb +49 -9
- data/app/views/decidim/admin/exports/_dropdown.html.erb +6 -2
- data/app/views/decidim/admin/impersonatable_users/index.html.erb +2 -2
- data/app/views/decidim/admin/metrics/_metrics.html.erb +21 -0
- data/app/views/decidim/admin/metrics/index.html.erb +7 -0
- data/app/views/decidim/admin/newsletter_templates/index.html.erb +28 -0
- data/app/views/decidim/admin/newsletter_templates/show.html.erb +12 -0
- data/app/views/decidim/admin/newsletters/_form.html.erb +1 -7
- data/app/views/decidim/admin/newsletters/edit.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/index.html.erb +9 -3
- data/app/views/decidim/admin/newsletters/new.html.erb +1 -1
- data/app/views/decidim/admin/newsletters/select_recipients_to_deliver.html.erb +4 -4
- data/app/views/decidim/admin/officializations/_show_email_modal.html.erb +31 -0
- data/app/views/decidim/admin/officializations/index.html.erb +9 -41
- data/app/views/decidim/admin/officializations/show_email.html.erb +2 -0
- data/app/views/decidim/admin/organization/_form.html.erb +37 -0
- data/app/views/decidim/admin/organization_appearance/_form.html.erb +2 -72
- data/app/views/decidim/admin/organization_appearance/form/_colors.html.erb +23 -0
- data/app/views/decidim/admin/organization_appearance/form/_images.html.erb +38 -0
- data/app/views/decidim/admin/organization_appearance/form/_minimap.html.erb +46 -0
- data/app/views/decidim/admin/resource_permissions/_options_form.html.erb +1 -1
- data/app/views/decidim/admin/share_tokens/_share_tokens.html.erb +57 -0
- data/app/views/decidim/admin/shared/_filters.html.erb +40 -0
- data/app/views/decidim/admin/shared/_gallery.html.erb +21 -0
- data/app/views/decidim/admin/static_pages/_form.html.erb +1 -1
- data/app/views/decidim/admin/user_groups/index.html.erb +4 -4
- data/app/views/decidim/admin/users_statistics/_users_count.html.erb +39 -0
- data/app/views/layouts/decidim/admin/_application.html.erb +2 -1
- data/app/views/layouts/decidim/admin/_header.html.erb +3 -0
- data/app/views/layouts/decidim/admin/_title_bar.html.erb +20 -10
- data/app/views/layouts/decidim/admin/newsletters.erb +1 -1
- data/config/locales/am-ET.yml +1 -0
- data/config/locales/ar.yml +52 -47
- data/config/locales/bg-BG.yml +16 -0
- data/config/locales/bg.yml +135 -0
- data/config/locales/ca.yml +127 -48
- data/config/locales/cs.yml +182 -103
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/da.yml +1 -0
- data/config/locales/de.yml +145 -47
- data/config/locales/el.yml +819 -0
- data/config/locales/en.yml +127 -48
- data/config/locales/eo-UY.yml +0 -1
- data/config/locales/eo.yml +51 -0
- data/config/locales/es-MX.yml +127 -48
- data/config/locales/es-PY.yml +127 -48
- data/config/locales/es.yml +127 -48
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/et.yml +1 -0
- data/config/locales/eu.yml +21 -47
- data/config/locales/fi-plain.yml +127 -48
- data/config/locales/fi.yml +140 -61
- data/config/locales/fr-CA.yml +849 -0
- data/config/locales/fr.yml +133 -53
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +21 -47
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hr.yml +1 -0
- data/config/locales/hu.yml +100 -48
- data/config/locales/id-ID.yml +21 -47
- data/config/locales/is-IS.yml +19 -45
- data/config/locales/is.yml +568 -0
- data/config/locales/it.yml +132 -83
- data/config/locales/ja-JP.yml +855 -0
- data/config/locales/ja.yml +849 -0
- data/config/locales/ko-KR.yml +1 -0
- data/config/locales/ko.yml +1 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lt.yml +1 -0
- data/config/locales/lv.yml +799 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/mt.yml +1 -0
- data/config/locales/nl.yml +102 -48
- data/config/locales/no.yml +147 -84
- data/config/locales/om-ET.yml +1 -0
- data/config/locales/pl.yml +364 -238
- data/config/locales/pt-BR.yml +22 -48
- data/config/locales/pt.yml +334 -237
- data/config/locales/ro-RO.yml +814 -0
- data/config/locales/ru.yml +20 -46
- data/config/locales/sk-SK.yml +823 -0
- data/config/locales/sk.yml +806 -0
- data/config/locales/sl.yml +166 -0
- data/config/locales/so-SO.yml +1 -0
- data/config/locales/sr-CS.yml +590 -0
- data/config/locales/sv.yml +140 -55
- data/config/locales/ti-ER.yml +1 -0
- data/config/locales/tr-TR.yml +21 -47
- data/config/locales/uk.yml +19 -48
- data/config/locales/vi-VN.yml +1 -0
- data/config/locales/vi.yml +1 -0
- data/config/locales/zh-CN.yml +849 -0
- data/config/locales/zh-TW.yml +1 -0
- data/config/routes.rb +20 -3
- data/db/migrate/20191118112040_add_accepted_admin_terms_at_field_to_users.rb +7 -0
- data/lib/decidim/admin.rb +17 -0
- data/lib/decidim/admin/engine.rb +12 -9
- data/lib/decidim/admin/form_builder.rb +7 -2
- data/lib/decidim/admin/test.rb +2 -0
- data/lib/decidim/admin/test/filterable_examples.rb +129 -0
- data/lib/decidim/admin/test/manage_attachment_collections_examples.rb +1 -1
- data/lib/decidim/admin/test/manage_component_permissions_examples.rb +15 -15
- data/lib/decidim/admin/test/manage_paginated_collection_examples.rb +22 -0
- data/lib/decidim/admin/version.rb +1 -1
- data/vendor/assets/javascripts/jquery.serializejson.js +344 -0
- metadata +98 -30
- data/app/commands/decidim/admin/create_oauth_application.rb +0 -36
- data/app/commands/decidim/admin/destroy_oauth_application.rb +0 -39
- data/app/commands/decidim/admin/update_oauth_application.rb +0 -39
- data/app/controllers/decidim/admin/oauth_applications_controller.rb +0 -90
- data/app/forms/decidim/admin/oauth_application_form.rb +0 -32
- data/app/views/decidim/admin/oauth_applications/_form.html.erb +0 -19
- data/app/views/decidim/admin/oauth_applications/edit.html.erb +0 -13
- data/app/views/decidim/admin/oauth_applications/index.html.erb +0 -40
- data/app/views/decidim/admin/oauth_applications/new.html.erb +0 -13
- data/app/views/decidim/admin/oauth_applications/show.html.erb +0 -27
@@ -11,25 +11,47 @@ module Decidim
|
|
11
11
|
# user - The user that updates the newsletter.
|
12
12
|
def initialize(newsletter, form, user)
|
13
13
|
@newsletter = newsletter
|
14
|
+
@content_block = newsletter.template
|
14
15
|
@form = form
|
15
16
|
@user = user
|
16
17
|
@organization = user.organization
|
17
18
|
end
|
18
19
|
|
19
20
|
def call
|
20
|
-
return broadcast(:invalid) unless
|
21
|
-
return broadcast(:invalid) if
|
22
|
-
return broadcast(:invalid) unless
|
21
|
+
return broadcast(:invalid) unless form.valid?
|
22
|
+
return broadcast(:invalid) if newsletter.sent?
|
23
|
+
return broadcast(:invalid) unless organization == newsletter.organization
|
23
24
|
|
25
|
+
transaction do
|
26
|
+
update_newsletter
|
27
|
+
update_content_block
|
28
|
+
end
|
29
|
+
|
30
|
+
broadcast(:ok, newsletter)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :user, :newsletter, :content_block, :organization, :form
|
36
|
+
|
37
|
+
def update_newsletter
|
24
38
|
@newsletter = Decidim.traceability.update!(
|
25
|
-
|
26
|
-
|
27
|
-
subject:
|
28
|
-
|
29
|
-
author: @user
|
39
|
+
newsletter,
|
40
|
+
user,
|
41
|
+
subject: form.subject,
|
42
|
+
author: user
|
30
43
|
)
|
44
|
+
end
|
31
45
|
|
32
|
-
|
46
|
+
def update_content_block
|
47
|
+
UpdateContentBlock.call(form, content_block, user) do
|
48
|
+
on(:ok) do |content_block|
|
49
|
+
@content_block = content_block
|
50
|
+
end
|
51
|
+
on(:invalid) do
|
52
|
+
raise "There was a problem persisting the changes to the content block"
|
53
|
+
end
|
54
|
+
end
|
33
55
|
end
|
34
56
|
end
|
35
57
|
end
|
@@ -45,14 +45,20 @@ module Decidim
|
|
45
45
|
name: form.name,
|
46
46
|
default_locale: form.default_locale,
|
47
47
|
reference_prefix: form.reference_prefix,
|
48
|
+
time_zone: form.time_zone,
|
48
49
|
twitter_handler: form.twitter_handler,
|
49
50
|
facebook_handler: form.facebook_handler,
|
50
51
|
instagram_handler: form.instagram_handler,
|
51
52
|
youtube_handler: form.youtube_handler,
|
52
53
|
github_handler: form.github_handler,
|
53
54
|
badges_enabled: form.badges_enabled,
|
54
|
-
user_groups_enabled: form.user_groups_enabled
|
55
|
+
user_groups_enabled: form.user_groups_enabled,
|
56
|
+
comments_max_length: form.comments_max_length,
|
57
|
+
enable_machine_translations: form.enable_machine_translations,
|
58
|
+
admin_terms_of_use_body: form.admin_terms_of_use_body,
|
59
|
+
rich_text_editor_in_public_views: form.rich_text_editor_in_public_views
|
55
60
|
}.merge(welcome_notification_attributes)
|
61
|
+
.merge(machine_translation_attributes || {})
|
56
62
|
end
|
57
63
|
|
58
64
|
def welcome_notification_attributes
|
@@ -62,6 +68,14 @@ module Decidim
|
|
62
68
|
welcome_notification_body: form.customize_welcome_notification ? form.welcome_notification_body : nil
|
63
69
|
}
|
64
70
|
end
|
71
|
+
|
72
|
+
def machine_translation_attributes
|
73
|
+
return unless Decidim.config.enable_machine_translations
|
74
|
+
|
75
|
+
{
|
76
|
+
machine_translation_display_priority: form.machine_translation_display_priority
|
77
|
+
}
|
78
|
+
end
|
65
79
|
end
|
66
80
|
end
|
67
81
|
end
|
@@ -102,7 +102,9 @@ module Decidim
|
|
102
102
|
secondary: form.secondary_color,
|
103
103
|
success: form.success_color,
|
104
104
|
warning: form.warning_color,
|
105
|
-
alert: form.alert_color
|
105
|
+
alert: form.alert_color,
|
106
|
+
highlight: form.highlight_color,
|
107
|
+
"highlight-alternative": form.highlight_alternative_color
|
106
108
|
}
|
107
109
|
}
|
108
110
|
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Admin
|
7
|
+
# Common logic to filter admin resources.
|
8
|
+
module Filterable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Admin::Paginable
|
13
|
+
include Decidim::TranslatableAttributes
|
14
|
+
|
15
|
+
helper Decidim::Admin::FilterableHelper
|
16
|
+
|
17
|
+
helper_method :collection_name,
|
18
|
+
:extra_allowed_params,
|
19
|
+
:extra_filters,
|
20
|
+
:filters,
|
21
|
+
:filters_with_values,
|
22
|
+
:find_dynamic_translation,
|
23
|
+
:query,
|
24
|
+
:query_params,
|
25
|
+
:query_params_with,
|
26
|
+
:query_params_without,
|
27
|
+
:ransack_params,
|
28
|
+
:search_field_predicate
|
29
|
+
|
30
|
+
delegate :categories, to: :current_component
|
31
|
+
delegate :scopes, to: :current_organization
|
32
|
+
|
33
|
+
def query
|
34
|
+
@query ||= base_query.ransack(ransack_params)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def filtered_collection
|
40
|
+
paginate(query.result)
|
41
|
+
end
|
42
|
+
|
43
|
+
def base_query
|
44
|
+
raise NotImplementedError, "A base query is needed to filter admin resources"
|
45
|
+
end
|
46
|
+
|
47
|
+
def query_params
|
48
|
+
params.permit(*allowed_query_params).to_h.deep_symbolize_keys
|
49
|
+
end
|
50
|
+
|
51
|
+
def allowed_query_params
|
52
|
+
[*extra_allowed_params, q: {}]
|
53
|
+
end
|
54
|
+
|
55
|
+
# Non ransack params (outside :q) to be allowed in the query links.
|
56
|
+
# Also, used in FilterableHelper#applied_filters_hidden_field_tags
|
57
|
+
# to ensure that these params are kept in the search_form_for.
|
58
|
+
def extra_allowed_params
|
59
|
+
[:per_page]
|
60
|
+
end
|
61
|
+
|
62
|
+
def ransack_params
|
63
|
+
query_params[:q] || {}
|
64
|
+
end
|
65
|
+
|
66
|
+
# For injecting ransack params while keeping query params in links.
|
67
|
+
def query_params_with(hash)
|
68
|
+
query_params.merge(q: ransack_params.merge(hash))
|
69
|
+
end
|
70
|
+
|
71
|
+
# For rejecting ransack params while keeping query params in links.
|
72
|
+
def query_params_without(*filters)
|
73
|
+
query_params.merge(q: ransack_params.except(*filters))
|
74
|
+
end
|
75
|
+
|
76
|
+
# Ransack predicate to use in the search_form_for.
|
77
|
+
def search_field_predicate
|
78
|
+
:title_cont
|
79
|
+
end
|
80
|
+
|
81
|
+
# Informs which filters are being used IN the dropdown.
|
82
|
+
# Array<Symbol> of ransack params (inside :q) keys used in:
|
83
|
+
# - FilterableHelper#applied_filters_tags
|
84
|
+
# To build the tags that inform which filters are being applied and
|
85
|
+
# that allow to discard them.
|
86
|
+
# - FilterableHelper#applied_filters_hidden_field_tags
|
87
|
+
# To ensure that filters are kept in the search_form_for.
|
88
|
+
def filters
|
89
|
+
[:private_space_eq, :published_at_null]
|
90
|
+
end
|
91
|
+
|
92
|
+
# Informs which filters are being used OUTSIDE the dropdown.
|
93
|
+
# Optional Array<Symbol> of ransack params (inside :q) keys
|
94
|
+
# used in FilterableHelper#applied_filters_hidden_field_tags
|
95
|
+
# to ensure that these filters are kept in the search_form_for.
|
96
|
+
def extra_filters
|
97
|
+
[]
|
98
|
+
end
|
99
|
+
|
100
|
+
# A Hash of filters as Symbol and its options as Array or Hash.
|
101
|
+
# Needed to build the tree of links used to build the dropdown submenu.
|
102
|
+
# Array values are used to build simple dropdown submenus with one level.
|
103
|
+
# Hash values are used to build nested dropdown submenus with many levels.
|
104
|
+
# By default, uses the Symbols in `filters` as keys and injects an Array
|
105
|
+
# with true and false as values. If these values fit your filtering needs,
|
106
|
+
# you won't have to declare a `filters_with_values` method in your concern.
|
107
|
+
def filters_with_values
|
108
|
+
filters.each_with_object({}) do |filter, hash|
|
109
|
+
hash[filter] = [true, false]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Plural model name. Used in search_field placeholder.
|
114
|
+
def collection_name
|
115
|
+
query.klass.model_name.human(count: 2)
|
116
|
+
end
|
117
|
+
|
118
|
+
# A tree of Category IDs. Leaves are `nil`.
|
119
|
+
def category_ids_hash(categories)
|
120
|
+
categories.each_with_object({}) do |category, hash|
|
121
|
+
hash[category.id] = category.subcategories.any? ? category_ids_hash(category.subcategories) : nil
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# A tree of Scope IDs. Leaves are `nil`.
|
126
|
+
def scope_ids_hash(scopes)
|
127
|
+
scopes.each_with_object({}) do |scope, hash|
|
128
|
+
hash[scope.id] = scope.children.any? ? scope_ids_hash(scope.children) : nil
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Array<Symbol> of filters that implement a method to find translations.
|
133
|
+
# Useful when translations cannot be found in i18n or come from a Model.
|
134
|
+
def dynamically_translated_filters
|
135
|
+
[:scope_id_eq, :category_id_eq]
|
136
|
+
end
|
137
|
+
|
138
|
+
def find_dynamic_translation(filter, value)
|
139
|
+
send("translated_#{filter}", value) if filter.in?(dynamically_translated_filters)
|
140
|
+
end
|
141
|
+
|
142
|
+
def translated_scope_id_eq(id)
|
143
|
+
translated_attribute(scopes.find_by(id: id).name)
|
144
|
+
end
|
145
|
+
|
146
|
+
def translated_category_id_eq(id)
|
147
|
+
translated_attribute(categories.find_by(id: id).name)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Admin
|
7
|
+
module Officializations
|
8
|
+
module Filterable
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Admin::Filterable
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def base_query
|
17
|
+
collection
|
18
|
+
end
|
19
|
+
|
20
|
+
def search_field_predicate
|
21
|
+
:name_or_nickname_or_email_cont
|
22
|
+
end
|
23
|
+
|
24
|
+
def filters
|
25
|
+
[:officialized_at_null]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Admin
|
7
|
+
module Paginable
|
8
|
+
# Common logic to paginate admin resources
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include Decidim::Paginable
|
13
|
+
|
14
|
+
def per_page
|
15
|
+
params[:per_page].present? ? params[:per_page].to_i : Decidim::Admin.per_page_range.first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -11,19 +11,25 @@ module Decidim
|
|
11
11
|
def create
|
12
12
|
enforce_permission_to :create, :export_space, participatory_space: exportable_space
|
13
13
|
|
14
|
-
ExportParticipatorySpaceJob.perform_later(current_user, exportable_space,
|
14
|
+
ExportParticipatorySpaceJob.perform_later(current_user, exportable_space, manifest_name, default_format)
|
15
15
|
|
16
16
|
flash[:notice] = t("decidim.admin.exports.notice")
|
17
17
|
|
18
18
|
redirect_back(fallback_location: after_export_path)
|
19
19
|
end
|
20
20
|
|
21
|
-
# Public:
|
21
|
+
# Public: To be implemented at the controller. You need to
|
22
22
|
# return the space that will be exported.
|
23
23
|
def exportable_space
|
24
24
|
raise NotImplementedError
|
25
25
|
end
|
26
26
|
|
27
|
+
# Public: To be implemented at the controller. You need to
|
28
|
+
# return the plural of the name of the space that will be exported.
|
29
|
+
def manifest_name
|
30
|
+
raise NotImplementedError
|
31
|
+
end
|
32
|
+
|
27
33
|
# Public: Returns a String or Object that will be passed to `redirect_to` after
|
28
34
|
# exporing a space. By default it redirects to the root_path.
|
29
35
|
#
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Admin
|
5
|
+
# The controller to handle the Admin
|
6
|
+
# Terms of use agreement.
|
7
|
+
class AdminTermsController < Decidim::Admin::ApplicationController
|
8
|
+
def accept
|
9
|
+
current_user.admin_terms_accepted_at = Time.current
|
10
|
+
if current_user.save!
|
11
|
+
flash[:notice] = t("accept.success", scope: "decidim.admin.admin_terms_of_use")
|
12
|
+
redirect_to decidim_admin.root_path
|
13
|
+
else
|
14
|
+
flash[:alert] = t("accept.error", scope: "decidim.admin.admin_terms_of_use")
|
15
|
+
redirect_to decidim_admin.admin_terms_show_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,8 +6,10 @@ module Decidim
|
|
6
6
|
class ApplicationController < ::DecidimController
|
7
7
|
include NeedsOrganization
|
8
8
|
include NeedsPermission
|
9
|
+
include NeedsSnippets
|
9
10
|
include FormFactory
|
10
11
|
include LocaleSwitcher
|
12
|
+
include UseOrganizationTimeZone
|
11
13
|
include PayloadInfo
|
12
14
|
include HttpCachingDisabler
|
13
15
|
|
@@ -17,6 +19,7 @@ module Decidim
|
|
17
19
|
helper Decidim::Admin::IconLinkHelper
|
18
20
|
helper Decidim::Admin::MenuHelper
|
19
21
|
helper Decidim::Admin::ScopesHelper
|
22
|
+
helper Decidim::Admin::Paginable::PerPageHelper
|
20
23
|
helper Decidim::DecidimFormHelper
|
21
24
|
helper Decidim::ReplaceButtonsHelper
|
22
25
|
helper Decidim::ScopesHelper
|
@@ -9,6 +9,12 @@ module Decidim
|
|
9
9
|
enforce_permission_to :index, :authorization_workflow
|
10
10
|
|
11
11
|
@workflows = Decidim::Verifications.admin_workflows
|
12
|
+
|
13
|
+
# Decidim::Verifications::Authorizations Query
|
14
|
+
@authorizations = Decidim::Verifications::Authorizations.new(
|
15
|
+
organization: current_organization,
|
16
|
+
granted: true
|
17
|
+
).query
|
12
18
|
end
|
13
19
|
end
|
14
20
|
end
|
@@ -22,7 +22,7 @@ module Decidim
|
|
22
22
|
:parent_path
|
23
23
|
|
24
24
|
before_action except: [:index, :show] do
|
25
|
-
enforce_permission_to :manage, :component, component: current_component
|
25
|
+
enforce_permission_to :manage, :component, component: current_component unless skip_manage_component_permission
|
26
26
|
end
|
27
27
|
|
28
28
|
before_action on: [:index, :show] do
|
@@ -59,6 +59,10 @@ module Decidim
|
|
59
59
|
def parent_path
|
60
60
|
@parent_path ||= ::Decidim::EngineRouter.admin_proxy(current_participatory_space).components_path
|
61
61
|
end
|
62
|
+
|
63
|
+
def skip_manage_component_permission
|
64
|
+
false
|
65
|
+
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
@@ -20,14 +20,17 @@ module Decidim
|
|
20
20
|
@component = Component.new(
|
21
21
|
name: default_name(manifest),
|
22
22
|
manifest_name: params[:type],
|
23
|
-
participatory_space: current_participatory_space
|
23
|
+
participatory_space: current_participatory_space,
|
24
|
+
settings: {
|
25
|
+
scope_id: current_participatory_space.scope.try(:id)
|
26
|
+
}
|
24
27
|
)
|
25
28
|
|
26
|
-
@form = form(
|
29
|
+
@form = form(@component.form_class).from_model(@component)
|
27
30
|
end
|
28
31
|
|
29
32
|
def create
|
30
|
-
@form = form(
|
33
|
+
@form = form(manifest.component_form_class).from_params(component_params)
|
31
34
|
enforce_permission_to :create, :component
|
32
35
|
|
33
36
|
CreateComponent.call(@form) do
|
@@ -47,12 +50,12 @@ module Decidim
|
|
47
50
|
@component = query_scope.find(params[:id])
|
48
51
|
enforce_permission_to :update, :component, component: @component
|
49
52
|
|
50
|
-
@form = form(
|
53
|
+
@form = form(@component.form_class).from_model(@component)
|
51
54
|
end
|
52
55
|
|
53
56
|
def update
|
54
57
|
@component = query_scope.find(params[:id])
|
55
|
-
@form = form(
|
58
|
+
@form = form(@component.form_class).from_params(component_params)
|
56
59
|
enforce_permission_to :update, :component, component: @component
|
57
60
|
|
58
61
|
UpdateComponent.call(@form, @component) do
|
@@ -111,30 +114,34 @@ module Decidim
|
|
111
114
|
end
|
112
115
|
end
|
113
116
|
|
114
|
-
|
117
|
+
def share
|
118
|
+
@component = query_scope.find(params[:id])
|
119
|
+
share_token = @component.share_tokens.create!(user: current_user, organization: current_organization)
|
115
120
|
|
116
|
-
|
117
|
-
# to the right type. See Decidim::SettingsManifest#schema.
|
118
|
-
def new_settings_schema(name, data)
|
119
|
-
manifest.settings(name).schema.new(data, current_organization.default_locale)
|
121
|
+
redirect_to share_token.url
|
120
122
|
end
|
121
123
|
|
122
|
-
|
124
|
+
private
|
125
|
+
|
126
|
+
# Processes the component params so the form object defined in the manifest (component_form_class_name)
|
123
127
|
# can assign and validate the attributes when using #from_params.
|
124
|
-
def
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
128
|
+
def component_params
|
129
|
+
new_settings = proc { |name, data| Component.build_settings(manifest, name, data, current_organization) }
|
130
|
+
|
131
|
+
params[:component].permit!.tap do |hsh|
|
132
|
+
hsh[:id] = params[:id]
|
133
|
+
hsh[:manifest] = manifest
|
134
|
+
hsh[:participatory_space] = current_participatory_space
|
135
|
+
hsh[:settings] = new_settings.call(:global, hsh[:settings])
|
136
|
+
if hsh[:default_step_settings]
|
137
|
+
hsh[:default_step_settings] = new_settings.call(:step, hsh[:default_step_settings])
|
138
|
+
else
|
139
|
+
hsh[:step_settings] ||= {}
|
140
|
+
hsh[:step_settings].each do |key, value|
|
141
|
+
hsh[:step_settings][key] = new_settings.call(:step, value)
|
142
|
+
end
|
135
143
|
end
|
136
144
|
end
|
137
|
-
form_params
|
138
145
|
end
|
139
146
|
|
140
147
|
def query_scope
|