decidim-proposals 0.23.5 → 0.24.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +4 -1
  3. data/app/assets/javascripts/decidim/proposals/admin/proposals_form.js.es6 +4 -1
  4. data/app/assets/stylesheets/decidim/proposals/_proposals.css.scss +1 -0
  5. data/app/assets/stylesheets/decidim/proposals/proposals/_preview.css.scss +3 -0
  6. data/app/cells/decidim/proposals/collaborative_draft_link_to_proposal_cell.rb +3 -3
  7. data/app/cells/decidim/proposals/collaborative_drafts/reported_content/show.erb +3 -0
  8. data/app/cells/decidim/proposals/collaborative_drafts/reported_content_cell.rb +15 -0
  9. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/elements.erb +5 -0
  10. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals/heading.erb +1 -0
  11. data/app/cells/decidim/proposals/content_blocks/highlighted_proposals_cell.rb +19 -0
  12. data/app/cells/decidim/proposals/irreversible_action_modal_cell.rb +1 -1
  13. data/app/cells/decidim/proposals/proposal_m_cell.rb +23 -2
  14. data/app/cells/decidim/proposals/proposals_picker_cell.rb +1 -1
  15. data/app/cells/decidim/proposals/reported_content/show.erb +4 -0
  16. data/app/cells/decidim/proposals/reported_content_cell.rb +13 -0
  17. data/app/commands/decidim/proposals/hashtags_methods.rb +1 -1
  18. data/app/commands/decidim/proposals/update_proposal.rb +0 -2
  19. data/app/controllers/decidim/proposals/admin/proposals_controller.rb +6 -4
  20. data/app/controllers/decidim/proposals/collaborative_drafts_controller.rb +1 -30
  21. data/app/controllers/decidim/proposals/proposals_controller.rb +5 -6
  22. data/app/events/decidim/proposals/publish_proposal_event.rb +1 -1
  23. data/app/forms/decidim/proposals/access_to_collaborative_draft_form.rb +1 -3
  24. data/app/forms/decidim/proposals/admin/proposal_base_form.rb +3 -2
  25. data/app/forms/decidim/proposals/proposal_form.rb +15 -5
  26. data/app/forms/decidim/proposals/proposal_wizard_create_step_form.rb +1 -1
  27. data/app/helpers/decidim/proposals/admin/filterable_helper.rb +1 -1
  28. data/app/helpers/decidim/proposals/admin/proposal_rankings_helper.rb +1 -1
  29. data/app/helpers/decidim/proposals/admin/proposals_helper.rb +8 -8
  30. data/app/helpers/decidim/proposals/application_helper.rb +5 -2
  31. data/app/helpers/decidim/proposals/map_helper.rb +31 -8
  32. data/app/helpers/decidim/proposals/proposal_wizard_helper.rb +14 -44
  33. data/app/helpers/decidim/proposals/proposals_helper.rb +3 -6
  34. data/app/models/decidim/proposals/collaborative_draft.rb +10 -0
  35. data/app/models/decidim/proposals/proposal.rb +18 -10
  36. data/app/permissions/decidim/proposals/admin/permissions.rb +2 -2
  37. data/app/permissions/decidim/proposals/permissions.rb +3 -2
  38. data/app/presenters/decidim/proposals/proposal_presenter.rb +4 -4
  39. data/app/queries/decidim/proposals/metrics/proposal_followers_metric_measure.rb +4 -4
  40. data/app/queries/decidim/proposals/metrics/proposal_participants_metric_measure.rb +6 -6
  41. data/app/services/decidim/proposals/collaborative_draft_search.rb +1 -1
  42. data/app/services/decidim/proposals/diff_renderer.rb +7 -11
  43. data/app/services/decidim/proposals/proposal_builder.rb +1 -0
  44. data/app/views/decidim/proposals/admin/proposals/_bulk-actions.html.erb +8 -1
  45. data/app/views/decidim/proposals/admin/proposals/_proposal-tr.html.erb +5 -1
  46. data/app/views/decidim/proposals/admin/proposals_imports/new.html.erb +1 -1
  47. data/app/views/decidim/proposals/collaborative_drafts/_filters_small_view.html.erb +1 -1
  48. data/app/views/decidim/proposals/collaborative_drafts/_wizard_aside.html.erb +2 -7
  49. data/app/views/decidim/proposals/collaborative_drafts/_wizard_header.html.erb +14 -0
  50. data/app/views/decidim/proposals/collaborative_drafts/edit.html.erb +1 -3
  51. data/app/views/decidim/proposals/collaborative_drafts/new.html.erb +5 -13
  52. data/app/views/decidim/proposals/collaborative_drafts/show.html.erb +1 -7
  53. data/app/views/decidim/proposals/proposals/_dynamic_map_instructions.html.erb +3 -0
  54. data/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb +6 -6
  55. data/app/views/decidim/proposals/proposals/_filters.html.erb +34 -32
  56. data/app/views/decidim/proposals/proposals/_filters_small_view.html.erb +1 -1
  57. data/app/views/decidim/proposals/proposals/_wizard_header.html.erb +21 -11
  58. data/app/views/decidim/proposals/proposals/edit.html.erb +1 -3
  59. data/app/views/decidim/proposals/proposals/preview.html.erb +50 -2
  60. data/app/views/decidim/proposals/proposals/show.html.erb +2 -8
  61. data/config/locales/ar.yml +2 -23
  62. data/config/locales/bg.yml +0 -4
  63. data/config/locales/ca.yml +23 -29
  64. data/config/locales/cs.yml +24 -30
  65. data/config/locales/de.yml +23 -29
  66. data/config/locales/el.yml +2 -29
  67. data/config/locales/en.yml +23 -29
  68. data/config/locales/es-MX.yml +23 -29
  69. data/config/locales/es-PY.yml +23 -29
  70. data/config/locales/es.yml +23 -29
  71. data/config/locales/eu.yml +2 -23
  72. data/config/locales/fi-plain.yml +22 -28
  73. data/config/locales/fi.yml +22 -28
  74. data/config/locales/fr-CA.yml +19 -29
  75. data/config/locales/fr.yml +19 -29
  76. data/config/locales/gl.yml +17 -25
  77. data/config/locales/hu.yml +2 -23
  78. data/config/locales/id-ID.yml +2 -23
  79. data/config/locales/is-IS.yml +0 -8
  80. data/config/locales/it.yml +4 -29
  81. data/config/locales/ja.yml +2 -29
  82. data/config/locales/lv.yml +2 -22
  83. data/config/locales/nl.yml +17 -29
  84. data/config/locales/no.yml +2 -23
  85. data/config/locales/pl.yml +22 -28
  86. data/config/locales/pt-BR.yml +2 -22
  87. data/config/locales/pt.yml +2 -29
  88. data/config/locales/ro-RO.yml +13 -29
  89. data/config/locales/ru.yml +0 -8
  90. data/config/locales/sk.yml +5 -23
  91. data/config/locales/sv.yml +23 -28
  92. data/config/locales/tr-TR.yml +17 -29
  93. data/config/locales/uk.yml +0 -8
  94. data/config/locales/zh-CN.yml +2 -29
  95. data/db/migrate/20210310102839_add_followable_counter_cache_to_proposals.rb +16 -0
  96. data/db/migrate/20210310120812_add_followable_counter_cache_to_collaborative_drafts.rb +16 -0
  97. data/db/migrate/20210318082934_fix_counters_for_copied_proposals.rb +9 -7
  98. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_filter.rb +0 -0
  99. data/{app/types/decidim/proposals → lib/decidim/api}/proposal_input_sort.rb +3 -5
  100. data/lib/decidim/api/proposal_type.rb +56 -0
  101. data/lib/decidim/api/proposals_type.rb +43 -0
  102. data/lib/decidim/content_renderers/proposal_renderer.rb +1 -1
  103. data/lib/decidim/proposals.rb +2 -0
  104. data/lib/decidim/proposals/api.rb +10 -0
  105. data/lib/decidim/proposals/component.rb +30 -19
  106. data/lib/decidim/proposals/engine.rb +6 -27
  107. data/lib/decidim/proposals/proposal_creator.rb +98 -0
  108. data/lib/decidim/proposals/test/factories.rb +22 -8
  109. data/lib/decidim/proposals/version.rb +1 -1
  110. metadata +49 -35
  111. data/app/commands/decidim/proposals/create_proposal_export.rb +0 -37
  112. data/app/helpers/decidim/proposals/proposal_endorsements_helper.rb +0 -0
  113. data/app/queries/decidim/proposals/similar_collaborative_drafts.rb +0 -52
  114. data/app/types/decidim/proposals/proposal_type.rb +0 -70
  115. data/app/types/decidim/proposals/proposals_type.rb +0 -41
  116. data/app/views/decidim/participatory_processes/participatory_process_groups/_highlighted_proposals.html.erb +0 -13
  117. data/app/views/decidim/proposals/collaborative_drafts/compare.html.erb +0 -21
  118. data/app/views/decidim/proposals/collaborative_drafts/complete.html.erb +0 -24
  119. data/app/views/decidim/proposals/proposals/_proposal_preview.html.erb +0 -1
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Proposals
5
- # A command with all the business logic when a user creates a new proposal.
6
- class CreateProposalExport < Rectify::Command
7
- # Public: Initializes the command.
8
- #
9
- # form - A form object with the params.
10
- # current_user - The current user.
11
- def initialize(participatory_process)
12
- @participatory_process = participatory_process
13
- end
14
-
15
- # Executes the command. Broadcasts these events:
16
- #
17
- # - :ok when everything is valid, together with the proposal.
18
- # - :invalid if the proposal wasn't valid and we couldn't proceed.
19
- #
20
- # Returns nothing.
21
- def call
22
- return broadcast(:invalid) if participatory_process.invalid?
23
-
24
- create_proposal_export
25
- broadcast(:ok, export)
26
- end
27
-
28
- private
29
-
30
- attr_reader :participatory_process
31
-
32
- def create_proposal_export
33
- ProposalsExporterJob.perform_later(participatory_process)
34
- end
35
- end
36
- end
37
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Proposals
5
- # Class used to retrieve similar collaborative_drafts.
6
- class SimilarCollaborativeDrafts < Rectify::Query
7
- include Decidim::TranslationsHelper
8
-
9
- # Syntactic sugar to initialize the class and return the queried objects.
10
- #
11
- # component - Decidim::CurrentComponent
12
- # collaborative_draft - Decidim::Proposals::CollaborativeDraft
13
- def self.for(component, collaborative_draft)
14
- new(component, collaborative_draft).query
15
- end
16
-
17
- # Initializes the class.
18
- #
19
- # component - Decidim::CurrentComponent
20
- # collaborative_draft - Decidim::Proposals::CollaborativeDraft
21
- def initialize(component, collaborative_draft)
22
- @component = component
23
- @collaborative_draft = collaborative_draft
24
- end
25
-
26
- # Retrieves similar collaborative_drafts
27
- def query
28
- Decidim::Proposals::CollaborativeDraft
29
- .where(component: @component)
30
- .where(
31
- "GREATEST(#{title_similarity}, #{body_similarity}) >= ?",
32
- @collaborative_draft[:title],
33
- @collaborative_draft[:body],
34
- Decidim::Proposals.similarity_threshold
35
- )
36
- .limit(Decidim::Proposals.similarity_limit)
37
- end
38
-
39
- private
40
-
41
- attr_reader :collaborative_draft
42
-
43
- def title_similarity
44
- "similarity(title, ?)"
45
- end
46
-
47
- def body_similarity
48
- "similarity(body, ?)"
49
- end
50
- end
51
- end
52
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Proposals
5
- ProposalType = GraphQL::ObjectType.define do
6
- name "Proposal"
7
- description "A proposal"
8
-
9
- interfaces [
10
- -> { Decidim::Comments::CommentableInterface },
11
- -> { Decidim::Core::CoauthorableInterface },
12
- -> { Decidim::Core::CategorizableInterface },
13
- -> { Decidim::Core::ScopableInterface },
14
- -> { Decidim::Core::AttachableInterface },
15
- -> { Decidim::Core::FingerprintInterface },
16
- -> { Decidim::Core::AmendableInterface },
17
- -> { Decidim::Core::AmendableEntityInterface },
18
- -> { Decidim::Core::TraceableInterface },
19
- -> { Decidim::Core::EndorsableInterface },
20
- -> { Decidim::Core::TimestampsInterface }
21
- ]
22
-
23
- field :id, !types.ID
24
- field :title, Decidim::Core::TranslatedFieldType, "The title for this title"
25
- field :body, Decidim::Core::TranslatedFieldType, "The description for this body"
26
- field :address, types.String, "The physical address (location) of this proposal"
27
- field :coordinates, Decidim::Core::CoordinatesType, "Physical coordinates for this proposal" do
28
- resolve ->(proposal, _args, _ctx) {
29
- [proposal.latitude, proposal.longitude]
30
- }
31
- end
32
- field :reference, types.String, "This proposal's unique reference"
33
- field :state, types.String, "The answer status in which proposal is in"
34
- field :answer, Decidim::Core::TranslatedFieldType, "The answer feedback for the status for this proposal"
35
-
36
- field :answeredAt, Decidim::Core::DateTimeType do
37
- description "The date and time this proposal was answered"
38
- property :answered_at
39
- end
40
-
41
- field :publishedAt, Decidim::Core::DateTimeType do
42
- description "The date and time this proposal was published"
43
- property :published_at
44
- end
45
-
46
- field :participatoryTextLevel, types.String do
47
- description "If it is a participatory text, the level indicates the type of paragraph"
48
- property :participatory_text_level
49
- end
50
- field :position, types.Int, "Position of this proposal in the participatory text"
51
-
52
- field :official, types.Boolean, "Whether this proposal is official or not", property: :official?
53
- field :createdInMeeting, types.Boolean, "Whether this proposal comes from a meeting or not", property: :official_meeting?
54
- field :meeting, Decidim::Meetings::MeetingType do
55
- description "If the proposal comes from a meeting, the related meeting"
56
- resolve ->(proposal, _, _) {
57
- proposal.authors.first if proposal.official_meeting?
58
- }
59
- end
60
-
61
- field :voteCount, types.Int do
62
- description "The total amount of votes the proposal has received"
63
- resolve ->(proposal, _args, _ctx) {
64
- current_component = proposal.component
65
- proposal.proposal_votes_count unless current_component.current_settings.votes_hidden?
66
- }
67
- end
68
- end
69
- end
70
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- module Proposals
5
- ProposalsType = GraphQL::ObjectType.define do
6
- interfaces [-> { Decidim::Core::ComponentInterface }]
7
-
8
- name "Proposals"
9
- description "A proposals component of a participatory space."
10
-
11
- connection :proposals,
12
- type: ProposalType.connection_type,
13
- description: "List all proposals",
14
- function: ProposalListHelper.new(model_class: Proposal)
15
-
16
- field :proposal,
17
- type: ProposalType,
18
- description: "Finds one proposal",
19
- function: ProposalFinderHelper.new(model_class: Proposal)
20
- end
21
-
22
- class ProposalListHelper < Decidim::Core::ComponentListBase
23
- argument :order, ProposalInputSort, "Provides several methods to order the results"
24
- argument :filter, ProposalInputFilter, "Provides several methods to filter the results"
25
-
26
- # only querying published posts
27
- def query_scope
28
- super.published
29
- end
30
- end
31
-
32
- class ProposalFinderHelper < Decidim::Core::ComponentFinderBase
33
- argument :id, !types.ID, "The ID of the proposal"
34
-
35
- # only querying published posts
36
- def query_scope
37
- super.published
38
- end
39
- end
40
- end
41
- end
@@ -1,13 +0,0 @@
1
- <% if proposals.any? %>
2
- <section class="section row collapse highlighted_proposals">
3
- <h2 class="section-heading"><%= t(".proposals") %></h2>
4
-
5
- <%= cell(
6
- "decidim/collapsible_list",
7
- proposals,
8
- cell_options: {},
9
- list_class: "row small-up-1 medium-up-2 large-up-3 card-grid",
10
- size: proposals.count
11
- ) %>
12
- </section>
13
- <% end %>
@@ -1,21 +0,0 @@
1
- <% add_decidim_page_title(proposal_wizard_step_title(action_name)) %>
2
-
3
- <div class="row">
4
- <%= render partial: "wizard_aside" %>
5
-
6
- <div class="columns large-6">
7
- <%= render partial: "decidim/proposals/proposals/wizard_header", locals: { callout_step_help_text_class: "warning" } %>
8
-
9
- <% if @similar_collaborative_drafts.presence %>
10
- <div class="row small-up-1 card-grid">
11
- <% @similar_collaborative_drafts.each do |collaborative_draft| %>
12
- <%= card_for collaborative_draft %>
13
- <% end %>
14
- </div>
15
- <% end %>
16
- <div class="row column text-center">
17
- <%= link_to t(".mine_is_different"), complete_collaborative_drafts_path(collaborative_draft: { title: @form.title, body: @form.body }), class: "button small" %>
18
- </div>
19
- </div>
20
- <div class="columns large-3"></div>
21
- </div>
@@ -1,24 +0,0 @@
1
- <% add_decidim_page_title(proposal_wizard_step_title(action_name)) %>
2
-
3
- <div class="row">
4
- <%= render partial: "wizard_aside" %>
5
-
6
- <div class="columns large-6">
7
- <%= render partial: "decidim/proposals/proposals/wizard_header" %>
8
-
9
- <div class="card">
10
- <div class="card__content">
11
- <%= decidim_form_for(@form) do |form| %>
12
- <%= render partial: "edit_form_fields", locals: { form: form } %>
13
-
14
- <div class="actions">
15
- <%= form.submit t(".send"), class: "button expanded mt-s mb-none", data: { disable: true } %>
16
- </div>
17
- <% end %>
18
- </div>
19
- </div>
20
- </div>
21
- <div class="columns large-3"></div>
22
- </div>
23
-
24
- <%= javascript_include_tag "decidim/proposals/add_proposal" %>
@@ -1 +0,0 @@
1
- <%= card_for @proposal, from: @proposal, preview: true %>