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.
- 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
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
module OrderableOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include Decidim::DecidimAwesome::NeedsAwesomeConfig
|
9
|
+
|
10
|
+
included do
|
11
|
+
before_action only: [:index] do
|
12
|
+
session[:order] = params[:order] if params[:order].present?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# read order from session if available
|
18
|
+
def order
|
19
|
+
@order ||= detect_order(session[:order]) || default_order
|
20
|
+
end
|
21
|
+
|
22
|
+
def possible_orders
|
23
|
+
@possible_orders ||= begin
|
24
|
+
possible_orders = %w(random recent)
|
25
|
+
possible_orders += awesome_additional_sortings
|
26
|
+
possible_orders << "most_voted" if most_voted_order_available?
|
27
|
+
possible_orders << "most_endorsed" if current_settings.endorsements_enabled?
|
28
|
+
possible_orders << "most_commented" if component_settings.comments_enabled?
|
29
|
+
possible_orders << "most_followed" << "with_more_authors"
|
30
|
+
possible_orders
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
35
|
+
def reorder(proposals)
|
36
|
+
case order
|
37
|
+
when "az"
|
38
|
+
proposals.order(Arel.sql("decidim_proposals_proposals.title->>'#{locale}' ASC,
|
39
|
+
decidim_proposals_proposals.title->'machine_translations'->>'#{locale}' ASC,
|
40
|
+
decidim_proposals_proposals.title->>'#{default_locale}' ASC"))
|
41
|
+
when "za"
|
42
|
+
proposals.order(Arel.sql("decidim_proposals_proposals.title->>'#{locale}' DESC,
|
43
|
+
decidim_proposals_proposals.title->'machine_translations'->>'#{locale}' DESC,
|
44
|
+
decidim_proposals_proposals.title->>'#{default_locale}' DESC"))
|
45
|
+
when "supported_first"
|
46
|
+
proposals.joins(my_votes_join).group(:id).order(Arel.sql("COUNT(decidim_proposals_proposal_votes.id) DESC"))
|
47
|
+
when "supported_last"
|
48
|
+
proposals.joins(my_votes_join).group(:id).order(Arel.sql("COUNT(decidim_proposals_proposal_votes.id) ASC"))
|
49
|
+
when "most_commented"
|
50
|
+
proposals.left_joins(:comments).group(:id).order(Arel.sql("COUNT(decidim_comments_comments.id) DESC"))
|
51
|
+
when "most_endorsed"
|
52
|
+
proposals.order(endorsements_count: :desc)
|
53
|
+
when "most_followed"
|
54
|
+
proposals.left_joins(:follows).group(:id).order(Arel.sql("COUNT(decidim_follows.id) DESC"))
|
55
|
+
when "most_voted"
|
56
|
+
proposals.order(proposal_votes_count: :desc)
|
57
|
+
when "random"
|
58
|
+
proposals.order_randomly(random_seed)
|
59
|
+
when "recent"
|
60
|
+
proposals.order(published_at: :desc)
|
61
|
+
when "with_more_authors"
|
62
|
+
proposals.order(coauthorships_count: :desc)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
66
|
+
|
67
|
+
def my_votes_join
|
68
|
+
votes_table = Decidim::Proposals::ProposalVote.arel_table
|
69
|
+
proposals_table = Decidim::Proposals::Proposal.arel_table
|
70
|
+
Arel::Nodes::OuterJoin.new(
|
71
|
+
votes_table,
|
72
|
+
Arel::Nodes::On.new(
|
73
|
+
votes_table[:decidim_proposal_id].eq(proposals_table[:id])
|
74
|
+
.and(votes_table[:decidim_author_id].eq(current_user.id))
|
75
|
+
)
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def supported_order_available?
|
80
|
+
most_voted_order_available? && current_user
|
81
|
+
end
|
82
|
+
|
83
|
+
def awesome_additional_sortings
|
84
|
+
return [] unless DecidimAwesome.enabled?(:additional_proposal_sortings)
|
85
|
+
return [] if awesome_config[:additional_proposal_sortings].blank?
|
86
|
+
return [] unless awesome_config_instance.constrained_in_context?(:additional_proposal_sortings)
|
87
|
+
|
88
|
+
awesome_config[:additional_proposal_sortings].filter_map do |sort|
|
89
|
+
sort = sort.to_s
|
90
|
+
next unless sort.in? DecidimAwesome.possible_additional_proposal_sortings
|
91
|
+
next if sort.in?(%w(supported_first supported_last)) && !supported_order_available?
|
92
|
+
|
93
|
+
sort
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module Proposals
|
6
|
+
module ProposalVotesControllerOverride
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
include Decidim::DecidimAwesome::AwesomeHelpers
|
9
|
+
|
10
|
+
included do
|
11
|
+
# rubocop:disable Rails/LexicallyScopedActionFilter
|
12
|
+
before_action :validate_weight, only: :create
|
13
|
+
# rubocop:enable Rails/LexicallyScopedActionFilter
|
14
|
+
|
15
|
+
def create
|
16
|
+
enforce_permission_to :vote, :proposal, proposal: proposal
|
17
|
+
@from_proposals_list = params[:from_proposals_list] == "true"
|
18
|
+
|
19
|
+
Decidim::Proposals::VoteProposal.call(proposal, current_user) do
|
20
|
+
on(:ok) do
|
21
|
+
current_vote.weight = weight if current_vote && vote_manifest
|
22
|
+
|
23
|
+
proposal.reload
|
24
|
+
|
25
|
+
proposals = Decidim::Proposals::ProposalVote.where(
|
26
|
+
author: current_user,
|
27
|
+
proposal: Decidim::Proposals::Proposal.where(component: current_component)
|
28
|
+
).map(&:proposal)
|
29
|
+
|
30
|
+
expose(proposals: proposals)
|
31
|
+
render :update_buttons_and_counters
|
32
|
+
end
|
33
|
+
|
34
|
+
on(:invalid) do
|
35
|
+
render json: { error: I18n.t("proposal_votes.create.error", scope: "decidim.proposals") }, status: :unprocessable_entity
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def validate_weight
|
43
|
+
return unless vote_manifest
|
44
|
+
return if vote_manifest.valid_weight? weight, user: current_user, proposal: proposal
|
45
|
+
|
46
|
+
render json: { error: I18n.t("proposal_votes.create.error", scope: "decidim.proposals") }, status: :unprocessable_entity
|
47
|
+
end
|
48
|
+
|
49
|
+
def current_vote
|
50
|
+
@current_vote ||= Decidim::Proposals::ProposalVote.find_by(author: current_user, proposal: proposal)
|
51
|
+
end
|
52
|
+
|
53
|
+
def vote_manifest
|
54
|
+
@vote_manifest ||= awesome_voting_manifest_for(current_component)
|
55
|
+
end
|
56
|
+
|
57
|
+
def weight
|
58
|
+
params[:weight].to_i if params.has_key?(:weight)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -11,9 +11,9 @@ module Decidim
|
|
11
11
|
helper ConfigConstraintsHelpers
|
12
12
|
helper SystemCheckerHelpers
|
13
13
|
|
14
|
-
layout "decidim/admin/
|
14
|
+
layout "decidim/decidim_awesome/admin/application"
|
15
15
|
|
16
|
-
helper_method :head, :admin_head, :head_addons, :admin_addons
|
16
|
+
helper_method :head, :admin_head, :head_addons, :admin_addons
|
17
17
|
|
18
18
|
def migrate_images
|
19
19
|
Decidim::DecidimAwesome::MigrateLegacyImagesJob.perform_later(current_organization.id)
|
@@ -23,10 +23,6 @@ module Decidim
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def legacy_version?
|
27
|
-
DecidimAwesome.legacy_version?
|
28
|
-
end
|
29
|
-
|
30
26
|
def head
|
31
27
|
@head ||= Nokogiri::HTML(render_template("decidim/decidim_awesome/admin/checks/assets_tester"))
|
32
28
|
end
|
@@ -9,7 +9,7 @@ module Decidim
|
|
9
9
|
include ConfigConstraintsHelpers
|
10
10
|
helper ConfigConstraintsHelpers
|
11
11
|
|
12
|
-
layout "decidim/admin/
|
12
|
+
layout "decidim/decidim_awesome/admin/application"
|
13
13
|
|
14
14
|
helper_method :constraints_for, :users_for, :config_var
|
15
15
|
before_action do
|
@@ -8,7 +8,7 @@ module Decidim
|
|
8
8
|
include NeedsAwesomeConfig
|
9
9
|
include ConfigConstraintsHelpers
|
10
10
|
|
11
|
-
layout "decidim/admin/
|
11
|
+
layout "decidim/decidim_awesome/admin/application"
|
12
12
|
|
13
13
|
helper ConfigConstraintsHelpers
|
14
14
|
helper_method :current_items, :visibility_options, :target_options
|
@@ -30,6 +30,7 @@ module Decidim
|
|
30
30
|
attribute :validate_body_max_caps_percent, Integer, default: 25
|
31
31
|
attribute :validate_body_max_marks_together, Integer, default: 1
|
32
32
|
attribute :validate_body_start_with_caps, Boolean, default: true
|
33
|
+
attribute :additional_proposal_sortings, Array, default: Decidim::DecidimAwesome.possible_additional_proposal_sortings
|
33
34
|
|
34
35
|
# collect all keys anything not specified in the params (UpdateConfig command ignores it)
|
35
36
|
attr_accessor :valid_keys
|
@@ -52,6 +53,12 @@ module Decidim
|
|
52
53
|
instance
|
53
54
|
end
|
54
55
|
|
56
|
+
def additional_proposal_sorting_labels
|
57
|
+
Decidim::DecidimAwesome.possible_additional_proposal_sortings.index_by do |sorting|
|
58
|
+
I18n.t(sorting, scope: "decidim.proposals.proposals.orders")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
55
62
|
def css_syntax
|
56
63
|
scoped_styles.each do |key, code|
|
57
64
|
next unless code
|
@@ -25,7 +25,7 @@ module Decidim
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def sanitize_url(url, strip_host: true)
|
28
|
-
url = url.strip
|
28
|
+
url = url.strip
|
29
29
|
parsed = Addressable::URI.parse(url)
|
30
30
|
url = parsed.path if strip_host && parsed.host == current_organization.host
|
31
31
|
url = "/#{url}" unless url.match?(%r{^https?://|^/})
|
data/app/forms/decidim/decidim_awesome/proposals/proposal_wizard_create_step_form_override.rb
CHANGED
@@ -27,7 +27,7 @@ module Decidim
|
|
27
27
|
def override_validations?
|
28
28
|
return false if context.current_component.settings.participatory_texts_enabled
|
29
29
|
|
30
|
-
custom_fields.present? || awesome_config.
|
30
|
+
custom_fields.present? || awesome_config.enabled_in_context?(:use_markdown_editor)
|
31
31
|
end
|
32
32
|
|
33
33
|
def minimum_title_length
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module HasProposalExtraFields
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_one :extra_fields, foreign_key: "decidim_proposal_id", class_name: "Decidim::DecidimAwesome::ProposalExtraField", dependent: :destroy
|
10
|
+
|
11
|
+
def weight_count(weight)
|
12
|
+
(extra_fields && extra_fields.vote_weight_totals[weight.to_s]) || 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def vote_weights
|
16
|
+
@vote_weights ||= all_vote_weights.to_h { |weight| [manifest&.label_for(weight) || weight.to_s, weight_count(weight)] }
|
17
|
+
end
|
18
|
+
|
19
|
+
def manifest
|
20
|
+
@manifest ||= DecidimAwesome.voting_registry.find(component.settings.awesome_voting_manifest)
|
21
|
+
end
|
22
|
+
|
23
|
+
def all_vote_weights
|
24
|
+
@all_vote_weights ||= self.class.all_vote_weights_for(component)
|
25
|
+
end
|
26
|
+
|
27
|
+
def update_vote_weights!
|
28
|
+
extra_fields ||= Decidim::DecidimAwesome::ProposalExtraField.find_or_initialize_by(proposal: self)
|
29
|
+
extra_fields.vote_weight_totals = {}
|
30
|
+
votes.each do |vote|
|
31
|
+
extra_fields.vote_weight_totals[vote.weight] ||= 0
|
32
|
+
extra_fields.vote_weight_totals[vote.weight] += 1
|
33
|
+
end
|
34
|
+
extra_fields.save!
|
35
|
+
self.extra_fields = extra_fields
|
36
|
+
@vote_weights = nil
|
37
|
+
@all_vote_weights = nil
|
38
|
+
end
|
39
|
+
|
40
|
+
# collects all different weights stored along the different proposals in a different component
|
41
|
+
def self.all_vote_weights_for(component)
|
42
|
+
Decidim::DecidimAwesome::VoteWeight.where(
|
43
|
+
proposal_vote_id: Decidim::Proposals::ProposalVote.where(
|
44
|
+
proposal: Decidim::Proposals::Proposal.where(component: component)
|
45
|
+
)
|
46
|
+
).pluck(:weight)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
module HasVoteWeight
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_one :vote_weight, foreign_key: "proposal_vote_id", class_name: "Decidim::DecidimAwesome::VoteWeight", dependent: :destroy
|
10
|
+
|
11
|
+
delegate :weight, to: :vote_weight, allow_nil: true
|
12
|
+
delegate :update_vote_weight_totals!, to: :vote_weight, allow_nil: true
|
13
|
+
|
14
|
+
# this is necessary when vote changes from temporary to final
|
15
|
+
after_update :update_vote_weight!
|
16
|
+
|
17
|
+
def weight=(new_weight)
|
18
|
+
vote_weight = VoteWeight.find_or_initialize_by(vote: self)
|
19
|
+
vote_weight.weight = new_weight
|
20
|
+
vote_weight.save
|
21
|
+
reload
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_vote_weight!
|
25
|
+
VoteWeight.find_by(vote: self)&.update_vote_weight_totals!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class ProposalExtraField < ApplicationRecord
|
6
|
+
self.table_name = "decidim_awesome_proposal_extra_fields"
|
7
|
+
|
8
|
+
belongs_to :proposal, foreign_key: "decidim_proposal_id", class_name: "Decidim::Proposals::Proposal"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module DecidimAwesome
|
5
|
+
class VoteWeight < ApplicationRecord
|
6
|
+
self.table_name = "decidim_awesome_vote_weights"
|
7
|
+
belongs_to :vote, foreign_key: "proposal_vote_id", class_name: "Decidim::Proposals::ProposalVote"
|
8
|
+
|
9
|
+
delegate :proposal, to: :vote
|
10
|
+
|
11
|
+
after_destroy :update_vote_weight_totals!
|
12
|
+
after_save :update_vote_weight_totals!
|
13
|
+
|
14
|
+
def update_vote_weight_totals!
|
15
|
+
extra = Decidim::DecidimAwesome::ProposalExtraField.find_or_initialize_by(proposal: proposal)
|
16
|
+
extra.vote_weight_totals = extra.vote_weight_totals || {}
|
17
|
+
|
18
|
+
prev = weight_previous_change&.first
|
19
|
+
if prev.present?
|
20
|
+
extra.vote_weight_totals[prev.to_s] = Decidim::DecidimAwesome::VoteWeight.where(vote: proposal.votes, weight: prev).count
|
21
|
+
extra.vote_weight_totals.delete(prev.to_s) if extra.vote_weight_totals[prev.to_s].zero?
|
22
|
+
end
|
23
|
+
extra.vote_weight_totals[weight.to_s] = Decidim::DecidimAwesome::VoteWeight.where(vote: proposal.votes, weight: weight).count
|
24
|
+
extra.vote_weight_totals.delete(weight.to_s) if extra.vote_weight_totals[weight.to_s].zero?
|
25
|
+
extra.weight_total = extra.vote_weight_totals.inject(0) { |sum, (weight, count)| sum + (weight.to_i * count) }
|
26
|
+
extra.save!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!-- replace "erb[silent]:contains('if !current_settings.votes_hidden?')" -->
|
2
|
+
|
3
|
+
<% if view = awesome_voting_manifest_for(current_component)&.show_votes_count_view %>
|
4
|
+
<% if view.present? %>
|
5
|
+
<%= render view, local_assigns %>
|
6
|
+
<% elsif !current_settings.votes_hidden? %>
|
7
|
+
<%# Hidden placeholder for votes count to avoid update_button_adn_counter.js.erb cause a javascript console error %>
|
8
|
+
<span style="display: none" id="proposal-<%= proposal.id %>-votes-count"><%= proposal.proposal_votes_count || 0 %></span>
|
9
|
+
<% end %>
|
10
|
+
<% elsif !current_settings.votes_hidden? && current_component.participatory_space.can_participate?(current_user) %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
<!-- insert_bottom "body" -->
|
2
2
|
|
3
3
|
<% if show_public_intergram? %>
|
4
4
|
<%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_public_settings] } %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Deface::Override.new(virtual_path: "layouts/decidim/_head",
|
4
|
+
name: "legacy_awesome_scripts",
|
5
|
+
insert_after: 'erb[loud]:contains(\'javascript_pack_tag "decidim_core"\')') do
|
6
|
+
# NOTE THAT THIS ONLY APPLIES TO DECIDIM 0.26. This will be ignored in 0.27
|
7
|
+
'
|
8
|
+
<%= javascript_pack_tag "decidim_decidim_awesome", defer: false %>
|
9
|
+
<%= javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
|
10
|
+
'
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!-- insert_before "erb[loud]:contains('organization_colors')" -->
|
2
|
+
|
3
|
+
<%= stylesheet_pack_tag "decidim_decidim_awesome", media: "all" %>
|
4
|
+
<%= render(partial: "layouts/decidim/decidim_awesome/custom_styles") if awesome_custom_styles.present? %>
|
5
|
+
|
6
|
+
<%= render partial: "layouts/decidim/decidim_awesome/awesome_config" %>
|
7
|
+
<%# This will render scripts only on Decidim 0.27 %>
|
8
|
+
<% content_for :js_content do %>
|
9
|
+
<%= javascript_pack_tag "decidim_decidim_awesome", defer: false %>
|
10
|
+
<%= javascript_pack_tag("decidim_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
|
11
|
+
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
<!-- insert_bottom "body" -->
|
2
2
|
|
3
3
|
<% if awesome_config[:intergram_for_admins] %>
|
4
4
|
<%= render partial: "layouts/decidim/decidim_awesome/intergram_widget", locals: { settings: organization_awesome_config[:intergram_for_admins_settings] } %>
|
@@ -1,11 +1,6 @@
|
|
1
|
-
|
2
|
-
<%= csrf_meta_tags %>
|
3
|
-
<%= organization_colors %>
|
1
|
+
<!-- replace "erb[loud]:contains('javascript_pack_tag')" -->
|
4
2
|
|
5
3
|
<%= render partial: "layouts/decidim/decidim_awesome/awesome_config" %>
|
6
4
|
|
7
|
-
<%= stylesheet_pack_tag "decidim_admin_decidim_awesome", media: "all" %>
|
8
5
|
<%= javascript_pack_tag "decidim_admin_decidim_awesome", defer: false %>
|
9
6
|
<%= javascript_pack_tag("decidim_admin_decidim_awesome_custom_fields") if Decidim::DecidimAwesome.enabled?(:proposal_custom_fields) %>
|
10
|
-
|
11
|
-
<%= snippets.display(:head) %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg version="1.1" viewBox="0 0 669.06268 969.54651" xml:space="preserve" id="handcard" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
3
|
+
<desc id="desc1">Created with Fabric.js 3.5.0</desc>
|
4
|
+
<defs id="defs1" />
|
5
|
+
<g transform="matrix(10.7728,0,0,10.7728,334.531,484.77376)" id="982417">
|
6
|
+
<path style="opacity:1;fill:#000000;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0" transform="translate(-49.9993,-50.0003)"
|
7
|
+
d="M 80.938,56.066 C 80.579,52.743 79.386,49.587 77.709,46.711 74.703,41.554 70.207,37.346 65.427,33.849 64.044,32.838 62.615,31.854 61.124,31 c 0,-0.209 0,-0.418 0,-0.626 0,-5.312 0,-10.622 0,-15.933 0,-1.465 0,-2.932 0,-4.397 0,-2.024 -0.681,-4 -2.786,-4.753 -1.15,-0.412 -2.524,-0.265 -3.729,-0.265 -2.228,0 -4.455,0 -6.683,0 -5.787,0 -11.574,0 -17.363,0 -1.992,0 -3.984,0 -5.977,0 -1.823,0 -3.574,0.082 -4.797,1.724 -0.84,1.128 -0.843,2.358 -0.843,3.667 0,1.446 0,2.892 0,4.338 0,11.004 0,22.009 0,33.013 0,4.597 0,9.193 0,13.789 0,1.063 0,2.126 0,3.188 0,2.426 1.709,4.56 4.264,4.56 8.156,0 16.313,0 24.47,0 0.186,2.026 0.826,4.078 1.49,5.949 0.916,2.579 2.33,4.917 3.326,7.454 0.884,2.253 1.41,4.654 1.62,7.062 0.144,1.644 -0.204,3.627 1.431,4.653 0.861,0.54 1.828,0.577 2.807,0.577 2.412,0 4.824,0 7.237,0 2.574,0 5.148,0 7.723,0 1.755,0 3.438,-0.292 4.02,-2.279 0.387,-1.319 -0.104,-3.022 -0.21,-4.368 -0.145,-1.84 -0.189,-3.687 -0.165,-5.532 0.067,-5.036 0.778,-10.041 2.061,-14.91 0.584,-2.218 1.43,-4.356 1.788,-6.629 0.272,-1.73 0.32,-3.475 0.13,-5.216 z m -57.652,11.05 c -1.584,0 -2.151,-1.277 -2.151,-2.619 0,-3.297 0,-6.594 0,-9.891 0,-11.382 0,-22.763 0,-34.144 0,-3.47 0,-6.94 0,-10.41 0,-1.346 0.363,-2.839 2.075,-2.839 1.064,0 2.129,0 3.193,0 9.901,0 19.803,0 29.703,0 0.256,0 0.512,0 0.768,0 1.202,0 2.063,0.997 2.063,2.158 0,1 0,2 0,3 0,4.861 0,9.723 0,14.584 0,1.563 0,3.123 0,4.686 0,6.727 0,13.453 0,20.181 -0.247,-0.354 -0.494,-0.708 -0.741,-1.063 -0.357,-0.512 -0.703,-1.027 -1.065,-1.523 -0.552,-0.782 -1.157,-1.482 -1.889,-2.05 -0.065,-0.051 -0.133,-0.102 -0.2,-0.15 -0.04,-0.029 -0.079,-0.059 -0.12,-0.087 -0.22,-0.153 -0.452,-0.296 -0.7,-0.425 -1.724,-0.895 -3.705,-0.971 -5.468,-0.369 -0.278,0.091 -0.553,0.194 -0.823,0.314 -1.247,0.555 -2.22,1.473 -2.89,2.576 -0.857,1.356 -1.197,2.968 -1.027,4.537 0.108,1.127 0.481,2.229 1.141,3.188 0.008,0.011 0.014,0.021 0.02,0.031 2.402,3.438 4.803,6.876 7.204,10.314 -8.381,0 -16.764,0 -25.147,0 -1.317,0.001 -2.632,0.001 -3.946,0.001 z m 54.901,-4.058 c -0.726,2.635 -1.572,5.202 -2.125,7.887 -0.515,2.503 -0.861,5.042 -1.079,7.587 -0.325,3.791 -0.299,7.621 0.097,11.405 0.103,0.973 0.539,2.551 -0.503,2.844 -0.049,0.014 -0.08,0.023 -0.102,0.031 -0.016,-10e-4 -0.041,-10e-4 -0.08,0.001 -0.023,0 -0.047,0 -0.069,0 -0.222,0 -0.442,0 -0.664,0 -4.991,0 -9.983,0 -14.976,0 -0.554,0 -1.515,0.124 -1.96,-0.222 -0.503,-0.393 -0.331,-1.156 -0.353,-1.715 -0.04,-1.057 -0.161,-2.105 -0.311,-3.151 -0.368,-2.584 -1.153,-5.077 -2.242,-7.444 -1.081,-2.354 -2.255,-4.587 -3.029,-7.072 -0.401,-1.289 -0.767,-2.604 -0.912,-3.903 1.53,0 3.06,0 4.591,0 0.778,0 1.432,-0.949 0.944,-1.646 C 52.852,63.992 50.29,60.323 47.729,56.655 47.72,56.642 47.71,56.63 47.703,56.617 47.566,56.422 47.43,56.226 47.293,56.031 47.141,55.81 46.991,55.587 46.852,55.357 c -1.217,-2.139 -0.793,-4.683 1.099,-6.335 0.921,-0.757 2.11,-1.116 3.288,-1.063 1.083,0.078 2.15,0.51 2.996,1.216 0.531,0.491 0.952,1.087 1.383,1.703 0.436,0.624 0.871,1.247 1.306,1.87 0.002,0.003 0.003,0.005 0.005,0.007 0.72,1.03 1.439,2.061 2.158,3.091 0.006,0.008 0.013,0.015 0.019,0.022 1.585,2.27 3.17,4.538 4.755,6.808 0.801,1.147 2.698,0.056 1.889,-1.104 -1.541,-2.206 -3.082,-4.413 -4.623,-6.619 0,-7.136 0,-14.271 0,-21.405 2.207,1.357 4.299,2.944 6.261,4.608 4.684,3.972 8.976,8.925 10.741,14.916 0.963,3.27 0.962,6.701 0.058,9.986 z"
|
8
|
+
stroke-linecap="round" id="base" />
|
9
|
+
<path style="fill:#ffffff;stroke-width:2.1164"
|
10
|
+
d="m 594.70899,956.61376 c -3.28069,-3.2807 -4.2328,-7.05467 -4.2328,-16.77808 0,-32.11564 -9.83754,-74.34114 -25.60954,-109.92338 -26.95925,-60.82111 -31.6305,-72.2574 -36.42289,-89.17156 -2.80338,-9.89418 -5.6834,-21.08466 -6.40004,-24.86772 l -1.30298,-6.87831 h 25.9312 c 29.14115,0 35.40474,-2.18349 35.25312,-12.28931 -0.0589,-3.92805 -14.85858,-26.75473 -47.60495,-73.42498 -50.64801,-72.1837 -55.75178,-81.73001 -52.97606,-99.08843 2.08776,-13.05611 11.52456,-28.57643 21.58317,-35.49693 19.59236,-13.47989 44.84759,-12.01341 62.13882,3.60818 4.55252,4.11292 29.88304,38.42498 56.29006,76.24903 26.40701,37.82407 50.16106,70.17863 52.78676,71.89905 8.42428,5.51981 20.03703,-0.47898 20.03703,-10.3505 0,-1.63993 -11.90476,-20.0041 -26.45502,-40.80929 L 641.26984,551.46391 V 438.69492 c 0,-62.02294 0.5192,-112.76899 1.15378,-112.76899 2.60326,0 34.24198,22.50961 54.43477,38.72806 94.05661,75.54436 141.83302,162.75992 132.80692,242.43835 -1.16082,10.24728 -5.9989,32.36736 -10.7513,49.15577 -18.01143,63.62753 -24.50586,96.52031 -29.42743,149.04289 -2.93469,31.31895 -2.80074,82.23702 0.31386,119.30468 2.43431,28.97151 2.3662,30.55433 -1.4343,33.33333 -3.24663,2.37402 -21.26318,2.91755 -96.70716,2.91755 -89.89531,0 -92.84601,-0.12883 -96.94999,-4.2328 z" id="hand" transform="matrix(0.09282638,0,0,0.09282638,-48.375947,-46.413263)" />
|
11
|
+
<path style="stroke-width:2.1164"
|
12
|
+
d="m 225.39683,681.59712 c -2.32805,-0.95285 -6.13757,-3.8495 -8.46561,-6.43701 -4.18611,-4.65268 -4.23888,-8.07776 -4.7831,-310.46731 C 211.54624,30.27064 210.91004,48.349453 223.482,42.621285 c 3.82607,-1.743274 56.50183,-2.409645 190.4793,-2.409645 201.1158,0 193.91605,-0.418193 199.38327,11.581074 1.91052,4.193088 2.52845,61.467056 2.52845,234.350356 v 228.80101 l -13.95454,-19.5069 c -22.17785,-31.00215 -39.15059,-41.1936 -68.58515,-41.18268 -32.91354,0.0122 -58.2372,15.56946 -71.11346,43.68757 -5.20002,11.35535 -6.03318,15.79234 -6.04961,32.21666 -0.0255,25.49354 2.37816,30.28262 47.83916,95.31596 20.31255,29.05771 37.65727,54.02266 38.54383,55.47769 1.28415,2.1076 -30.36523,2.61822 -155.65586,2.51134 -86.49727,-0.0738 -159.17252,-0.91375 -161.50056,-1.8666 z" id="card" transform="matrix(0.09282638,0,0,0.09282638,-48.375947,-46.413263)" />
|
13
|
+
</g>
|
14
|
+
</svg>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg version="1.1" viewBox="0 0 669.06268 969.54651" xml:space="preserve" id="handcard" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
3
|
+
<desc id="desc1">Created with Fabric.js 3.5.0</desc>
|
4
|
+
<defs id="defs1" />
|
5
|
+
<g transform="matrix(10.7728,0,0,10.7728,334.531,484.77376)" id="982417">
|
6
|
+
<path style="opacity:1;fill:#000000;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0" transform="translate(-49.9993,-50.0003)"
|
7
|
+
d="M 80.938,56.066 C 80.579,52.743 79.386,49.587 77.709,46.711 74.703,41.554 70.207,37.346 65.427,33.849 64.044,32.838 62.615,31.854 61.124,31 c 0,-0.209 0,-0.418 0,-0.626 0,-5.312 0,-10.622 0,-15.933 0,-1.465 0,-2.932 0,-4.397 0,-2.024 -0.681,-4 -2.786,-4.753 -1.15,-0.412 -2.524,-0.265 -3.729,-0.265 -2.228,0 -4.455,0 -6.683,0 -5.787,0 -11.574,0 -17.363,0 -1.992,0 -3.984,0 -5.977,0 -1.823,0 -3.574,0.082 -4.797,1.724 -0.84,1.128 -0.843,2.358 -0.843,3.667 0,1.446 0,2.892 0,4.338 0,11.004 0,22.009 0,33.013 0,4.597 0,9.193 0,13.789 0,1.063 0,2.126 0,3.188 0,2.426 1.709,4.56 4.264,4.56 8.156,0 16.313,0 24.47,0 0.186,2.026 0.826,4.078 1.49,5.949 0.916,2.579 2.33,4.917 3.326,7.454 0.884,2.253 1.41,4.654 1.62,7.062 0.144,1.644 -0.204,3.627 1.431,4.653 0.861,0.54 1.828,0.577 2.807,0.577 2.412,0 4.824,0 7.237,0 2.574,0 5.148,0 7.723,0 1.755,0 3.438,-0.292 4.02,-2.279 0.387,-1.319 -0.104,-3.022 -0.21,-4.368 -0.145,-1.84 -0.189,-3.687 -0.165,-5.532 0.067,-5.036 0.778,-10.041 2.061,-14.91 0.584,-2.218 1.43,-4.356 1.788,-6.629 0.272,-1.73 0.32,-3.475 0.13,-5.216 z m -57.652,11.05 c -1.584,0 -2.151,-1.277 -2.151,-2.619 0,-3.297 0,-6.594 0,-9.891 0,-11.382 0,-22.763 0,-34.144 0,-3.47 0,-6.94 0,-10.41 0,-1.346 0.363,-2.839 2.075,-2.839 1.064,0 2.129,0 3.193,0 9.901,0 19.803,0 29.703,0 0.256,0 0.512,0 0.768,0 1.202,0 2.063,0.997 2.063,2.158 0,1 0,2 0,3 0,4.861 0,9.723 0,14.584 0,1.563 0,3.123 0,4.686 0,6.727 0,13.453 0,20.181 -0.247,-0.354 -0.494,-0.708 -0.741,-1.063 -0.357,-0.512 -0.703,-1.027 -1.065,-1.523 -0.552,-0.782 -1.157,-1.482 -1.889,-2.05 -0.065,-0.051 -0.133,-0.102 -0.2,-0.15 -0.04,-0.029 -0.079,-0.059 -0.12,-0.087 -0.22,-0.153 -0.452,-0.296 -0.7,-0.425 -1.724,-0.895 -3.705,-0.971 -5.468,-0.369 -0.278,0.091 -0.553,0.194 -0.823,0.314 -1.247,0.555 -2.22,1.473 -2.89,2.576 -0.857,1.356 -1.197,2.968 -1.027,4.537 0.108,1.127 0.481,2.229 1.141,3.188 0.008,0.011 0.014,0.021 0.02,0.031 2.402,3.438 4.803,6.876 7.204,10.314 -8.381,0 -16.764,0 -25.147,0 -1.317,0.001 -2.632,0.001 -3.946,0.001 z m 54.901,-4.058 c -0.726,2.635 -1.572,5.202 -2.125,7.887 -0.515,2.503 -0.861,5.042 -1.079,7.587 -0.325,3.791 -0.299,7.621 0.097,11.405 0.103,0.973 0.539,2.551 -0.503,2.844 -0.049,0.014 -0.08,0.023 -0.102,0.031 -0.016,-10e-4 -0.041,-10e-4 -0.08,0.001 -0.023,0 -0.047,0 -0.069,0 -0.222,0 -0.442,0 -0.664,0 -4.991,0 -9.983,0 -14.976,0 -0.554,0 -1.515,0.124 -1.96,-0.222 -0.503,-0.393 -0.331,-1.156 -0.353,-1.715 -0.04,-1.057 -0.161,-2.105 -0.311,-3.151 -0.368,-2.584 -1.153,-5.077 -2.242,-7.444 -1.081,-2.354 -2.255,-4.587 -3.029,-7.072 -0.401,-1.289 -0.767,-2.604 -0.912,-3.903 1.53,0 3.06,0 4.591,0 0.778,0 1.432,-0.949 0.944,-1.646 C 52.852,63.992 50.29,60.323 47.729,56.655 47.72,56.642 47.71,56.63 47.703,56.617 47.566,56.422 47.43,56.226 47.293,56.031 47.141,55.81 46.991,55.587 46.852,55.357 c -1.217,-2.139 -0.793,-4.683 1.099,-6.335 0.921,-0.757 2.11,-1.116 3.288,-1.063 1.083,0.078 2.15,0.51 2.996,1.216 0.531,0.491 0.952,1.087 1.383,1.703 0.436,0.624 0.871,1.247 1.306,1.87 0.002,0.003 0.003,0.005 0.005,0.007 0.72,1.03 1.439,2.061 2.158,3.091 0.006,0.008 0.013,0.015 0.019,0.022 1.585,2.27 3.17,4.538 4.755,6.808 0.801,1.147 2.698,0.056 1.889,-1.104 -1.541,-2.206 -3.082,-4.413 -4.623,-6.619 0,-7.136 0,-14.271 0,-21.405 2.207,1.357 4.299,2.944 6.261,4.608 4.684,3.972 8.976,8.925 10.741,14.916 0.963,3.27 0.962,6.701 0.058,9.986 z"
|
8
|
+
stroke-linecap="round" id="base" />
|
9
|
+
<path style="fill:#ffffff;stroke-width:2.1164"
|
10
|
+
d="m 594.70899,956.61376 c -3.28069,-3.2807 -4.2328,-7.05467 -4.2328,-16.77808 0,-32.11564 -9.83754,-74.34114 -25.60954,-109.92338 -26.95925,-60.82111 -31.6305,-72.2574 -36.42289,-89.17156 -2.80338,-9.89418 -5.6834,-21.08466 -6.40004,-24.86772 l -1.30298,-6.87831 h 25.9312 c 29.14115,0 35.40474,-2.18349 35.25312,-12.28931 -0.0589,-3.92805 -14.85858,-26.75473 -47.60495,-73.42498 -50.64801,-72.1837 -55.75178,-81.73001 -52.97606,-99.08843 2.08776,-13.05611 11.52456,-28.57643 21.58317,-35.49693 19.59236,-13.47989 44.84759,-12.01341 62.13882,3.60818 4.55252,4.11292 29.88304,38.42498 56.29006,76.24903 26.40701,37.82407 50.16106,70.17863 52.78676,71.89905 8.42428,5.51981 20.03703,-0.47898 20.03703,-10.3505 0,-1.63993 -11.90476,-20.0041 -26.45502,-40.80929 L 641.26984,551.46391 V 438.69492 c 0,-62.02294 0.5192,-112.76899 1.15378,-112.76899 2.60326,0 34.24198,22.50961 54.43477,38.72806 94.05661,75.54436 141.83302,162.75992 132.80692,242.43835 -1.16082,10.24728 -5.9989,32.36736 -10.7513,49.15577 -18.01143,63.62753 -24.50586,96.52031 -29.42743,149.04289 -2.93469,31.31895 -2.80074,82.23702 0.31386,119.30468 2.43431,28.97151 2.3662,30.55433 -1.4343,33.33333 -3.24663,2.37402 -21.26318,2.91755 -96.70716,2.91755 -89.89531,0 -92.84601,-0.12883 -96.94999,-4.2328 z" id="hand" transform="matrix(0.09282638,0,0,0.09282638,-48.375947,-46.413263)" />
|
11
|
+
<path style="stroke-width:2.1164"
|
12
|
+
d="m 225.39683,681.59712 c -2.32805,-0.95285 -6.13757,-3.8495 -8.46561,-6.43701 -4.18611,-4.65268 -4.23888,-8.07776 -4.7831,-310.46731 C 211.54624,30.27064 210.91004,48.349453 223.482,42.621285 c 3.82607,-1.743274 56.50183,-2.409645 190.4793,-2.409645 201.1158,0 193.91605,-0.418193 199.38327,11.581074 1.91052,4.193088 2.52845,61.467056 2.52845,234.350356 v 228.80101 l -13.95454,-19.5069 c -22.17785,-31.00215 -39.15059,-41.1936 -68.58515,-41.18268 -32.91354,0.0122 -58.2372,15.56946 -71.11346,43.68757 -5.20002,11.35535 -6.03318,15.79234 -6.04961,32.21666 -0.0255,25.49354 2.37816,30.28262 47.83916,95.31596 20.31255,29.05771 37.65727,54.02266 38.54383,55.47769 1.28415,2.1076 -30.36523,2.61822 -155.65586,2.51134 -86.49727,-0.0738 -159.17252,-0.91375 -161.50056,-1.8666 z" id="card" transform="matrix(0.09282638,0,0,0.09282638,-48.375947,-46.413263)" />
|
13
|
+
<g transform="matrix(0.87618872,0,0,0.87618872,-9.9399602,-21.131679)" id="862203">
|
14
|
+
<path style="opacity:1;fill:#000000;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0" vector-effect="non-scaling-stroke" transform="translate(-9.2,-6.3)" d="M 6,10.2 1.8,6 0.4,7.4 6,13 18,1 16.6,-0.4 Z" stroke-linecap="round" id="check" />
|
15
|
+
</g>
|
16
|
+
</g>
|
17
|
+
</svg>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import "select2"
|
2
|
+
|
3
|
+
$(() => {
|
4
|
+
const $select = $("#config_additional_proposal_sortings");
|
5
|
+
$select.select2({
|
6
|
+
theme: "foundation"
|
7
|
+
});
|
8
|
+
$("#additional_proposal_sortings-enable-all").on("click", (evt) => {
|
9
|
+
evt.preventDefault();
|
10
|
+
$select.find("option").prop("selected", true);
|
11
|
+
$select.trigger("change");
|
12
|
+
});
|
13
|
+
});
|
@@ -5,6 +5,7 @@ import "entrypoints/decidim_admin"
|
|
5
5
|
import "src/decidim/decidim_awesome/admin/constraints"
|
6
6
|
import "src/decidim/decidim_awesome/admin/auto_edit"
|
7
7
|
import "src/decidim/decidim_awesome/admin/user_picker"
|
8
|
+
import "src/decidim/decidim_awesome/admin/proposal_sortings"
|
8
9
|
import "src/decidim/decidim_awesome/editors/tabs_focus"
|
9
10
|
import "src/decidim/decidim_awesome/admin/codemirror"
|
10
11
|
import "src/decidim/decidim_awesome/admin/check_redirections"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import "src/decidim/decidim_awesome/proposals/images"
|
2
2
|
import "src/decidim/decidim_awesome/forms/autosave"
|
3
|
+
import "src/decidim/decidim_awesome/voting/voting_cards"
|
3
4
|
import {destroyQuillEditor, createQuillEditor, createMarkdownEditor} from "src/decidim/decidim_awesome/editors/editor"
|
4
5
|
|
5
6
|
$(() => {
|
@@ -24,13 +24,7 @@ export default class Controller {
|
|
24
24
|
setFetcher(Fetcher) {
|
25
25
|
let checkProposalState = function (node, map) {
|
26
26
|
const showConfig = map.config.show;
|
27
|
-
|
28
|
-
|
29
|
-
return withdrawn && node.state === "withdrawn" ||
|
30
|
-
accepted && node.state === "accepted" ||
|
31
|
-
evaluating && node.state === "evaluating" ||
|
32
|
-
notAnswered && node.state === "notAnswered" ||
|
33
|
-
rejected && node.state === "rejected";
|
27
|
+
return showConfig[node.state || "notAnswered"];
|
34
28
|
}
|
35
29
|
|
36
30
|
this.fetcher = new Fetcher(this);
|
@@ -16,6 +16,7 @@ import "highlight.js/styles/github.css";
|
|
16
16
|
import "src/decidim/editor/clipboard_override"
|
17
17
|
import "src/decidim/vendor/image-resize.min"
|
18
18
|
import "src/decidim/vendor/image-upload.min"
|
19
|
+
import { marked } from "marked";
|
19
20
|
|
20
21
|
const DecidimAwesome = window.DecidimAwesome || {};
|
21
22
|
const quillFormats = ["bold", "italic", "link", "underline", "header", "list", "video", "image", "alt", "break", "width", "style", "code", "blockquote", "indent"];
|
@@ -105,14 +106,14 @@ export function createQuillEditor(container) {
|
|
105
106
|
callbackKO: (serverError) => {
|
106
107
|
$("div.ql-toolbar").last().removeClass("editor-loading")
|
107
108
|
let msg = serverError && serverError.body;
|
108
|
-
try {
|
109
|
-
msg = JSON.parse(msg).message;
|
109
|
+
try {
|
110
|
+
msg = JSON.parse(msg).message;
|
110
111
|
} catch (evt) { console.error("Parsing error", evt); }
|
111
112
|
console.error(`Image upload error: ${msg}`);
|
112
113
|
let $p = $(`<p class="text-alert help-text">${msg}</p>`);
|
113
114
|
$(container).after($p)
|
114
115
|
setTimeout(() => {
|
115
|
-
$p.fadeOut(1000, () => {
|
116
|
+
$p.fadeOut(1000, () => {
|
116
117
|
$p.destroy();
|
117
118
|
});
|
118
119
|
}, 3000);
|
@@ -204,9 +205,14 @@ export function createMarkdownEditor(container) {
|
|
204
205
|
});
|
205
206
|
}
|
206
207
|
|
208
|
+
// Allow linebreaks
|
209
|
+
marked.setOptions({
|
210
|
+
breaks: true
|
211
|
+
});
|
212
|
+
|
207
213
|
// convert to html on submit
|
208
214
|
$form.on("submit", () => {
|
209
215
|
// e.preventDefault();
|
210
|
-
$input.val(
|
216
|
+
$input.val(marked(inscrybmde.value()));
|
211
217
|
});
|
212
218
|
}
|
@@ -4,7 +4,7 @@ import "src/decidim/decidim_awesome/forms/rich_text_plugin"
|
|
4
4
|
export default class CustomFieldsRenderer { // eslint-disable-line no-unused-vars
|
5
5
|
constructor(containerSelector) {
|
6
6
|
this.containerSelector = containerSelector || ".proposal_custom_field:last";
|
7
|
-
this.lang = this.getLang(
|
7
|
+
this.lang = this.getLang(window.DecidimAwesome.currentLocale);
|
8
8
|
}
|
9
9
|
|
10
10
|
getLang(lang) {
|