decidim-admin 0.21.0 → 0.22.0
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/decidim/admin/application.js.es6 +4 -0
- data/app/assets/javascripts/decidim/admin/budget_rule_toggler.component.js.es6 +52 -0
- data/app/assets/javascripts/decidim/admin/bundle.js +7 -7
- data/app/assets/javascripts/decidim/admin/bundle.js.map +1 -1
- data/app/assets/javascripts/decidim/admin/dynamic_fields.component.js.es6 +24 -5
- data/app/assets/javascripts/decidim/admin/form.js.es6 +23 -10
- data/app/assets/javascripts/decidim/admin/gallery.js.es6 +5 -0
- data/app/assets/javascripts/decidim/admin/officializations.js.es6 +20 -0
- data/app/assets/stylesheets/decidim/admin/_decidim.scss +2 -0
- data/app/assets/stylesheets/decidim/admin/_variables.scss +1 -1
- 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 +10 -1
- data/app/assets/stylesheets/decidim/admin/modules/_cards.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/modules/_filters.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/modules/_forms.scss +2 -2
- data/app/assets/stylesheets/decidim/admin/modules/_import_result.scss +10 -0
- data/app/assets/stylesheets/decidim/admin/modules/_loading-spinner.scss +11 -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 +0 -1
- data/app/assets/stylesheets/decidim/admin/modules/_table-list.scss +0 -5
- 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/commands/decidim/admin/create_newsletter.rb +34 -9
- 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 +2 -1
- data/app/commands/decidim/admin/update_newsletter.rb +31 -9
- data/app/commands/decidim/admin/update_organization_appearance.rb +3 -1
- data/app/controllers/decidim/admin/authorization_workflows_controller.rb +6 -0
- data/app/controllers/decidim/admin/components_controller.rb +6 -5
- 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 +22 -4
- data/app/controllers/decidim/admin/officializations_controller.rb +8 -0
- 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 +1 -1
- data/app/forms/decidim/admin/component_form.rb +0 -23
- data/app/forms/decidim/admin/newsletter_form.rb +15 -3
- data/app/forms/decidim/admin/organization_appearance_form.rb +2 -0
- data/app/helpers/decidim/admin/filterable_helper.rb +35 -27
- data/app/helpers/decidim/admin/icon_link_helper.rb +1 -1
- data/app/helpers/decidim/admin/settings_helper.rb +47 -59
- data/app/helpers/decidim/admin/uploader_image_dimensions_helper.rb +30 -0
- data/app/models/decidim/admin/fake_newsletter.rb +49 -0
- data/app/permissions/decidim/admin/permissions.rb +6 -0
- 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/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/_settings_fields.html.erb +2 -2
- data/app/views/decidim/admin/dashboard/show.html.erb +35 -10
- 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 +1 -1
- data/app/views/decidim/admin/newsletters/new.html.erb +1 -1
- data/app/views/decidim/admin/officializations/_show_email_modal.html.erb +31 -0
- data/app/views/decidim/admin/officializations/index.html.erb +7 -3
- data/app/views/decidim/admin/officializations/show_email.html.erb +2 -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/shared/_filters.html.erb +3 -3
- data/app/views/decidim/admin/shared/_gallery.html.erb +21 -0
- 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 +1 -0
- data/app/views/layouts/decidim/admin/_header.html.erb +2 -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/ar.yml +12 -6
- data/config/locales/bg-BG.yml +16 -0
- data/config/locales/ca.yml +46 -6
- data/config/locales/cs.yml +89 -49
- data/config/locales/da-DK.yml +1 -0
- data/config/locales/de.yml +102 -6
- data/config/locales/el.yml +848 -0
- data/config/locales/en.yml +46 -6
- data/config/locales/eo-UY.yml +0 -1
- data/config/locales/es-MX.yml +46 -6
- data/config/locales/es-PY.yml +46 -6
- data/config/locales/es.yml +46 -6
- data/config/locales/et-EE.yml +1 -0
- data/config/locales/eu.yml +12 -6
- data/config/locales/fi-plain.yml +46 -6
- data/config/locales/fi.yml +61 -21
- data/config/locales/fr-CA.yml +849 -0
- data/config/locales/fr.yml +83 -6
- data/config/locales/ga-IE.yml +1 -0
- data/config/locales/gl.yml +12 -6
- data/config/locales/hr-HR.yml +1 -0
- data/config/locales/hu.yml +46 -6
- data/config/locales/id-ID.yml +12 -6
- data/config/locales/is-IS.yml +10 -5
- data/config/locales/it.yml +78 -38
- data/config/locales/ja-JP.yml +849 -0
- data/config/locales/lt-LT.yml +1 -0
- data/config/locales/lv-LV.yml +835 -0
- data/config/locales/mt-MT.yml +1 -0
- data/config/locales/nl.yml +63 -6
- data/config/locales/no.yml +80 -43
- data/config/locales/pl.yml +309 -185
- data/config/locales/pt-BR.yml +13 -7
- data/config/locales/pt.yml +331 -207
- data/config/locales/ro-RO.yml +844 -0
- data/config/locales/ru.yml +11 -5
- data/config/locales/sk-SK.yml +823 -0
- data/config/locales/sk.yml +842 -0
- data/config/locales/sl.yml +175 -0
- data/config/locales/sr-CS.yml +625 -0
- data/config/locales/sv.yml +94 -12
- data/config/locales/tr-TR.yml +12 -6
- data/config/locales/uk.yml +10 -5
- data/config/routes.rb +13 -2
- data/lib/decidim/admin/engine.rb +2 -1
- data/lib/decidim/admin/version.rb +1 -1
- metadata +53 -18
|
@@ -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
|
|
@@ -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
|
|
@@ -23,11 +23,11 @@ module Decidim
|
|
|
23
23
|
participatory_space: current_participatory_space
|
|
24
24
|
)
|
|
25
25
|
|
|
26
|
-
@form = form(
|
|
26
|
+
@form = form(@component.form_class).from_model(@component)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def create
|
|
30
|
-
@form = form(
|
|
30
|
+
@form = form(manifest.component_form_class).from_params(component_params)
|
|
31
31
|
enforce_permission_to :create, :component
|
|
32
32
|
|
|
33
33
|
CreateComponent.call(@form) do
|
|
@@ -47,12 +47,12 @@ module Decidim
|
|
|
47
47
|
@component = query_scope.find(params[:id])
|
|
48
48
|
enforce_permission_to :update, :component, component: @component
|
|
49
49
|
|
|
50
|
-
@form = form(
|
|
50
|
+
@form = form(@component.form_class).from_model(@component)
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def update
|
|
54
54
|
@component = query_scope.find(params[:id])
|
|
55
|
-
@form = form(
|
|
55
|
+
@form = form(@component.form_class).from_params(component_params)
|
|
56
56
|
enforce_permission_to :update, :component, component: @component
|
|
57
57
|
|
|
58
58
|
UpdateComponent.call(@form, @component) do
|
|
@@ -113,7 +113,7 @@ module Decidim
|
|
|
113
113
|
|
|
114
114
|
private
|
|
115
115
|
|
|
116
|
-
# Processes the component params so
|
|
116
|
+
# Processes the component params so the form object defined in the manifest (component_form_class_name)
|
|
117
117
|
# can assign and validate the attributes when using #from_params.
|
|
118
118
|
def component_params
|
|
119
119
|
new_settings = proc { |name, data| Component.build_settings(manifest, name, data, current_organization) }
|
|
@@ -126,6 +126,7 @@ module Decidim
|
|
|
126
126
|
if hsh[:default_step_settings]
|
|
127
127
|
hsh[:default_step_settings] = new_settings.call(:step, hsh[:default_step_settings])
|
|
128
128
|
else
|
|
129
|
+
hsh[:step_settings] ||= {}
|
|
129
130
|
hsh[:step_settings].each do |key, value|
|
|
130
131
|
hsh[:step_settings][key] = new_settings.call(:step, value)
|
|
131
132
|
end
|
|
@@ -6,6 +6,8 @@ module Decidim
|
|
|
6
6
|
#
|
|
7
7
|
class DashboardController < Decidim::Admin::ApplicationController
|
|
8
8
|
helper_method :latest_action_logs
|
|
9
|
+
helper_method :users_counter
|
|
10
|
+
helper_method :metrics_presenter
|
|
9
11
|
|
|
10
12
|
def show
|
|
11
13
|
enforce_permission_to :read, :admin_dashboard
|
|
@@ -19,7 +21,37 @@ module Decidim
|
|
|
19
21
|
.includes(:participatory_space, :user, :resource, :component, :version)
|
|
20
22
|
.for_admin
|
|
21
23
|
.order(created_at: :desc)
|
|
22
|
-
.first(
|
|
24
|
+
.first(5)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def metrics_presenter
|
|
28
|
+
@metrics_presenter ||= Decidim::Admin::DashboardMetricChartsPresenter.new(
|
|
29
|
+
summary: true,
|
|
30
|
+
organization: current_organization
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def users_counter
|
|
35
|
+
last_day = Time.zone.yesterday
|
|
36
|
+
last_week = Time.zone.today.prev_week
|
|
37
|
+
last_month = Time.zone.today.prev_month
|
|
38
|
+
|
|
39
|
+
{
|
|
40
|
+
total_admins_last_24: users_count(last_day, true),
|
|
41
|
+
total_admins_last_week: users_count(last_week, true),
|
|
42
|
+
total_admins_last_month: users_count(last_month, true),
|
|
43
|
+
total_participants_last_24: users_count(last_day, false),
|
|
44
|
+
total_participants_last_week: users_count(last_week, false),
|
|
45
|
+
total_participants_last_month: users_count(last_month, false)
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def users_count(date, admin)
|
|
50
|
+
@users_count = Decidim::Admin::ActiveUsersCounter.new(
|
|
51
|
+
organization: current_organization,
|
|
52
|
+
date: date,
|
|
53
|
+
admin: admin
|
|
54
|
+
).query.count
|
|
23
55
|
end
|
|
24
56
|
end
|
|
25
57
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
class MetricsController < Decidim::Admin::ApplicationController
|
|
6
|
+
helper_method :metrics_presenter
|
|
7
|
+
|
|
8
|
+
def index
|
|
9
|
+
enforce_permission_to :read, :metrics
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def metrics_presenter
|
|
15
|
+
@metrics_presenter ||= Decidim::Admin::DashboardMetricChartsPresenter.new(
|
|
16
|
+
summary: false,
|
|
17
|
+
organization: current_organization
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Admin
|
|
5
|
+
# Controller that allows managing newsletters.
|
|
6
|
+
class NewsletterTemplatesController < Decidim::Admin::ApplicationController
|
|
7
|
+
helper_method :templates, :template_manifest
|
|
8
|
+
|
|
9
|
+
layout "decidim/admin/newsletters"
|
|
10
|
+
|
|
11
|
+
def index
|
|
12
|
+
enforce_permission_to :index, :newsletter
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def show; end
|
|
16
|
+
|
|
17
|
+
def preview
|
|
18
|
+
email = NewsletterMailer.newsletter(current_user, fake_newsletter)
|
|
19
|
+
Premailer::Rails::Hook.perform(email)
|
|
20
|
+
render html: email.html_part.body.decoded.html_safe
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def templates
|
|
26
|
+
@templates ||= Decidim.content_blocks.for(:newsletter_template)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def template_manifest
|
|
30
|
+
@template_manifest ||= Decidim
|
|
31
|
+
.content_blocks
|
|
32
|
+
.for(:newsletter_template)
|
|
33
|
+
.find { |manifest| manifest.name.to_s == params[:id] }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def fake_newsletter
|
|
37
|
+
@fake_newsletter ||= Decidim::Admin::FakeNewsletter.new(current_organization, template_manifest)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -7,7 +7,7 @@ module Decidim
|
|
|
7
7
|
include Decidim::NewslettersHelper
|
|
8
8
|
include Decidim::Admin::NewslettersHelper
|
|
9
9
|
include Paginable
|
|
10
|
-
helper_method :newsletter, :recipients_count_query
|
|
10
|
+
helper_method :newsletter, :recipients_count_query, :content_block
|
|
11
11
|
|
|
12
12
|
def index
|
|
13
13
|
enforce_permission_to :index, :newsletter
|
|
@@ -17,7 +17,7 @@ module Decidim
|
|
|
17
17
|
|
|
18
18
|
def new
|
|
19
19
|
enforce_permission_to :create, :newsletter
|
|
20
|
-
@form = form(NewsletterForm).
|
|
20
|
+
@form = form(NewsletterForm).from_model(content_block)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def show
|
|
@@ -37,7 +37,7 @@ module Decidim
|
|
|
37
37
|
enforce_permission_to :create, :newsletter
|
|
38
38
|
@form = form(NewsletterForm).from_params(params)
|
|
39
39
|
|
|
40
|
-
CreateNewsletter.call(@form, current_user) do
|
|
40
|
+
CreateNewsletter.call(@form, content_block, current_user) do
|
|
41
41
|
on(:ok) do |newsletter|
|
|
42
42
|
flash.now[:notice] = I18n.t("newsletters.create.success", scope: "decidim.admin")
|
|
43
43
|
redirect_to action: :show, id: newsletter.id
|
|
@@ -53,7 +53,7 @@ module Decidim
|
|
|
53
53
|
|
|
54
54
|
def edit
|
|
55
55
|
enforce_permission_to :update, :newsletter, newsletter: newsletter
|
|
56
|
-
@form = form(NewsletterForm).from_model(
|
|
56
|
+
@form = form(NewsletterForm).from_model(content_block)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def update
|
|
@@ -138,6 +138,24 @@ module Decidim
|
|
|
138
138
|
@form ||= form(SelectiveNewsletterForm).instance
|
|
139
139
|
NewsletterRecipients.for(@form).size
|
|
140
140
|
end
|
|
141
|
+
|
|
142
|
+
def content_block
|
|
143
|
+
@content_block ||= content_block_for_newsletter || content_block_from_manifest
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def content_block_from_manifest
|
|
147
|
+
Decidim::ContentBlock.new(
|
|
148
|
+
organization: current_organization,
|
|
149
|
+
scope_name: :newsletter_template,
|
|
150
|
+
manifest_name: params[:newsletter_template_id]
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def content_block_for_newsletter
|
|
155
|
+
return nil unless @newsletter
|
|
156
|
+
|
|
157
|
+
@content_block_for_newsletter ||= @newsletter.template
|
|
158
|
+
end
|
|
141
159
|
end
|
|
142
160
|
end
|
|
143
161
|
end
|
|
@@ -49,6 +49,14 @@ module Decidim
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
def show_email
|
|
53
|
+
enforce_permission_to :show_email, :user, user: user
|
|
54
|
+
|
|
55
|
+
Decidim.traceability.perform_action! :show_email, user, current_user
|
|
56
|
+
|
|
57
|
+
render :show_email, layout: false
|
|
58
|
+
end
|
|
59
|
+
|
|
52
60
|
private
|
|
53
61
|
|
|
54
62
|
def collection
|
|
@@ -5,6 +5,7 @@ module Decidim
|
|
|
5
5
|
# Controller that allows managing the appearance of the organization.
|
|
6
6
|
class OrganizationAppearanceController < Decidim::Admin::ApplicationController
|
|
7
7
|
layout "decidim/admin/settings"
|
|
8
|
+
helper Decidim::Admin::UploaderImageDimensionsHelper
|
|
8
9
|
|
|
9
10
|
def edit
|
|
10
11
|
enforce_permission_to :update, :organization, organization: current_organization
|
|
@@ -37,10 +37,11 @@ module Decidim
|
|
|
37
37
|
query = if term.start_with?("@")
|
|
38
38
|
query.where("nickname ILIKE ?", "#{term.delete("@")}%")
|
|
39
39
|
else
|
|
40
|
-
query.where("name ILIKE ?", "%#{term}%")
|
|
40
|
+
query.where("name ILIKE ?", "%#{term}%").or(
|
|
41
|
+
query.where("email ILIKE ?", "%#{term}%")
|
|
42
|
+
)
|
|
41
43
|
end
|
|
42
|
-
|
|
43
|
-
render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname})" } }
|
|
44
|
+
render json: query.all.collect { |u| { value: u.id, label: "#{u.name} (@#{u.nickname}) #{u.email}" } }
|
|
44
45
|
else
|
|
45
46
|
render json: []
|
|
46
47
|
end
|
|
@@ -23,9 +23,6 @@ module Decidim
|
|
|
23
23
|
attribute :default_step_settings, Object
|
|
24
24
|
attribute :step_settings, Hash[String => Object]
|
|
25
25
|
|
|
26
|
-
validate :must_be_able_to_change_participatory_texts_setting
|
|
27
|
-
validate :amendments_visibility_options_must_be_valid
|
|
28
|
-
|
|
29
26
|
def settings?
|
|
30
27
|
settings.manifest.attributes.any?
|
|
31
28
|
end
|
|
@@ -54,26 +51,6 @@ module Decidim
|
|
|
54
51
|
end
|
|
55
52
|
validations.all?
|
|
56
53
|
end
|
|
57
|
-
|
|
58
|
-
# Validates setting `participatory_texts_enabled` is not changed when there are proposals for the component.
|
|
59
|
-
def must_be_able_to_change_participatory_texts_setting
|
|
60
|
-
return unless manifest&.name == :proposals && (component = Component.find_by(id: id))
|
|
61
|
-
return unless settings.participatory_texts_enabled != component.settings.participatory_texts_enabled
|
|
62
|
-
|
|
63
|
-
settings.errors.add(:participatory_texts_enabled) if Decidim::Proposals::Proposal.where(component: component).any?
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# Validates setting `amendments_visibility` is included in Decidim::Amendment::VisibilityStepSetting.options.
|
|
67
|
-
def amendments_visibility_options_must_be_valid
|
|
68
|
-
return unless manifest&.name == :proposals && settings.amendments_enabled
|
|
69
|
-
|
|
70
|
-
visibility_options = Decidim::Amendment::VisibilityStepSetting.options.map(&:last)
|
|
71
|
-
step_settings.each do |step, settings|
|
|
72
|
-
next unless visibility_options.exclude? settings[:amendments_visibility]
|
|
73
|
-
|
|
74
|
-
step_settings[step].errors.add(:amendments_visibility, :inclusion)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
54
|
end
|
|
78
55
|
end
|
|
79
56
|
end
|
|
@@ -3,14 +3,26 @@
|
|
|
3
3
|
module Decidim
|
|
4
4
|
module Admin
|
|
5
5
|
# The form that validates the data to construct a valid Newsletter.
|
|
6
|
-
class NewsletterForm <
|
|
6
|
+
class NewsletterForm < ContentBlockForm
|
|
7
7
|
mimic :newsletter
|
|
8
8
|
|
|
9
9
|
include TranslatableAttributes
|
|
10
10
|
|
|
11
11
|
translatable_attribute :subject, String
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
validates :subject, translatable_presence: true
|
|
13
|
+
|
|
14
|
+
def map_model(content_block)
|
|
15
|
+
super(content_block)
|
|
16
|
+
self.subject = newsletter_for(content_block).try(:subject)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def newsletter_for(content_block)
|
|
22
|
+
Decidim::Newsletter
|
|
23
|
+
.where(organization: content_block.organization)
|
|
24
|
+
.find_by(id: content_block.scoped_resource_id)
|
|
25
|
+
end
|
|
14
26
|
end
|
|
15
27
|
end
|
|
16
28
|
end
|
|
@@ -34,6 +34,8 @@ module Decidim
|
|
|
34
34
|
attribute :success_color, String, default: "#57d685"
|
|
35
35
|
attribute :warning_color, String, default: "#ffae00"
|
|
36
36
|
attribute :alert_color, String, default: "#ec5840"
|
|
37
|
+
attribute :highlight_color, String, default: "#be6400"
|
|
38
|
+
attribute :highlight_alternative_color, String, default: "#ff5731"
|
|
37
39
|
|
|
38
40
|
translatable_attribute :cta_button_text, String
|
|
39
41
|
translatable_attribute :description, String
|
|
@@ -5,44 +5,46 @@ module Decidim
|
|
|
5
5
|
# Helper that provides methods related to Decidim::Admin::Filterable concern.
|
|
6
6
|
module FilterableHelper
|
|
7
7
|
# Renders the filters selector with tags in the admin panel.
|
|
8
|
-
def admin_filter_selector
|
|
9
|
-
render partial: "decidim/admin/shared/filters"
|
|
8
|
+
def admin_filter_selector(i18n_ctx = nil)
|
|
9
|
+
render partial: "decidim/admin/shared/filters", locals: { i18n_ctx: i18n_ctx }
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
# Builds a tree of links from Decidim::Admin::Filterable::filters_with_values
|
|
13
|
-
def submenu_options_tree
|
|
13
|
+
def submenu_options_tree(i18n_ctx = nil)
|
|
14
|
+
i18n_scope = filterable_i18n_scope_from_ctx(i18n_ctx)
|
|
15
|
+
|
|
14
16
|
filters_with_values.each_with_object({}) do |(filter, values), hash|
|
|
15
|
-
link = filter_link_label(filter)
|
|
17
|
+
link = filter_link_label(filter, i18n_scope)
|
|
16
18
|
hash[link] = if values.is_a?(Array)
|
|
17
|
-
build_submenu_options_tree_from_array(filter, values)
|
|
19
|
+
build_submenu_options_tree_from_array(filter, values, i18n_scope)
|
|
18
20
|
elsif values.is_a?(Hash)
|
|
19
|
-
build_submenu_options_tree_from_hash(filter, values)
|
|
21
|
+
build_submenu_options_tree_from_hash(filter, values, i18n_scope)
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
|
|
24
26
|
# Builds a tree of links from an array. The tree will have only one level.
|
|
25
|
-
def build_submenu_options_tree_from_array(filter, values)
|
|
27
|
+
def build_submenu_options_tree_from_array(filter, values, i18n_scope)
|
|
26
28
|
links = []
|
|
27
|
-
links += extra_dropdown_submenu_options_items(filter)
|
|
28
|
-
links += values.map { |value| filter_link_value(filter, value) }
|
|
29
|
+
links += extra_dropdown_submenu_options_items(filter, i18n_scope)
|
|
30
|
+
links += values.map { |value| filter_link_value(filter, value, i18n_scope) }
|
|
29
31
|
links.each_with_object({}) { |link, hash| hash[link] = nil }
|
|
30
32
|
end
|
|
31
33
|
|
|
32
34
|
# To be overriden. Useful for adding links that do not match with the filter.
|
|
33
35
|
# Must return an Array.
|
|
34
|
-
def extra_dropdown_submenu_options_items(_filter)
|
|
36
|
+
def extra_dropdown_submenu_options_items(_filter, _i18n_scope)
|
|
35
37
|
[]
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
# Builds a tree of links from an Hash. The tree can have many levels.
|
|
39
|
-
def build_submenu_options_tree_from_hash(filter, values)
|
|
41
|
+
def build_submenu_options_tree_from_hash(filter, values, i18n_scope)
|
|
40
42
|
values.each_with_object({}) do |(key, value), hash|
|
|
41
|
-
link = filter_link_value(filter, key)
|
|
43
|
+
link = filter_link_value(filter, key, i18n_scope)
|
|
42
44
|
hash[link] = if value.nil?
|
|
43
45
|
nil
|
|
44
46
|
elsif value.is_a?(Hash)
|
|
45
|
-
build_submenu_options_tree_from_hash(filter, value)
|
|
47
|
+
build_submenu_options_tree_from_hash(filter, value, i18n_scope)
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
50
|
end
|
|
@@ -63,21 +65,21 @@ module Decidim
|
|
|
63
65
|
end
|
|
64
66
|
end
|
|
65
67
|
|
|
66
|
-
def filter_link_label(filter)
|
|
67
|
-
link_to(i18n_filter_label(filter), href: "#")
|
|
68
|
+
def filter_link_label(filter, i18n_scope)
|
|
69
|
+
link_to(i18n_filter_label(filter, i18n_scope), href: "#")
|
|
68
70
|
end
|
|
69
71
|
|
|
70
|
-
def filter_link_value(filter, value)
|
|
71
|
-
link_to(i18n_filter_value(filter, value), query_params_with(filter => value))
|
|
72
|
+
def filter_link_value(filter, value, i18n_scope)
|
|
73
|
+
link_to(i18n_filter_value(filter, value, i18n_scope), query_params_with(filter => value))
|
|
72
74
|
end
|
|
73
75
|
|
|
74
|
-
def i18n_filter_label(filter)
|
|
75
|
-
t("
|
|
76
|
+
def i18n_filter_label(filter, i18n_scope)
|
|
77
|
+
t("#{i18n_scope}.#{filter}.label")
|
|
76
78
|
end
|
|
77
79
|
|
|
78
|
-
def i18n_filter_value(filter, value)
|
|
79
|
-
if I18n.exists?("
|
|
80
|
-
t(value, scope: "
|
|
80
|
+
def i18n_filter_value(filter, value, i18n_scope)
|
|
81
|
+
if I18n.exists?("#{i18n_scope}.#{filter}.values.#{value}")
|
|
82
|
+
t(value, scope: "#{i18n_scope}.#{filter}.values")
|
|
81
83
|
else
|
|
82
84
|
find_dynamic_translation(filter, value)
|
|
83
85
|
end
|
|
@@ -94,16 +96,16 @@ module Decidim
|
|
|
94
96
|
html.join.html_safe
|
|
95
97
|
end
|
|
96
98
|
|
|
97
|
-
def applied_filters_tags
|
|
99
|
+
def applied_filters_tags(i18n_ctx)
|
|
98
100
|
ransack_params.slice(*filters).map do |filter, value|
|
|
99
|
-
applied_filter_tag(filter, value)
|
|
101
|
+
applied_filter_tag(filter, value, filterable_i18n_scope_from_ctx(i18n_ctx))
|
|
100
102
|
end.join.html_safe
|
|
101
103
|
end
|
|
102
104
|
|
|
103
|
-
def applied_filter_tag(filter, value)
|
|
105
|
+
def applied_filter_tag(filter, value, i18n_scope)
|
|
104
106
|
content_tag(:span, class: "label secondary") do
|
|
105
|
-
concat "#{i18n_filter_label(filter)}: "
|
|
106
|
-
concat i18n_filter_value(filter, value)
|
|
107
|
+
concat "#{i18n_filter_label(filter, i18n_scope)}: "
|
|
108
|
+
concat i18n_filter_value(filter, value, i18n_scope)
|
|
107
109
|
concat remove_filter_icon_link(filter)
|
|
108
110
|
end
|
|
109
111
|
end
|
|
@@ -116,6 +118,12 @@ module Decidim
|
|
|
116
118
|
class: "action-icon--remove"
|
|
117
119
|
)
|
|
118
120
|
end
|
|
121
|
+
|
|
122
|
+
def filterable_i18n_scope_from_ctx(i18n_ctx)
|
|
123
|
+
i18n_scope = "decidim.admin.filters"
|
|
124
|
+
i18n_scope += ".#{i18n_ctx}" if i18n_ctx
|
|
125
|
+
i18n_scope
|
|
126
|
+
end
|
|
119
127
|
end
|
|
120
128
|
end
|
|
121
129
|
end
|