decidim-decidim_awesome 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +134 -15
- data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +4 -24
- data/app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb +9 -5
- data/app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb +1 -1
- data/app/commands/concerns/decidim/decidim_awesome/proposals/admin/update_proposal_override.rb +31 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/create_proposal_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_collaborative_draft_override.rb +27 -0
- data/app/commands/concerns/decidim/decidim_awesome/proposals/update_proposal_override.rb +26 -0
- data/app/commands/decidim/decidim_awesome/admin/create_proposal_custom_field.rb +4 -3
- data/app/commands/decidim/decidim_awesome/admin/destroy_proposal_custom_field.rb +6 -3
- data/app/controllers/concerns/decidim/decidim_awesome/admin/maintenance_context.rb +43 -0
- data/app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb +3 -2
- data/app/controllers/concerns/decidim/decidim_awesome/limit_pending_amendments.rb +35 -0
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +9 -22
- data/app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb +7 -7
- data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +2 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +7 -3
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +8 -5
- data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +3 -1
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +0 -2
- data/app/controllers/decidim/decidim_awesome/admin/maintenance_controller.rb +76 -0
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +0 -2
- data/app/controllers/decidim/decidim_awesome/admin/proposal_custom_fields_controller.rb +12 -4
- data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +8 -1
- data/app/forms/concerns/decidim/decidim_awesome/proposals/proposal_form_override.rb +21 -0
- data/app/forms/{decidim → concerns/decidim}/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -0
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +35 -9
- data/app/helpers/{decidim → concerns/decidim}/decidim_awesome/amendments_helper_override.rb +17 -7
- data/app/helpers/concerns/decidim/decidim_awesome/proposals/application_helper_override.rb +126 -0
- data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +5 -26
- data/app/jobs/decidim/decidim_awesome/destroy_private_data_job.rb +22 -0
- data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +38 -9
- data/app/models/decidim/decidim_awesome/paper_trail_version.rb +5 -1
- data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +35 -1
- data/app/overrides/decidim/proposals/admin/proposals/show/add_private_body.html.erb.deface +7 -0
- data/app/overrides/decidim/proposals/admin/proposals/show/replace_body.html.erb.deface +5 -0
- data/app/overrides/decidim/proposals/proposals/show/limit_amendments_modal.html.erb.deface +5 -0
- data/app/packs/entrypoints/decidim_decidim_awesome_map.scss +1 -1
- data/app/packs/src/decidim/decidim_awesome/admin/auto_edit.js +5 -3
- data/app/packs/src/decidim/decidim_awesome/admin/constraints.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js +5 -4
- data/app/packs/src/decidim/decidim_awesome/amendments/show_modal_on_limits.js +30 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_application.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/editors/editor.js +1 -6
- data/app/packs/src/decidim/decidim_awesome/editors/tabs_focus.js +18 -9
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +35 -26
- data/app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js +31 -15
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/codemirror.scss +12 -7
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/constraints.scss +69 -25
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/custom_fields.scss +34 -27
- data/app/packs/stylesheets/decidim/decidim_awesome/admin/user_picker.scss +2 -2
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin.scss +3 -3
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_admin_global.scss +28 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +3 -2
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +15 -15
- data/app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +3 -3
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss +3 -3
- data/app/packs/stylesheets/decidim/decidim_awesome/forms/custom_fields.scss +187 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/shared/spinner.scss +47 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +7 -7
- data/app/permissions/decidim/decidim_awesome/admin/permissions.rb +14 -3
- data/app/presenters/concerns/decidim/decidim_awesome/proposals/proposal_presenter_override.rb +20 -0
- data/app/presenters/decidim/decidim_awesome/admin_log/component_presenter_override.rb +30 -0
- data/app/presenters/decidim/decidim_awesome/private_data_presenter.rb +70 -0
- data/app/queries/decidim/decidim_awesome/private_data_finder.rb +19 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +1 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb +72 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb +38 -0
- data/app/serializers/decidim/decidim_awesome/proposals/private_proposal_serializer.rb +42 -0
- data/app/types/concerns/decidim/decidim_awesome/add_proposal_type_custom_fields.rb +59 -0
- data/app/types/concerns/decidim/decidim_awesome/{proposal_type_override.rb → add_proposal_type_vote_weights.rb} +3 -1
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +52 -48
- data/app/views/decidim/decidim_awesome/admin/config/_autoedit_box_label.html.erb +7 -2
- data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +16 -8
- data/app/views/decidim/decidim_awesome/admin/config/_form_admins.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +12 -16
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_custom_fields.html.erb +35 -15
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposal_private_custom_fields.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +22 -22
- data/app/views/decidim/decidim_awesome/admin/config/_form_styles.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/custom_redirects/index.html.erb +14 -13
- data/app/views/decidim/decidim_awesome/admin/maintenance/_private_data.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/maintenance/show.html.erb +44 -0
- data/app/views/decidim/decidim_awesome/admin/menu_hacks/index.html.erb +28 -29
- data/app/views/decidim/decidim_awesome/admin/proposals/_editor.html.erb +8 -5
- data/app/views/decidim/decidim_awesome/admin/proposals/_private_body.html.erb +20 -0
- data/app/views/decidim/decidim_awesome/amendments/_modal.html.erb +16 -0
- data/app/views/decidim/decidim_awesome/custom_fields/_form_render.html.erb +10 -2
- data/app/views/layouts/decidim/decidim_awesome/admin/_base.html.erb +21 -0
- data/app/views/layouts/decidim/decidim_awesome/admin/application.html.erb +1 -73
- data/app/views/layouts/decidim/decidim_awesome/admin/maintenance.html.erb +19 -0
- data/config/i18n-tasks.yml +22 -3
- data/config/locales/ca.yml +97 -9
- data/config/locales/cs.yml +109 -6
- data/config/locales/de.yml +92 -6
- data/config/locales/en.yml +102 -8
- data/config/locales/es.yml +96 -8
- data/config/locales/eu.yml +15 -1
- data/config/locales/fr.yml +94 -6
- data/config/locales/hu.yml +53 -4
- data/config/locales/it.yml +16 -6
- data/config/locales/ja.yml +94 -6
- data/config/locales/lt.yml +0 -2
- data/config/locales/nl.yml +9 -4
- data/config/locales/pt-BR.yml +16 -7
- data/config/locales/ro-RO.yml +11 -2
- data/config/locales/sv.yml +17 -6
- data/db/migrate/20240531224204_add_decidim_awesome_proposal_private_fields.rb +29 -0
- data/db/migrate/20240729164227_add_decidim_awesome_proposal_private_fields_date.rb +20 -0
- data/lib/decidim/decidim_awesome/admin_engine.rb +22 -6
- data/lib/decidim/decidim_awesome/api/types/localized_custom_fields_type.rb +22 -0
- data/lib/decidim/decidim_awesome/api/types/translated_custom_fields_type.rb +52 -0
- data/lib/decidim/decidim_awesome/awesome.rb +45 -8
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +5 -1
- data/lib/decidim/decidim_awesome/checksums.yml +23 -0
- data/lib/decidim/decidim_awesome/custom_fields.rb +8 -0
- data/lib/decidim/decidim_awesome/engine.rb +143 -52
- data/lib/decidim/decidim_awesome/lock.rb +47 -0
- data/lib/decidim/decidim_awesome/menu.rb +146 -0
- data/lib/decidim/decidim_awesome/test/initializer.rb +4 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/{box_label_editor.rb → box_label_editor_examples.rb} +1 -1
- data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +20 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/custom_fields_examples.rb +155 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/editor_examples.rb +24 -0
- data/lib/decidim/decidim_awesome/test/shared_examples/menu_hack_contexts.rb +2 -2
- data/lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb +3 -5
- data/lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb +78 -12
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/package.json +2 -2
- metadata +52 -13
- data/app/helpers/decidim/decidim_awesome/proposals/application_helper_override.rb +0 -78
- /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_item_presenter_override.rb +0 -0
- /data/app/presenters/{decidim → concerns/decidim}/decidim_awesome/menu_presenter_override.rb +0 -0
@@ -65,7 +65,7 @@
|
|
65
65
|
border-bottom: none;
|
66
66
|
|
67
67
|
.vote-card {
|
68
|
-
margin-top: .5rem;
|
68
|
+
margin-top: 0.5rem;
|
69
69
|
|
70
70
|
.vote-label {
|
71
71
|
margin-bottom: 1rem;
|
@@ -80,7 +80,7 @@
|
|
80
80
|
}
|
81
81
|
|
82
82
|
&.loading {
|
83
|
-
opacity: .3;
|
83
|
+
opacity: 0.3;
|
84
84
|
pointer-events: none;
|
85
85
|
position: relative;
|
86
86
|
|
@@ -102,7 +102,7 @@
|
|
102
102
|
}
|
103
103
|
|
104
104
|
.votes_counter {
|
105
|
-
letter-spacing: .2rem;
|
105
|
+
letter-spacing: 0.2rem;
|
106
106
|
font-size: 1rem;
|
107
107
|
}
|
108
108
|
|
@@ -123,7 +123,7 @@
|
|
123
123
|
width: $rectangle-width;
|
124
124
|
height: calc($rectangle-width * 2);
|
125
125
|
vertical-align: middle;
|
126
|
-
margin:
|
126
|
+
margin: -0.5rem 0 0 0.5rem;
|
127
127
|
max-width: 100%;
|
128
128
|
transition: transform 150ms ease-in-out;
|
129
129
|
|
@@ -171,7 +171,7 @@
|
|
171
171
|
}
|
172
172
|
|
173
173
|
.dim {
|
174
|
-
opacity: .3;
|
174
|
+
opacity: 0.3;
|
175
175
|
pointer-events: none;
|
176
176
|
}
|
177
177
|
|
@@ -199,8 +199,8 @@
|
|
199
199
|
|
200
200
|
&:hover {
|
201
201
|
text-decoration: none;
|
202
|
-
font-size: .9rem;
|
203
|
-
margin-top: .1rem;
|
202
|
+
font-size: 0.9rem;
|
203
|
+
margin-top: 0.1rem;
|
204
204
|
}
|
205
205
|
}
|
206
206
|
|
@@ -10,6 +10,7 @@ module Decidim
|
|
10
10
|
return permission_action if permission_action.scope != :admin
|
11
11
|
return permission_action unless user
|
12
12
|
return permission_action if user.read_attribute("admin").blank?
|
13
|
+
return permission_action unless permission_action.action == :edit_config
|
13
14
|
|
14
15
|
if permission_action.subject == :admin_accountability && DecidimAwesome.admin_accountability.respond_to?(:include?)
|
15
16
|
if global?
|
@@ -17,8 +18,14 @@ module Decidim
|
|
17
18
|
else
|
18
19
|
toggle_allow(DecidimAwesome.admin_accountability.include?(:participatory_space_roles))
|
19
20
|
end
|
20
|
-
elsif permission_action.
|
21
|
-
|
21
|
+
elsif permission_action.subject == :private_data && config_enabled?(:proposal_private_custom_fields)
|
22
|
+
if private_data.present?
|
23
|
+
allow! if private_data.destroyable?
|
24
|
+
else
|
25
|
+
allow!
|
26
|
+
end
|
27
|
+
else
|
28
|
+
toggle_allow(config_enabled?(*permission_action.subject))
|
22
29
|
end
|
23
30
|
|
24
31
|
permission_action
|
@@ -27,7 +34,11 @@ module Decidim
|
|
27
34
|
private
|
28
35
|
|
29
36
|
def global?
|
30
|
-
context.fetch(:global)
|
37
|
+
context.fetch(:global, nil)
|
38
|
+
end
|
39
|
+
|
40
|
+
def private_data
|
41
|
+
context.fetch(:private_data, nil)
|
31
42
|
end
|
32
43
|
end
|
33
44
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
##
|
7
|
+
# Override Proposal Presenter to access private field.
|
8
|
+
module ProposalPresenterOverride
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
included do
|
11
|
+
def private_body(*)
|
12
|
+
return unless proposal
|
13
|
+
|
14
|
+
proposal.private_body
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module AdminLog
|
6
|
+
module ComponentPresenterOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
included do
|
10
|
+
alias_method :decidim_original_action_string, :action_string
|
11
|
+
alias_method :decidim_original_i18n_params, :i18n_params
|
12
|
+
|
13
|
+
def action_string
|
14
|
+
return "decidim.decidim_awesome.admin_log.component.#{action}" if action == "destroy_private_data"
|
15
|
+
|
16
|
+
decidim_original_action_string
|
17
|
+
end
|
18
|
+
|
19
|
+
def i18n_params
|
20
|
+
if action == "destroy_private_data"
|
21
|
+
decidim_original_i18n_params.merge({ count: action_log.extra["count"] })
|
22
|
+
else
|
23
|
+
decidim_original_i18n_params
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class PrivateDataPresenter < SimpleDelegator
|
6
|
+
include Decidim::TranslatableAttributes
|
7
|
+
include ActionView::Helpers::DateHelper
|
8
|
+
include ActionView::Helpers::TagHelper
|
9
|
+
|
10
|
+
def name
|
11
|
+
@name ||= "#{translated_attribute(participatory_space.title)} / #{translated_attribute(super)}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def path
|
15
|
+
@path ||= Decidim::EngineRouter.main_proxy(self).root_path
|
16
|
+
end
|
17
|
+
|
18
|
+
def total
|
19
|
+
@total ||= Decidim::Proposals::Proposal.joins(:extra_fields)
|
20
|
+
.where(decidim_component_id: id)
|
21
|
+
.where.not(decidim_awesome_proposal_extra_fields: { private_body: nil })
|
22
|
+
.count.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def last_date
|
26
|
+
@last_date ||= Decidim::Proposals::Proposal.joins(:extra_fields)
|
27
|
+
.where(decidim_component_id: id)
|
28
|
+
.where.not(decidim_awesome_proposal_extra_fields: { private_body: nil })
|
29
|
+
.order(private_body_updated_at: :desc)
|
30
|
+
.first&.extra_fields&.private_body_updated_at
|
31
|
+
end
|
32
|
+
|
33
|
+
def time_ago
|
34
|
+
I18n.t("decidim.decidim_awesome.admin.maintenance.private_data.time_ago", time: time_ago_in_words(last_date)) if last_date
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroyable?
|
38
|
+
return false unless last_date
|
39
|
+
|
40
|
+
last_date < DecidimAwesome.private_data_expiration_time.ago
|
41
|
+
end
|
42
|
+
|
43
|
+
def locked?
|
44
|
+
Decidim::DecidimAwesome::Lock.new(organization).locked?(__getobj__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def as_json(_options = nil)
|
48
|
+
{
|
49
|
+
id: id,
|
50
|
+
name: name,
|
51
|
+
path: path,
|
52
|
+
total: total,
|
53
|
+
last_date: last_date,
|
54
|
+
time_ago: time_ago,
|
55
|
+
locked: locked?,
|
56
|
+
done: done
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def done
|
61
|
+
return content_tag("span", "", class: "loading-spinner primary") if locked?
|
62
|
+
|
63
|
+
return if destroyable?
|
64
|
+
return if last_date
|
65
|
+
|
66
|
+
I18n.t("decidim.decidim_awesome.admin.maintenance.private_data.done")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class PrivateDataFinder
|
6
|
+
def query
|
7
|
+
Component.where(id: proposals.where.not(decidim_awesome_proposal_extra_fields: { private_body: nil }))
|
8
|
+
end
|
9
|
+
|
10
|
+
def proposals
|
11
|
+
Decidim::Proposals::Proposal.select(:decidim_component_id).joins(:extra_fields)
|
12
|
+
end
|
13
|
+
|
14
|
+
def for(resources)
|
15
|
+
Component.where(id: proposals).where(id: resources)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -31,6 +31,7 @@ module Decidim
|
|
31
31
|
state: proposal.state.to_s,
|
32
32
|
reference: proposal.reference,
|
33
33
|
answer: ensure_translatable(proposal.answer),
|
34
|
+
answered_at: proposal.answered_at,
|
34
35
|
supports: proposal.proposal_votes_count,
|
35
36
|
weights: proposal_vote_weights,
|
36
37
|
endorsements: {
|
data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_methods.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
# Adds one custom field per column in export if custom fields are activted
|
7
|
+
# Adds vote weights
|
8
|
+
module ProposalSerializerMethods
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include ::Decidim::DecidimAwesome::NeedsAwesomeConfig
|
13
|
+
|
14
|
+
# Override the NeedsAwesomeConfig's awesome_config_instance,
|
15
|
+
# to take context from proposal instead of controller's request.
|
16
|
+
def awesome_config_instance
|
17
|
+
return @custom_config if @custom_config
|
18
|
+
|
19
|
+
@custom_config = Config.new(proposal.organization)
|
20
|
+
@custom_config.context_from_component(proposal.component)
|
21
|
+
@custom_config
|
22
|
+
end
|
23
|
+
|
24
|
+
def serialize_custom_fields
|
25
|
+
payload = {}
|
26
|
+
custom_fields = CustomFields.new(awesome_proposal_custom_fields)
|
27
|
+
if custom_fields.present?
|
28
|
+
@proposal.body.each do |locale, body|
|
29
|
+
if body.is_a?(Hash)
|
30
|
+
body.each do |translation_locale, value|
|
31
|
+
fields_entries(custom_fields, value) do |field_key, field_value|
|
32
|
+
payload["body/#{field_key}/#{translation_locale}".to_sym] = field_value if payload["body/#{field_key}/#{translation_locale}".to_sym].blank?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
fields_entries(custom_fields, body) do |key, value|
|
37
|
+
payload["body/#{key}/#{locale}".to_sym] = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
payload
|
43
|
+
end
|
44
|
+
|
45
|
+
def serialize_private_custom_fields
|
46
|
+
payload = {}
|
47
|
+
private_custom_fields = CustomFields.new(awesome_proposal_private_custom_fields)
|
48
|
+
if private_custom_fields.present?
|
49
|
+
fields_entries(private_custom_fields, proposal.private_body) do |key, value|
|
50
|
+
value = value.first if value.is_a? Array
|
51
|
+
payload["private_body/#{key}".to_sym] = value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
payload
|
55
|
+
end
|
56
|
+
|
57
|
+
# Iterate on custom fields that has a label and name
|
58
|
+
# (will ignore paragraphs and title)
|
59
|
+
def fields_entries(custom_fields, body)
|
60
|
+
custom_fields.apply_xml(body)
|
61
|
+
custom_fields.fields.each do |field|
|
62
|
+
next unless field["label"].present? && field.has_key?("name")
|
63
|
+
|
64
|
+
value = field["userData"].is_a?(Array) ? field["userData"].first : field["userData"]
|
65
|
+
yield field["label"].parameterize, value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/app/serializers/concerns/decidim/decidim_awesome/proposals/proposal_serializer_override.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
# Adds one custom field per column in export if custom fields are activted
|
7
|
+
# Adds vote weights
|
8
|
+
module ProposalSerializerOverride
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
include ProposalSerializerMethods
|
13
|
+
|
14
|
+
alias_method :decidim_original_serialize, :serialize
|
15
|
+
|
16
|
+
def serialize
|
17
|
+
# serialize first the custom fields,
|
18
|
+
# as default serialization will strip proposal body's <xml> tags.
|
19
|
+
serialization = decidim_original_serialize
|
20
|
+
serialization.merge!(proposal_vote_weights)
|
21
|
+
serialization.merge!(serialize_custom_fields)
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def proposal_vote_weights
|
27
|
+
payload = {}
|
28
|
+
if proposal.respond_to?(:vote_weights)
|
29
|
+
proposal.update_vote_weights!
|
30
|
+
payload[:votes] = proposal.reload.vote_weights
|
31
|
+
end
|
32
|
+
payload
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
##
|
7
|
+
# Custom serializer for Proposals with private data.
|
8
|
+
# Used to separate open-data export and admin export.
|
9
|
+
class PrivateProposalSerializer < ::Decidim::Proposals::ProposalSerializer
|
10
|
+
include ProposalSerializerMethods
|
11
|
+
|
12
|
+
def serialize
|
13
|
+
serialization = super.merge!(serialize_private_custom_fields)
|
14
|
+
serialization.merge!(serialize_private_notes)
|
15
|
+
end
|
16
|
+
|
17
|
+
def serialize_private_notes
|
18
|
+
payload = {}
|
19
|
+
notes = proposal.notes
|
20
|
+
return payload unless notes.any?
|
21
|
+
|
22
|
+
notes.each do |note|
|
23
|
+
payload["notes/#{note.id}".to_sym] = {
|
24
|
+
created_at: note.created_at,
|
25
|
+
note: note.body,
|
26
|
+
author: author_name(note.author)
|
27
|
+
}
|
28
|
+
end
|
29
|
+
payload
|
30
|
+
end
|
31
|
+
|
32
|
+
def author_name(author)
|
33
|
+
if author.respond_to?(:name)
|
34
|
+
translated_attribute(author.name) # is a Decidim::User or Decidim::Organization or Decidim::UserGroup
|
35
|
+
elsif author.respond_to?(:title)
|
36
|
+
translated_attribute(author.title) # is a Decidim::Meetings::Meeting
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module AddProposalTypeCustomFields
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
include ::Decidim::DecidimAwesome::NeedsAwesomeConfig
|
10
|
+
|
11
|
+
field :body_fields, TranslatedCustomFieldsType, "Custom fields for this proposal", null: true
|
12
|
+
|
13
|
+
def body_fields
|
14
|
+
return if custom_fields.empty?
|
15
|
+
|
16
|
+
@body_fields ||= object.body.transform_values do |body|
|
17
|
+
sanitize_translated_fields(body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Override the NeedsAwesomeConfig's awesome_config_instance,
|
22
|
+
# to take context from proposal instead of controller's request.
|
23
|
+
def awesome_config_instance
|
24
|
+
return @custom_config if @custom_config
|
25
|
+
|
26
|
+
@custom_config = Config.new(object.organization)
|
27
|
+
@custom_config.context_from_component(object.component)
|
28
|
+
@custom_config
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def custom_fields
|
34
|
+
@custom_fields ||= CustomFields.new(awesome_proposal_custom_fields)
|
35
|
+
end
|
36
|
+
|
37
|
+
def fields_for_xml(body)
|
38
|
+
custom_fields.apply_xml(body)
|
39
|
+
custom_fields.fields.filter_map do |field|
|
40
|
+
next unless field["label"].present? && field.has_key?("name")
|
41
|
+
|
42
|
+
field["userData"] = field["userData"].first if field["userData"].is_a?(Array)
|
43
|
+
field.dup
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def sanitize_translated_fields(body)
|
48
|
+
if body.is_a?(Hash)
|
49
|
+
body.transform_values do |value|
|
50
|
+
fields_for_xml(value)
|
51
|
+
end
|
52
|
+
else
|
53
|
+
fields_for_xml(body)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module DecidimAwesome
|
5
|
-
module
|
5
|
+
module AddProposalTypeVoteWeights
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
@@ -10,6 +10,8 @@ module Decidim
|
|
10
10
|
|
11
11
|
def vote_weights
|
12
12
|
current_component = object.component
|
13
|
+
return unless current_component.current_settings.respond_to?(:votes_hidden?)
|
14
|
+
|
13
15
|
object.vote_weights unless current_component.current_settings.votes_hidden?
|
14
16
|
end
|
15
17
|
end
|
@@ -1,28 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
<!--
|
2
|
+
Force tailwind to compile these classes
|
3
|
+
class="fill-success fill-alert"
|
4
|
+
-->
|
5
|
+
<div class="card-divider">
|
6
|
+
<h2 class="card-title"><%= t ".title" %></h2>
|
7
|
+
</div>
|
8
|
+
<div class="card-section decidim-version">
|
9
|
+
<p>
|
10
|
+
<span class="label <%= decidim_version_valid? ? "success" : "alert" %>"><%= t ".decidim_version", version: decidim_version %></span>
|
11
|
+
<%= check decidim_version_valid? %>
|
12
|
+
</p>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div class="card-section">
|
16
|
+
<p><%= t(".images_migrated") %>
|
17
|
+
<% if images_migrated? %>
|
18
|
+
<%= check true %></p>
|
19
|
+
<% else %>
|
20
|
+
<%= check false %></p>
|
21
|
+
<div class="callout alert">
|
22
|
+
<p><%= t(".pending_image_migrations", total: pending_image_migrations).html_safe %></p>
|
23
|
+
<%= link_to t(".start_image_migrations"), migrate_images_path, method: :post, class: "button" %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="card-section">
|
29
|
+
<ul class="vertical menu">
|
30
|
+
<% overrides.each do |group, props| %>
|
26
31
|
<li>
|
27
32
|
<strong><%= t ".#{group}" %></strong>
|
28
33
|
<ul class="vertical menu">
|
@@ -36,16 +41,16 @@
|
|
36
41
|
</ul>
|
37
42
|
<br>
|
38
43
|
</li>
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
<% end %>
|
45
|
+
</ul>
|
46
|
+
<ul class="vertical menu heads">
|
47
|
+
<li>
|
48
|
+
<strong><%= t ".head_tags" %></strong>
|
49
|
+
<ul class="vertical menu">
|
45
50
|
<% {
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
CSS: "//head/link[@rel='stylesheet'][contains(@href,'decidim_decidim_awesome')]",
|
52
|
+
JavaScript: "//script[contains(@src,'decidim_decidim_awesome')]"
|
53
|
+
}.each do |part, xpath| %>
|
49
54
|
<li>
|
50
55
|
<%= part %>
|
51
56
|
<% if head.xpath(xpath).count.positive? %>
|
@@ -56,16 +61,16 @@
|
|
56
61
|
<code class="help-text code-block"><%= head_addons(part) %></code>
|
57
62
|
<% end %>
|
58
63
|
</li>
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
<% end %>
|
65
|
+
</ul>
|
66
|
+
</li>
|
67
|
+
<li>
|
68
|
+
<strong><%= t ".admin_head_tags" %></strong>
|
69
|
+
<ul class="vertical menu">
|
65
70
|
<% {
|
66
|
-
|
67
|
-
|
68
|
-
|
71
|
+
CSS: "//head/link[@rel='stylesheet'][contains(@href,'decidim_admin_decidim_awesome')]",
|
72
|
+
JavaScript: "//script[contains(@src,'decidim_admin_decidim_awesome')]"
|
73
|
+
}.each do |part, xpath| %>
|
69
74
|
<li>
|
70
75
|
<%= part %>
|
71
76
|
<% if admin_head.xpath(xpath).count.positive? %>
|
@@ -76,9 +81,8 @@
|
|
76
81
|
<code class="help-text code-block"><%= admin_addons(part) %></code>
|
77
82
|
<% end %>
|
78
83
|
</li>
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
</div>
|
84
|
+
<% end %>
|
85
|
+
</ul>
|
86
|
+
</li>
|
87
|
+
</ul>
|
84
88
|
</div>
|
@@ -2,6 +2,11 @@
|
|
2
2
|
<%= t("config.#{var}",
|
3
3
|
scope: "activemodel.attributes",
|
4
4
|
id: "<span class='awesome-auto-edit' data-var='#{var}' data-scope='#{scope}' data-key='#{key}'>#{key}</span>").html_safe %>
|
5
|
-
|
6
|
-
<%=
|
5
|
+
|
6
|
+
<%= icon_link_to "pencil", "#", t("edit_label", scope: "decidim.decidim_awesome.admin.config.form"), class: "awesome-auto-edit", data: { "scope" => "#{scope}" } %>
|
7
|
+
|
8
|
+
<%= link_to delete_path, method: :delete, class: "float-right delete-box", title: t("remove", scope: "decidim.decidim_awesome.admin.config.form_#{var}"), data: { confirm: t("sure_to_remove", scope: "decidim.decidim_awesome.admin.config.form_#{var}") } do %>
|
9
|
+
<%= icon "circle-x" %>
|
10
|
+
<%= t("delete", scope: "decidim.decidim_awesome.admin.config.form_#{var}") %>
|
11
|
+
<% end %>
|
7
12
|
<% end %>
|
@@ -5,23 +5,31 @@
|
|
5
5
|
<span aria-hidden="true">×</span>
|
6
6
|
</button>
|
7
7
|
</div>
|
8
|
-
|
9
|
-
<h5><%= t ".title" %></h5>
|
8
|
+
<h5 class="mb-2"><%= t ".title" %></h5>
|
10
9
|
<% if constraints.blank? %>
|
11
10
|
<span class="label warning"><%= t ".always" %></span>
|
12
11
|
<% end %>
|
13
12
|
|
14
|
-
<ul class="constraints-list<%= " inactive" if constraints
|
13
|
+
<ul class="constraints-list<%= " inactive" if constraints.detect { |c| c.settings["participatory_space_manifest"] == "none" } %> <%= "no-items" if constraints.blank? || constraints.all? { |c| c.settings.none? { |k, val| val.present? } } %>">
|
15
14
|
<% constraints&.each do |constraint| %>
|
15
|
+
<% if constraint.settings.any? { |k, val| val.present? } %>
|
16
16
|
<li>
|
17
|
-
|
17
|
+
<% constraint.settings.reverse_each do |k, val| %>
|
18
|
+
<% if val.present? %>
|
18
19
|
<span class="label <%= k %> constraint-<%= val %>"><%= translate_constraint_value constraint, k %></span>
|
19
20
|
<% end %>
|
20
|
-
|
21
|
-
<%=
|
21
|
+
<% end %>
|
22
|
+
<button id="<%= "edit-#{key}-#{constraint.id}" %>" type="button" name="button" class="edit-condition" data-dialog-open="<%= "edit-modal-#{key}" %>" data-constraints-url="<%= constraint_path(id: constraint.id, key: key) %>">
|
23
|
+
<%= t ".edit" %>
|
24
|
+
</button>
|
25
|
+
|
26
|
+
<%= link_to t(".delete"), constraint_path(id: constraint.id), remote: true, method: :delete, class: "delete-condition" %>
|
22
27
|
</li>
|
23
28
|
<% end %>
|
29
|
+
<% end %>
|
24
30
|
</ul>
|
25
|
-
<
|
26
|
-
|
31
|
+
<button id="<%= "new-#{key}" %>" type="button" name="button" class="add-condition button small button__secondary" data-open="constraintsModal" data-constraints-url="<%= new_constraint_path(key: key) %>">
|
32
|
+
<%= icon "plus", class: "small" %>
|
33
|
+
<%= t ".add_condition" %>
|
34
|
+
</button>
|
27
35
|
</div>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<p class="help-text"><%= t("help.scoped_admins", scope: "decidim.decidim_awesome.admin.config.form") %></p>
|
4
4
|
|
5
5
|
<% form.object.scoped_admins&.each do |key, value| %>
|
6
|
-
<div class="scoped_admins_container" data-key="<%= key %>">
|
6
|
+
<div class="card p-4 scoped_admins_container js-box-container" data-key="<%= key %>">
|
7
7
|
<%= render(partial: "decidim/decidim_awesome/admin/config/autoedit_box_label", locals: { var: "scoped_admins", key: key, scope: "scoped_admin_#{key}", delete_path: decidim_admin_decidim_awesome.scoped_admin_path(key: key) }) %>
|
8
8
|
<p class="form-error is-visible" id="scoped-admin-error-<%= $key %>"><%= errors[key.to_sym].join("<br>") if errors %></p>
|
9
9
|
|