decidim-decidim_awesome 0.9.3 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of decidim-decidim_awesome might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +121 -8
- data/Rakefile +1 -0
- data/app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb +38 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_base_cell.rb +40 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/show.erb +15 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter/vote_button.erb +15 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_counter_cell.rb +21 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb +35 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/vote_block_for.erb +16 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb +87 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal/show.erb +16 -0
- data/app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal_cell.rb +20 -0
- data/app/cells/decidim/proposals/proposal_m/footer.erb +13 -0
- data/app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb +2 -2
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb +100 -0
- data/app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb +64 -0
- data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +2 -6
- data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +1 -1
- data/app/controllers/decidim/decidim_awesome/admin/custom_redirects_controller.rb +1 -1
- data/app/controllers/decidim/decidim_awesome/admin/menu_hacks_controller.rb +1 -1
- data/app/forms/decidim/decidim_awesome/admin/config_form.rb +7 -0
- data/app/forms/decidim/decidim_awesome/admin/custom_redirect_form.rb +1 -1
- data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb +1 -1
- data/app/helpers/decidim/decidim_awesome/admin/system_checker_helpers.rb +4 -0
- data/app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb +51 -0
- data/app/models/concerns/decidim/decidim_awesome/has_vote_weight.rb +30 -0
- data/app/models/decidim/decidim_awesome/proposal_extra_field.rb +11 -0
- data/app/models/decidim/decidim_awesome/vote_weight.rb +30 -0
- data/app/overrides/decidim/proposals/admin/proposals/_form/replace_editor.html.erb.deface +3 -0
- data/app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface +7 -0
- data/app/overrides/decidim/proposals/proposals/_votes_count/replace_counter.html.erb.deface +10 -0
- data/app/{views/layouts/decidim/_head.html.erb → overrides/layouts/decidim/_application/add_intergram.html.erb.deface} +1 -1
- data/app/overrides/layouts/decidim/_head/add_awesome_legacy_scripts.rb +11 -0
- data/app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface +11 -0
- data/app/{views/layouts/decidim/admin/_header.html.erb → overrides/layouts/decidim/admin/_application/add_intergram.html.erb.deface} +1 -1
- data/app/{views/v0.26/layouts/decidim/admin/_header.html.erb → overrides/layouts/decidim/admin/_header/replace_scripts.html.erb.deface} +1 -6
- data/app/overrides/layouts/decidim/admin/_header/replace_styles.html.erb.deface +3 -0
- data/app/packs/images/decidim/decidim_awesome/handcard.svg +14 -0
- data/app/packs/images/decidim/decidim_awesome/handcheck.svg +17 -0
- data/app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js +13 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_admin.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_application.js +1 -0
- data/app/packs/src/decidim/decidim_awesome/awesome_map/controllers/controller.js +1 -7
- data/app/packs/src/decidim/decidim_awesome/editors/editor.js +10 -4
- data/app/packs/src/decidim/decidim_awesome/forms/custom_fields_renderer.js +1 -1
- data/app/packs/src/decidim/decidim_awesome/voting/voting_cards.js +63 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/awesome_application.scss +1 -0
- data/app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss +223 -0
- data/app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb +64 -0
- data/app/types/concerns/decidim/decidim_awesome/proposal_type_override.rb +18 -0
- data/app/views/decidim/decidim_awesome/admin/checks/_assets_tester.html.erb +1 -1
- data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +1 -0
- data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +19 -1
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_proposal_m_cell_footer.erb +15 -0
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb +6 -0
- data/app/views/decidim/decidim_awesome/voting/voting_cards/_show_votes_count.html.erb +1 -0
- data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +1 -0
- data/app/views/layouts/decidim/{admin/decidim_awesome.html.erb → decidim_awesome/admin/application.html.erb} +1 -1
- data/config/locales/ca.yml +64 -1
- data/config/locales/cs.yml +46 -1
- data/config/locales/de.yml +63 -0
- data/config/locales/en.yml +73 -1
- data/config/locales/es.yml +65 -1
- data/config/locales/eu.yml +5 -0
- data/config/locales/fr.yml +58 -1
- data/config/locales/hu.yml +227 -0
- data/config/locales/it.yml +133 -4
- data/config/locales/ja.yml +64 -1
- data/config/locales/lt.yml +102 -0
- data/config/locales/nl.yml +5 -1
- data/config/locales/pt-BR.yml +5 -1
- data/config/locales/pt-PT.yml +1 -0
- data/config/locales/ro-RO.yml +148 -0
- data/config/locales/sv.yml +5 -0
- data/db/migrate/20231006113837_create_decidim_awesome_vote_weights.rb +13 -0
- data/db/migrate/20231006113841_create_decidim_awesome_proposal_extra_fields.rb +14 -0
- data/lib/decidim/decidim_awesome/awesome.rb +43 -4
- data/lib/decidim/decidim_awesome/awesome_helpers.rb +7 -0
- data/lib/decidim/decidim_awesome/checksums.yml +17 -0
- data/lib/decidim/decidim_awesome/config.rb +10 -2
- data/lib/decidim/decidim_awesome/engine.rb +80 -2
- data/lib/decidim/decidim_awesome/system_checker.rb +4 -0
- data/lib/decidim/decidim_awesome/test/factories.rb +18 -0
- data/lib/decidim/decidim_awesome/test/initializer.rb +10 -1
- data/lib/decidim/decidim_awesome/version.rb +1 -1
- data/lib/decidim/decidim_awesome/voting_manifest.rb +60 -0
- data/lib/tasks/decidim_awesome_upgrade_tasks.rake +9 -0
- data/package.json +5 -4
- metadata +61 -11
- data/app/views/decidim/proposals/admin/proposals/_form.html.erb +0 -101
- data/app/views/v0.26/layouts/decidim/_head.html.erb +0 -45
- data/app/views/v0.27/layouts/decidim/_head.html.erb +0 -49
- data/app/views/v0.27/layouts/decidim/admin/_header.html.erb +0 -11
- /data/app/models/{decidim → concerns/decidim}/decidim_awesome/user_override.rb +0 -0
@@ -9,6 +9,7 @@ module Decidim
|
|
9
9
|
autoload :ContextAnalyzers, "decidim/decidim_awesome/context_analyzers"
|
10
10
|
autoload :MenuHacker, "decidim/decidim_awesome/menu_hacker"
|
11
11
|
autoload :CustomFields, "decidim/decidim_awesome/custom_fields"
|
12
|
+
autoload :VotingManifest, "decidim/decidim_awesome/voting_manifest"
|
12
13
|
|
13
14
|
# Awesome coms with some components for participatory spaces
|
14
15
|
# Currently :awesome_map and :awesome_iframe, list them here
|
@@ -57,10 +58,16 @@ module Decidim
|
|
57
58
|
end
|
58
59
|
|
59
60
|
# Live chat widget linked to Telegram account or group
|
61
|
+
# In the admin side only
|
60
62
|
config_accessor :intergram_for_admins do
|
61
63
|
false
|
62
64
|
end
|
63
65
|
|
66
|
+
# In the public side only
|
67
|
+
config_accessor :intergram_for_public do
|
68
|
+
false
|
69
|
+
end
|
70
|
+
|
64
71
|
# Configuration options to handle different validations in proposals
|
65
72
|
# (maybe in the future will apply to other places)
|
66
73
|
# Set it to :disabled if you don't want to use this feature
|
@@ -96,8 +103,22 @@ module Decidim
|
|
96
103
|
true
|
97
104
|
end
|
98
105
|
|
99
|
-
|
100
|
-
|
106
|
+
# This transforms the proposal voting into a weighted voting
|
107
|
+
# Different processors can be registered and configured in the component's settings
|
108
|
+
# Each processor must account for a cell to display how to vote and a cell to display the results
|
109
|
+
config_accessor :weighted_proposal_voting do
|
110
|
+
true
|
111
|
+
end
|
112
|
+
|
113
|
+
# Additional sorting methods for proposals
|
114
|
+
# this setting also stores the selected sorting method in the user's session
|
115
|
+
config_accessor :additional_proposal_sortings do
|
116
|
+
[
|
117
|
+
:supported_first,
|
118
|
+
:supported_last,
|
119
|
+
:az,
|
120
|
+
:za
|
121
|
+
]
|
101
122
|
end
|
102
123
|
|
103
124
|
# allows admins to created specific CSS snippets affecting only some specific parts
|
@@ -236,13 +257,31 @@ module Decidim
|
|
236
257
|
]
|
237
258
|
end
|
238
259
|
|
260
|
+
# Which components will be tampered to add the voting registry override
|
261
|
+
config_accessor :voting_components do
|
262
|
+
[:proposals, :reporting_propposals]
|
263
|
+
end
|
264
|
+
|
265
|
+
# Public: Stores an instance of ContentBlockRegistry
|
266
|
+
def self.voting_registry
|
267
|
+
@voting_registry ||= Decidim::ManifestRegistry.new("decidim_awesome/voting")
|
268
|
+
end
|
269
|
+
|
239
270
|
#
|
240
271
|
# HELPERS
|
241
272
|
#
|
242
273
|
# pass a single config var or an array of them
|
243
274
|
# any non disabled match will return as true
|
275
|
+
def self.possible_additional_proposal_sortings
|
276
|
+
@possible_additional_proposal_sortings ||= additional_proposal_sortings.to_a.filter_map do |sort|
|
277
|
+
next unless sort.to_sym.in?([:az, :za, :supported_first, :supported_last])
|
278
|
+
|
279
|
+
sort.to_s
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
244
283
|
def self.enabled?(config_vars)
|
245
|
-
config_vars = [config_vars] unless config_vars.respond_to?(:
|
284
|
+
config_vars = [config_vars] unless config_vars.respond_to?(:any?)
|
246
285
|
|
247
286
|
config_vars.any? do |item|
|
248
287
|
next unless config.has_key?(item.to_sym)
|
@@ -255,7 +294,7 @@ module Decidim
|
|
255
294
|
@registered_components ||= []
|
256
295
|
end
|
257
296
|
|
258
|
-
#
|
297
|
+
# Wrap registered components to register it later, after initializing
|
259
298
|
# so we can honor disabled_components config
|
260
299
|
def self.register_component(manifest, &block)
|
261
300
|
registered_components << [manifest, block]
|
@@ -61,6 +61,13 @@ module Decidim
|
|
61
61
|
@awesome_proposal_custom_fields ||= awesome_config_instance.collect_sub_configs_values("proposal_custom_field")
|
62
62
|
end
|
63
63
|
|
64
|
+
# this will check if the current component has been configured to use a custom voting manifest
|
65
|
+
def awesome_voting_manifest_for(component)
|
66
|
+
return nil unless component.settings.respond_to? :awesome_voting_manifest
|
67
|
+
|
68
|
+
DecidimAwesome.voting_registry.find(component.settings.awesome_voting_manifest)
|
69
|
+
end
|
70
|
+
|
64
71
|
def version_prefix
|
65
72
|
"v#{Decidim.version[0..3]}"
|
66
73
|
end
|
@@ -23,6 +23,10 @@ decidim-core:
|
|
23
23
|
decidim-0.25: 63532a04fcf07cf92b789833a9421416
|
24
24
|
decidim-0.26: 636943ccb2e994fe0124dc87e72e49e9
|
25
25
|
decidim-proposals:
|
26
|
+
/lib/decidim/proposals/proposal_serializer.rb:
|
27
|
+
decidim-0.26: 2d817775f79a19cfcf9cfae8e5b68c5a
|
28
|
+
/lib/decidim/api/proposal_type.rb:
|
29
|
+
decidim-0.26: e38e4875e408ec4f658e28725c5a94d4
|
26
30
|
/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb:
|
27
31
|
decidim-0.24: db69edd0ba8ffa3965a5c44a6bfaba8d
|
28
32
|
decidim-0.27: b495d37088ecebcbe4ac9563bb3498d5
|
@@ -33,6 +37,9 @@ decidim-proposals:
|
|
33
37
|
decidim-0.27: c0ebeac39ebe4926bf0e5fc585a384d7
|
34
38
|
decidim-0.27.1: a4f902d1c4829a7f7f62299686f8604e
|
35
39
|
decidim-0.27.3: a9c9ed5eedaf7bf80afaf9ff5a89c254
|
40
|
+
/app/controllers/decidim/proposals/proposal_votes_controller.rb:
|
41
|
+
decidim-0.26: 65ca00fdb4aaf30da37ad75aaf66e70a
|
42
|
+
decidim-0.27: a1d416491752f4c2fb2668b29ceb8e09
|
36
43
|
/app/views/decidim/proposals/collaborative_drafts/_edit_form_fields.html.erb:
|
37
44
|
# this file is not overriden anymore but it needs to be the last version
|
38
45
|
decidim-0.26: 519a0d34a9ffbd8b9c26d9b68ff4e2a3
|
@@ -44,3 +51,13 @@ decidim-proposals:
|
|
44
51
|
/app/views/decidim/proposals/admin/proposals/_form.html.erb:
|
45
52
|
decidim-0.25: 90a04984d4269398b7cd21aa33763a1f
|
46
53
|
decidim-0.27: f60168e432e1d419e5aec5d3d1e53f0e
|
54
|
+
/app/views/decidim/proposals/proposals/_vote_button.html.erb:
|
55
|
+
decidim-0.27: f7202c37fe042cd816a6f9fd0f9e6807
|
56
|
+
/app/views/decidim/proposals/proposals/_votes_count.html.erb:
|
57
|
+
decidim-0.27: 33339aae5004361e24c4c5b009cc2888
|
58
|
+
/app/cells/decidim/proposals/proposal_m_cell.rb:
|
59
|
+
decidim-0.26: 21cc09a45efa20dbcda5c943d820c867
|
60
|
+
decidim-0.27: 9df97ded3e6594b65b85fcbf1e5b0644
|
61
|
+
decidim-0.27.4: ce3b30cdddfee547b8fb089c0fddd8a4
|
62
|
+
/app/cells/decidim/proposals/proposal_m/footer.erb:
|
63
|
+
decidim-0.26: 7ade5bbd8412f44f1c4ed913ae1834c6
|
@@ -75,11 +75,19 @@ module Decidim
|
|
75
75
|
)
|
76
76
|
end
|
77
77
|
|
78
|
-
# Checks if some config
|
79
|
-
def
|
78
|
+
# Checks if some config setting is enabled in a certain context
|
79
|
+
def enabled_in_context?(setting)
|
80
80
|
config[setting]
|
81
81
|
end
|
82
82
|
|
83
|
+
# returns true if some setting is constrained in the current context
|
84
|
+
# if no constraints defined, applies to everything
|
85
|
+
def constrained_in_context?(setting)
|
86
|
+
return true unless @vars.exists?(var: setting)
|
87
|
+
|
88
|
+
@vars.where(var: setting).any? { |v| valid_in_context?(v.all_constraints) }
|
89
|
+
end
|
90
|
+
|
83
91
|
# checks if some constraint blocks the validity fot the current context
|
84
92
|
def valid_in_context?(constraints)
|
85
93
|
# if no constraints defined, applies to everything
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "rails"
|
4
|
+
require "deface"
|
4
5
|
require "decidim/core"
|
5
6
|
require "decidim/decidim_awesome/awesome_helpers"
|
6
7
|
|
@@ -26,6 +27,8 @@ module Decidim
|
|
26
27
|
end
|
27
28
|
# Include additional helpers globally
|
28
29
|
ActionView::Base.include(Decidim::DecidimAwesome::AwesomeHelpers)
|
30
|
+
# Also for cells
|
31
|
+
Decidim::ViewModel.include(Decidim::DecidimAwesome::AwesomeHelpers)
|
29
32
|
|
30
33
|
# Override EtiquetteValidator
|
31
34
|
EtiquetteValidator.include(Decidim::DecidimAwesome::EtiquetteValidatorOverride) if DecidimAwesome.enabled?([:validate_title_max_caps_percent,
|
@@ -51,6 +54,16 @@ module Decidim
|
|
51
54
|
# override user's admin property
|
52
55
|
Decidim::User.include(Decidim::DecidimAwesome::UserOverride) if DecidimAwesome.enabled?(:scoped_admins)
|
53
56
|
|
57
|
+
if DecidimAwesome.enabled?(:weighted_proposal_voting)
|
58
|
+
# add vote weight to proposal vote
|
59
|
+
Decidim::Proposals::ProposalVote.include(Decidim::DecidimAwesome::HasVoteWeight)
|
60
|
+
# add vote weight cache to proposal
|
61
|
+
Decidim::Proposals::Proposal.include(Decidim::DecidimAwesome::HasProposalExtraFields)
|
62
|
+
Decidim::Proposals::ProposalSerializer.include(Decidim::DecidimAwesome::ProposalSerializerOverride)
|
63
|
+
Decidim::Proposals::ProposalType.include(Decidim::DecidimAwesome::ProposalTypeOverride)
|
64
|
+
Decidim::Proposals::ProposalMCell.include(Decidim::DecidimAwesome::ProposalMCellOverride)
|
65
|
+
end
|
66
|
+
|
54
67
|
Decidim::MenuPresenter.include(Decidim::DecidimAwesome::MenuPresenterOverride)
|
55
68
|
Decidim::MenuItemPresenter.include(Decidim::DecidimAwesome::MenuItemPresenterOverride)
|
56
69
|
|
@@ -73,18 +86,83 @@ module Decidim
|
|
73
86
|
Decidim::Proposals::ApplicationHelper.include(Decidim::DecidimAwesome::Proposals::ApplicationHelperOverride)
|
74
87
|
Decidim::AmendmentsHelper.include(Decidim::DecidimAwesome::AmendmentsHelperOverride)
|
75
88
|
end
|
89
|
+
|
90
|
+
if DecidimAwesome.enabled?(:weighted_proposal_voting)
|
91
|
+
Decidim::Proposals::ProposalVotesController.include(Decidim::DecidimAwesome::Proposals::ProposalVotesControllerOverride)
|
92
|
+
end
|
93
|
+
|
94
|
+
Decidim::Proposals::ProposalsController.include(Decidim::DecidimAwesome::Proposals::OrderableOverride) if DecidimAwesome.enabled?(:additional_proposal_sortings)
|
76
95
|
end
|
77
96
|
end
|
78
97
|
|
79
|
-
initializer "
|
98
|
+
initializer "decidim_decidim_awesome.middleware" do |app|
|
80
99
|
app.config.middleware.insert_after Decidim::Middleware::CurrentOrganization, Decidim::DecidimAwesome::CurrentConfig
|
81
100
|
end
|
82
101
|
|
102
|
+
initializer "decidim_decidim_awesome.additional_proposal_sortings" do |_app|
|
103
|
+
if DecidimAwesome.enabled?(:additional_proposal_sortings)
|
104
|
+
Decidim.component_registry.find(:proposals).tap do |component|
|
105
|
+
component.settings(:global) do |settings|
|
106
|
+
settings.attribute :default_sort_order, type: :select, default: "default", choices: -> { ["default"] + DecidimAwesome.possible_additional_proposal_sortings }
|
107
|
+
end
|
108
|
+
component.settings(:step) do |settings|
|
109
|
+
settings.attribute :default_sort_order, type: :select, include_blank: true, choices: -> { ["default"] + DecidimAwesome.possible_additional_proposal_sortings }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
initializer "decidim_decidim_awesome.weighted_proposal_voting" do |_app|
|
116
|
+
if DecidimAwesome.enabled?(:weighted_proposal_voting)
|
117
|
+
# register available processors
|
118
|
+
Decidim::DecidimAwesome.voting_registry.register(:voting_cards) do |voting|
|
119
|
+
voting.show_vote_button_view = "decidim/decidim_awesome/voting/voting_cards/show_vote_button"
|
120
|
+
voting.show_votes_count_view = "decidim/decidim_awesome/voting/voting_cards/show_votes_count"
|
121
|
+
voting.show_votes_count_view = "" # hide votes count if needed
|
122
|
+
voting.proposal_m_cell_footer = "decidim/decidim_awesome/voting/voting_cards/proposal_m_cell_footer"
|
123
|
+
voting.weight_validator do |weight, context|
|
124
|
+
allowed = [1, 2, 3]
|
125
|
+
allowed << 0 if context[:proposal]&.component&.settings&.voting_cards_show_abstain
|
126
|
+
weight.in? allowed
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
Decidim::DecidimAwesome.voting_components&.each do |manifest|
|
131
|
+
component = Decidim.component_registry.find(manifest)
|
132
|
+
next unless component
|
133
|
+
|
134
|
+
component.settings(:global) do |settings|
|
135
|
+
settings.attribute :awesome_voting_manifest,
|
136
|
+
type: :select,
|
137
|
+
default: "",
|
138
|
+
choices: -> { ["default"] + Decidim::DecidimAwesome.voting_registry.manifests.map(&:name) },
|
139
|
+
readonly: lambda { |context|
|
140
|
+
Decidim::Proposals::Proposal.where(component: context[:component]).where.not(proposal_votes_count: 0).any?
|
141
|
+
}
|
142
|
+
settings.attribute :voting_cards_box_title,
|
143
|
+
type: :string,
|
144
|
+
translated: true
|
145
|
+
settings.attribute :voting_cards_show_modal_help,
|
146
|
+
type: :boolean,
|
147
|
+
default: true
|
148
|
+
settings.attribute :voting_cards_show_abstain,
|
149
|
+
type: :boolean,
|
150
|
+
default: false
|
151
|
+
settings.attribute :voting_cards_instructions,
|
152
|
+
type: :text,
|
153
|
+
translated: true,
|
154
|
+
editor: true
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
83
160
|
initializer "decidim_decidim_awesome.webpacker.assets_path" do
|
84
161
|
Decidim.register_assets_path File.expand_path("app/packs", root)
|
85
162
|
end
|
86
163
|
|
87
|
-
|
164
|
+
# Votings may override proposals cells, let's be sure to add these paths after the proposal component initializer
|
165
|
+
initializer "decidim_decidim_awesome.add_cells_view_paths", before: "decidim_proposals.add_cells_view_paths" do
|
88
166
|
Cell::ViewModel.view_paths << File.expand_path("#{Decidim::DecidimAwesome::Engine.root}/app/cells")
|
89
167
|
Cell::ViewModel.view_paths << File.expand_path("#{Decidim::DecidimAwesome::Engine.root}/app/views")
|
90
168
|
end
|
@@ -41,4 +41,22 @@ FactoryBot.define do
|
|
41
41
|
manifest_name { :awesome_iframe }
|
42
42
|
participatory_space { create(:participatory_process, :with_steps, organization: organization) }
|
43
43
|
end
|
44
|
+
|
45
|
+
factory :awesome_vote_weight, class: "Decidim::DecidimAwesome::VoteWeight" do
|
46
|
+
vote { create :proposal_vote }
|
47
|
+
sequence(:weight) { |n| n }
|
48
|
+
end
|
49
|
+
|
50
|
+
factory :awesome_proposal_extra_fields, class: "Decidim::DecidimAwesome::ProposalExtraField" do
|
51
|
+
proposal { create :proposal }
|
52
|
+
|
53
|
+
trait :with_votes do
|
54
|
+
after :create do |weight|
|
55
|
+
5.times.collect do |n|
|
56
|
+
vote = create(:proposal_vote, proposal: weight.proposal, author: create(:user, organization: weight.proposal.organization))
|
57
|
+
create(:awesome_vote_weight, vote: vote, weight: n + 1)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
44
62
|
end
|
@@ -23,7 +23,9 @@ Decidim::DecidimAwesome.configure do |config|
|
|
23
23
|
:validate_body_min_length,
|
24
24
|
:validate_body_max_caps_percent,
|
25
25
|
:validate_body_max_marks_together,
|
26
|
-
:validate_body_start_with_caps
|
26
|
+
:validate_body_start_with_caps,
|
27
|
+
:weighted_proposal_voting,
|
28
|
+
:additional_proposal_scopes
|
27
29
|
].each do |conf|
|
28
30
|
config.send("#{conf}=", :disabled)
|
29
31
|
end
|
@@ -31,3 +33,10 @@ Decidim::DecidimAwesome.configure do |config|
|
|
31
33
|
config.disabled_components = [:awesome_map, :awesome_iframe]
|
32
34
|
end
|
33
35
|
end
|
36
|
+
|
37
|
+
if Decidim::DecidimAwesome.legacy_version?
|
38
|
+
Rails.application.config.to_prepare do
|
39
|
+
Decidim::Api::Schema.max_complexity = 5000
|
40
|
+
Decidim::Api::Schema.max_depth = 50
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class VotingManifest
|
6
|
+
include ActiveModel::Model
|
7
|
+
# From 0.27 onwards, Virtus is deprecated
|
8
|
+
if defined? Decidim::AttributeObject::Model
|
9
|
+
include Decidim::AttributeObject::Model
|
10
|
+
else
|
11
|
+
include Virtus.model
|
12
|
+
end
|
13
|
+
|
14
|
+
attribute :name, Symbol
|
15
|
+
|
16
|
+
# path to overriden views for the proposal show page vote button
|
17
|
+
# not defining it will use the original view from Decidim
|
18
|
+
# setting it to an empty string will hide the original content
|
19
|
+
|
20
|
+
# original is decidim-proposals/app/views/proposals/proposals/_vote_button.html.erb
|
21
|
+
attribute :show_vote_button_view, String
|
22
|
+
# original is decidim-proposals/app/views/proposals/proposals/_votes_count.html.erb
|
23
|
+
attribute :show_votes_count_view, String
|
24
|
+
# original is decidim-proposals/app/cells/proposals/proposal_m/footer.erb
|
25
|
+
attribute :proposal_m_cell_footer, String
|
26
|
+
|
27
|
+
# a callback that will be called by the method valid_weight?
|
28
|
+
# Do not access this parameter directly, use the weight_validator method to register a block
|
29
|
+
attribute :on_weight_validation, Proc, default: nil
|
30
|
+
|
31
|
+
validates :name, presence: true
|
32
|
+
|
33
|
+
# registers a weight validator
|
34
|
+
def weight_validator(&block)
|
35
|
+
@on_weight_validation = block
|
36
|
+
end
|
37
|
+
|
38
|
+
# validates the weight using the Proc defined by weight_validator
|
39
|
+
# Receives the weight and a context with the user and the proposal to be voted
|
40
|
+
def valid_weight?(weight, context = {})
|
41
|
+
return true unless @on_weight_validation
|
42
|
+
|
43
|
+
@on_weight_validation.call(weight, **context)
|
44
|
+
end
|
45
|
+
|
46
|
+
# registers an optional label generator block
|
47
|
+
def label_generator(&block)
|
48
|
+
@on_label_generation = block
|
49
|
+
end
|
50
|
+
|
51
|
+
# returns the label used in export or other places for a given weight
|
52
|
+
# defaults to a I18n key scoped under decidim_awesome
|
53
|
+
def label_for(weight, context = {})
|
54
|
+
return I18n.t("decidim.decidim_awesome.voting.#{name}.weights.weight_#{weight}", default: "weight_#{weight}") unless @on_label_generation
|
55
|
+
|
56
|
+
@on_label_generation.call(weight, **context)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rake::Task["decidim:webpacker:install"].enhance do
|
4
|
+
Rake::Task["decidim_decidim_awesome:webpacker:install"].invoke
|
5
|
+
end
|
6
|
+
|
7
|
+
Rake::Task["decidim:webpacker:upgrade"].enhance do
|
8
|
+
Rake::Task["decidim_decidim_awesome:webpacker:install"].invoke
|
9
|
+
end
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "decidim-module-decidim_awesome",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.3",
|
4
4
|
"description": "Mods and tweaks for Decidim",
|
5
5
|
"main": "index.js",
|
6
6
|
"directories": {
|
@@ -43,9 +43,9 @@
|
|
43
43
|
"@babel/plugin-transform-runtime": "^7.19.6",
|
44
44
|
"@babel/preset-env": "^7.20.2",
|
45
45
|
"@babel/preset-react": "^7.18.6",
|
46
|
-
"@decidim/dev": "0.27.
|
47
|
-
"@decidim/eslint-config": "0.27.
|
48
|
-
"@decidim/stylelint-config": "0.27.
|
46
|
+
"@decidim/dev": "0.27.4",
|
47
|
+
"@decidim/eslint-config": "0.27.4",
|
48
|
+
"@decidim/stylelint-config": "0.27.4",
|
49
49
|
"eslint-config-prettier": "^8.2.0",
|
50
50
|
"eslint-config-standard": "^11.0.0",
|
51
51
|
"eslint-plugin-import": "^2.22.0",
|
@@ -53,6 +53,7 @@
|
|
53
53
|
"sass-embedded": "~1.57.1"
|
54
54
|
},
|
55
55
|
"dependencies": {
|
56
|
+
"@rails/actioncable": "^6.1.7-6",
|
56
57
|
"codemirror": "^5.65.0",
|
57
58
|
"europa": "^4.0.0",
|
58
59
|
"form-storage": "^1.3.5",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-decidim_awesome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Vergés
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-admin
|
@@ -50,6 +50,20 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0.28'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: deface
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.5'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.5'
|
53
67
|
- !ruby/object:Gem::Dependency
|
54
68
|
name: sassc
|
55
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,11 +109,22 @@ files:
|
|
95
109
|
- LICENSE-AGPLv3.txt
|
96
110
|
- README.md
|
97
111
|
- Rakefile
|
112
|
+
- app/cells/concerns/decidim/decidim_awesome/proposal_m_cell_override.rb
|
98
113
|
- app/cells/decidim/decidim_awesome/content_blocks/map/error.erb
|
99
114
|
- app/cells/decidim/decidim_awesome/content_blocks/map/show.erb
|
100
115
|
- app/cells/decidim/decidim_awesome/content_blocks/map_cell.rb
|
101
116
|
- app/cells/decidim/decidim_awesome/content_blocks/map_form/show.erb
|
102
117
|
- app/cells/decidim/decidim_awesome/content_blocks/map_form_cell.rb
|
118
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_base_cell.rb
|
119
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_counter/show.erb
|
120
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_counter/vote_button.erb
|
121
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_counter_cell.rb
|
122
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/show.erb
|
123
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_proposal/vote_block_for.erb
|
124
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_cell.rb
|
125
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal/show.erb
|
126
|
+
- app/cells/decidim/decidim_awesome/voting/voting_cards_proposal_modal_cell.rb
|
127
|
+
- app/cells/decidim/proposals/proposal_m/footer.erb
|
103
128
|
- app/commands/concerns/decidim/decidim_awesome/admin/needs_constraint_helpers.rb
|
104
129
|
- app/commands/decidim/decidim_awesome/admin/create_constraint.rb
|
105
130
|
- app/commands/decidim/decidim_awesome/admin/create_custom_redirect.rb
|
@@ -124,6 +149,8 @@ files:
|
|
124
149
|
- app/controllers/concerns/decidim/decidim_awesome/admin_accountability/admin/filterable_helper.rb
|
125
150
|
- app/controllers/concerns/decidim/decidim_awesome/needs_awesome_config.rb
|
126
151
|
- app/controllers/concerns/decidim/decidim_awesome/not_found_redirect.rb
|
152
|
+
- app/controllers/concerns/decidim/decidim_awesome/proposals/orderable_override.rb
|
153
|
+
- app/controllers/concerns/decidim/decidim_awesome/proposals/proposal_votes_controller_override.rb
|
127
154
|
- app/controllers/decidim/decidim_awesome/admin/admin_accountability_controller.rb
|
128
155
|
- app/controllers/decidim/decidim_awesome/admin/application_controller.rb
|
129
156
|
- app/controllers/decidim/decidim_awesome/admin/checks_controller.rb
|
@@ -154,12 +181,25 @@ files:
|
|
154
181
|
- app/jobs/decidim/decidim_awesome/export_admin_actions_job.rb
|
155
182
|
- app/jobs/decidim/decidim_awesome/migrate_legacy_images_job.rb
|
156
183
|
- app/middleware/decidim/decidim_awesome/current_config.rb
|
184
|
+
- app/models/concerns/decidim/decidim_awesome/has_proposal_extra_fields.rb
|
185
|
+
- app/models/concerns/decidim/decidim_awesome/has_vote_weight.rb
|
186
|
+
- app/models/concerns/decidim/decidim_awesome/user_override.rb
|
157
187
|
- app/models/decidim/decidim_awesome/application_record.rb
|
158
188
|
- app/models/decidim/decidim_awesome/awesome_config.rb
|
159
189
|
- app/models/decidim/decidim_awesome/config_constraint.rb
|
160
190
|
- app/models/decidim/decidim_awesome/editor_image.rb
|
161
191
|
- app/models/decidim/decidim_awesome/paper_trail_version.rb
|
162
|
-
- app/models/decidim/decidim_awesome/
|
192
|
+
- app/models/decidim/decidim_awesome/proposal_extra_field.rb
|
193
|
+
- app/models/decidim/decidim_awesome/vote_weight.rb
|
194
|
+
- app/overrides/decidim/proposals/admin/proposals/_form/replace_editor.html.erb.deface
|
195
|
+
- app/overrides/decidim/proposals/proposals/_vote_button/replace_vote_button.html.erb.deface
|
196
|
+
- app/overrides/decidim/proposals/proposals/_votes_count/replace_counter.html.erb.deface
|
197
|
+
- app/overrides/layouts/decidim/_application/add_intergram.html.erb.deface
|
198
|
+
- app/overrides/layouts/decidim/_head/add_awesome_legacy_scripts.rb
|
199
|
+
- app/overrides/layouts/decidim/_head/add_awesome_tags.html.erb.deface
|
200
|
+
- app/overrides/layouts/decidim/admin/_application/add_intergram.html.erb.deface
|
201
|
+
- app/overrides/layouts/decidim/admin/_header/replace_scripts.html.erb.deface
|
202
|
+
- app/overrides/layouts/decidim/admin/_header/replace_styles.html.erb.deface
|
163
203
|
- app/packs/entrypoints/decidim_admin_decidim_awesome.js
|
164
204
|
- app/packs/entrypoints/decidim_admin_decidim_awesome.scss
|
165
205
|
- app/packs/entrypoints/decidim_admin_decidim_awesome_custom_fields.js
|
@@ -170,6 +210,8 @@ files:
|
|
170
210
|
- app/packs/entrypoints/decidim_decidim_awesome_iframe.scss
|
171
211
|
- app/packs/entrypoints/decidim_decidim_awesome_map.js
|
172
212
|
- app/packs/entrypoints/decidim_decidim_awesome_map.scss
|
213
|
+
- app/packs/images/decidim/decidim_awesome/handcard.svg
|
214
|
+
- app/packs/images/decidim/decidim_awesome/handcheck.svg
|
173
215
|
- app/packs/images/decidim/decidim_awesome/pokecode-logo.png
|
174
216
|
- app/packs/src/decidim/decidim_awesome/admin/auto_edit.js
|
175
217
|
- app/packs/src/decidim/decidim_awesome/admin/check_redirections.js
|
@@ -177,6 +219,7 @@ files:
|
|
177
219
|
- app/packs/src/decidim/decidim_awesome/admin/constraints.js
|
178
220
|
- app/packs/src/decidim/decidim_awesome/admin/custom_fields_builder.js
|
179
221
|
- app/packs/src/decidim/decidim_awesome/admin/form_exit_warn.js
|
222
|
+
- app/packs/src/decidim/decidim_awesome/admin/proposal_sortings.js
|
180
223
|
- app/packs/src/decidim/decidim_awesome/admin/user_picker.js
|
181
224
|
- app/packs/src/decidim/decidim_awesome/awesome_admin.js
|
182
225
|
- app/packs/src/decidim/decidim_awesome/awesome_application.js
|
@@ -197,6 +240,7 @@ files:
|
|
197
240
|
- app/packs/src/decidim/decidim_awesome/forms/rich_text_plugin.js
|
198
241
|
- app/packs/src/decidim/decidim_awesome/proposals/custom_fields.js
|
199
242
|
- app/packs/src/decidim/decidim_awesome/proposals/images.js
|
243
|
+
- app/packs/src/decidim/decidim_awesome/voting/voting_cards.js
|
200
244
|
- app/packs/src/vendor/jquery.truncate.js
|
201
245
|
- app/packs/stylesheets/decidim/decidim_awesome/admin/auto_edits.scss
|
202
246
|
- app/packs/stylesheets/decidim/decidim_awesome/admin/check_redirections.scss
|
@@ -211,6 +255,7 @@ files:
|
|
211
255
|
- app/packs/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss
|
212
256
|
- app/packs/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss
|
213
257
|
- app/packs/stylesheets/decidim/decidim_awesome/forms/autosave.scss
|
258
|
+
- app/packs/stylesheets/decidim/decidim_awesome/voting/voting_cards.scss
|
214
259
|
- app/packs/stylesheets/vendor/select2-foundation-theme.scss
|
215
260
|
- app/permissions/decidim/decidim_awesome/admin/permissions.rb
|
216
261
|
- app/permissions/decidim/decidim_awesome/permissions.rb
|
@@ -220,7 +265,9 @@ files:
|
|
220
265
|
- app/presenters/decidim/decidim_awesome/participatory_space_role_presenter.rb
|
221
266
|
- app/presenters/decidim/decidim_awesome/role_base_presenter.rb
|
222
267
|
- app/presenters/decidim/decidim_awesome/user_entity_presenter.rb
|
268
|
+
- app/serializers/concerns/decidim/decidim_awesome/proposal_serializer_override.rb
|
223
269
|
- app/serializers/decidim/decidim_awesome/paper_trail_version_serializer.rb
|
270
|
+
- app/types/concerns/decidim/decidim_awesome/proposal_type_override.rb
|
224
271
|
- app/uploaders/decidim/cw/decidim_awesome/image_uploader.rb
|
225
272
|
- app/uploaders/decidim/decidim_awesome/image_uploader.rb
|
226
273
|
- app/validators/concerns/decidim/decidim_awesome/etiquette_validator_override.rb
|
@@ -257,17 +304,13 @@ files:
|
|
257
304
|
- app/views/decidim/decidim_awesome/map_component/map/_map_template.html.erb
|
258
305
|
- app/views/decidim/decidim_awesome/map_component/map/error.html.erb
|
259
306
|
- app/views/decidim/decidim_awesome/map_component/map/show.html.erb
|
260
|
-
- app/views/decidim/
|
261
|
-
- app/views/
|
262
|
-
- app/views/
|
263
|
-
- app/views/layouts/decidim/admin/decidim_awesome.html.erb
|
307
|
+
- app/views/decidim/decidim_awesome/voting/voting_cards/_proposal_m_cell_footer.erb
|
308
|
+
- app/views/decidim/decidim_awesome/voting/voting_cards/_show_vote_button.html.erb
|
309
|
+
- app/views/decidim/decidim_awesome/voting/voting_cards/_show_votes_count.html.erb
|
264
310
|
- app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb
|
265
311
|
- app/views/layouts/decidim/decidim_awesome/_custom_styles.html.erb
|
266
312
|
- app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb
|
267
|
-
- app/views/
|
268
|
-
- app/views/v0.26/layouts/decidim/admin/_header.html.erb
|
269
|
-
- app/views/v0.27/layouts/decidim/_head.html.erb
|
270
|
-
- app/views/v0.27/layouts/decidim/admin/_header.html.erb
|
313
|
+
- app/views/layouts/decidim/decidim_awesome/admin/application.html.erb
|
271
314
|
- config/assets.rb
|
272
315
|
- config/i18n-tasks.yml
|
273
316
|
- config/locales/ca.yml
|
@@ -277,17 +320,22 @@ files:
|
|
277
320
|
- config/locales/es.yml
|
278
321
|
- config/locales/eu.yml
|
279
322
|
- config/locales/fr.yml
|
323
|
+
- config/locales/hu.yml
|
280
324
|
- config/locales/it.yml
|
281
325
|
- config/locales/ja.yml
|
326
|
+
- config/locales/lt.yml
|
282
327
|
- config/locales/nl.yml
|
283
328
|
- config/locales/pt-BR.yml
|
284
329
|
- config/locales/pt-PT.yml
|
285
330
|
- config/locales/pt.yml
|
331
|
+
- config/locales/ro-RO.yml
|
286
332
|
- config/locales/sv.yml
|
287
333
|
- db/migrate/20200324170000_create_decidim_awesome_config.rb
|
288
334
|
- db/migrate/20200324230936_create_awesome_editor_images.rb
|
289
335
|
- db/migrate/20200403142257_create_decidim_awesome_config_constraints.rb
|
290
336
|
- db/migrate/20210628150825_change_awesome_config_var_type.rb
|
337
|
+
- db/migrate/20231006113837_create_decidim_awesome_vote_weights.rb
|
338
|
+
- db/migrate/20231006113841_create_decidim_awesome_proposal_extra_fields.rb
|
291
339
|
- db/seeds.rb
|
292
340
|
- lib/decidim/decidim_awesome.rb
|
293
341
|
- lib/decidim/decidim_awesome/admin.rb
|
@@ -326,7 +374,9 @@ files:
|
|
326
374
|
- lib/decidim/decidim_awesome/test/shared_examples/scoped_admins_examples.rb
|
327
375
|
- lib/decidim/decidim_awesome/test/shared_examples/summary_examples.rb
|
328
376
|
- lib/decidim/decidim_awesome/version.rb
|
377
|
+
- lib/decidim/decidim_awesome/voting_manifest.rb
|
329
378
|
- lib/tasks/decidim_awesome_active_storage_migrations_tasks.rake
|
379
|
+
- lib/tasks/decidim_awesome_upgrade_tasks.rake
|
330
380
|
- lib/tasks/decidim_awesome_webpacker_tasks.rake
|
331
381
|
- package.json
|
332
382
|
homepage: https://github.com/decidim-ice/decidim-module-decidim_awesome
|