decidim-accountability 0.31.8 → 0.32.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -16
  3. data/app/cells/decidim/accountability/result_metadata/{project_aside.erb → result_aside.erb} +1 -1
  4. data/app/cells/decidim/accountability/result_metadata_cell.rb +1 -1
  5. data/app/cells/decidim/accountability/{project → result_show}/milestones.erb +4 -4
  6. data/app/cells/decidim/accountability/{project_cell.rb → result_show_cell.rb} +4 -3
  7. data/app/cells/decidim/accountability/status_cell.rb +1 -5
  8. data/app/commands/decidim/accountability/admin/import_component_to_accountability.rb +1 -1
  9. data/app/controllers/concerns/decidim/accountability/admin/filterable.rb +1 -5
  10. data/app/controllers/decidim/accountability/admin/attachment_collections_controller.rb +0 -2
  11. data/app/controllers/decidim/accountability/admin/attachments_controller.rb +0 -2
  12. data/app/controllers/decidim/accountability/admin/import_components_controller.rb +3 -5
  13. data/app/controllers/decidim/accountability/admin/import_results_controller.rb +9 -5
  14. data/app/controllers/decidim/accountability/admin/milestones_controller.rb +2 -2
  15. data/app/controllers/decidim/accountability/admin/results_bulk_actions_controller.rb +6 -6
  16. data/app/controllers/decidim/accountability/admin/results_controller.rb +7 -9
  17. data/app/controllers/decidim/accountability/admin/statuses_controller.rb +15 -3
  18. data/app/controllers/decidim/accountability/results_controller.rb +15 -21
  19. data/app/controllers/decidim/accountability/versions_controller.rb +12 -2
  20. data/app/forms/decidim/accountability/admin/status_form.rb +0 -1
  21. data/app/helpers/decidim/accountability/breadcrumb_helper.rb +0 -4
  22. data/app/helpers/decidim/accountability/calculator_helper.rb +16 -0
  23. data/app/mailers/decidim/accountability/import_projects_mailer.rb +3 -2
  24. data/app/mailers/decidim/accountability/import_proposals_mailer.rb +1 -0
  25. data/app/models/decidim/accountability/result.rb +9 -7
  26. data/app/models/decidim/accountability/status.rb +5 -2
  27. data/app/packs/stylesheets/accountability.scss +2 -2
  28. data/app/permissions/decidim/accountability/permissions.rb +1 -1
  29. data/app/views/decidim/accountability/admin/import_components/new.html.erb +1 -1
  30. data/app/views/decidim/accountability/admin/import_results/new.html.erb +1 -1
  31. data/app/views/decidim/accountability/admin/results/_actions.html.erb +1 -1
  32. data/app/views/decidim/accountability/admin/results/_form.html.erb +3 -5
  33. data/app/views/decidim/accountability/admin/results/_result-tr.html.erb +1 -4
  34. data/app/views/decidim/accountability/admin/results/_results-thead.html.erb +0 -3
  35. data/app/views/decidim/accountability/admin/results/bulk_actions/_dropdown.html.erb +5 -7
  36. data/app/views/decidim/accountability/admin/statuses/index.html.erb +3 -3
  37. data/app/views/decidim/accountability/results/_home_taxonomies.html.erb +2 -2
  38. data/app/views/decidim/accountability/results/{_project.html.erb → _result.html.erb} +4 -4
  39. data/app/views/decidim/accountability/results/index.html.erb +1 -1
  40. data/app/views/decidim/accountability/results/show.html.erb +1 -1
  41. data/config/locales/ar.yml +1 -2
  42. data/config/locales/bg.yml +1 -2
  43. data/config/locales/bs-BA.yml +0 -1
  44. data/config/locales/ca-IT.yml +2 -3
  45. data/config/locales/ca.yml +2 -3
  46. data/config/locales/cs.yml +1 -3
  47. data/config/locales/da.yml +1 -1
  48. data/config/locales/de.yml +2 -2
  49. data/config/locales/el.yml +2 -2
  50. data/config/locales/en.yml +2 -2
  51. data/config/locales/es-MX.yml +3 -4
  52. data/config/locales/es-PY.yml +3 -4
  53. data/config/locales/es.yml +2 -3
  54. data/config/locales/eu.yml +32 -33
  55. data/config/locales/fi-plain.yml +1 -2
  56. data/config/locales/fi.yml +1 -2
  57. data/config/locales/fr-CA.yml +2 -3
  58. data/config/locales/fr.yml +2 -3
  59. data/config/locales/ga-IE.yml +0 -2
  60. data/config/locales/gl.yml +3 -229
  61. data/config/locales/gn-PY.yml +0 -1
  62. data/config/locales/he-IL.yml +4 -2
  63. data/config/locales/hu.yml +1 -2
  64. data/config/locales/id-ID.yml +0 -1
  65. data/config/locales/is-IS.yml +1 -3
  66. data/config/locales/it.yml +1 -2
  67. data/config/locales/ja.yml +2 -3
  68. data/config/locales/kaa.yml +0 -1
  69. data/config/locales/ko.yml +1 -2
  70. data/config/locales/lb.yml +1 -2
  71. data/config/locales/lt.yml +1 -2
  72. data/config/locales/lv.yml +0 -1
  73. data/config/locales/nl.yml +1 -2
  74. data/config/locales/no.yml +1 -2
  75. data/config/locales/pl.yml +1 -5
  76. data/config/locales/pt-BR.yml +2 -2
  77. data/config/locales/pt.yml +1 -2
  78. data/config/locales/ro-RO.yml +2 -2
  79. data/config/locales/ru.yml +0 -234
  80. data/config/locales/si-LK.yml +0 -1
  81. data/config/locales/sk.yml +2 -252
  82. data/config/locales/sl.yml +0 -1
  83. data/config/locales/sq-AL.yml +1 -2
  84. data/config/locales/sr-CS.yml +0 -1
  85. data/config/locales/sv.yml +2 -3
  86. data/config/locales/th-TH.yml +1 -1
  87. data/config/locales/tr-TR.yml +2 -2
  88. data/config/locales/uk.yml +0 -1
  89. data/config/locales/zh-CN.yml +1 -1
  90. data/config/locales/zh-TW.yml +1 -2
  91. data/db/data/20260113140600_reindex_results.rb +13 -0
  92. data/decidim-accountability.gemspec +12 -15
  93. data/lib/decidim/accountability/component.rb +14 -6
  94. data/lib/decidim/accountability/seeds.rb +2 -2
  95. data/lib/decidim/accountability/version.rb +1 -1
  96. data/lib/decidim/api/accountability_type.rb +14 -2
  97. metadata +30 -32
  98. data/app/views/decidim/accountability/results/index.js.erb +0 -5
  99. /data/app/cells/decidim/accountability/{project → result_show}/show.erb +0 -0
  100. /data/app/views/decidim/accountability/results/{_projects_aside.html.erb → _results_aside.html.erb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c87e10cab3a24a882575bf4b40eded34c02803470f34109935f6c07120659aaf
4
- data.tar.gz: d72cbd2c821899c74364b7e281d5f88280ad8e54106f189a589195fad68ebd82
3
+ metadata.gz: b11b03399049993a09e10d946a0963a2f79405496523bdb1b2392e52fab4c9fd
4
+ data.tar.gz: e9a3872042ae120dcd2d34acfdddd1fa96303b041661fe139428093d6915fdc5
5
5
  SHA512:
6
- metadata.gz: f5121e60765ca3e4070f2372a1e50436fe46102e7e0b082269c782c382a863b80eacf5daa124809cce104b4301a870ff0ff346c653405923a3e05df51f80dddb
7
- data.tar.gz: 4a5041e2052dad7340432f9e5ca7479e7cf9014c4cf14b2b5f25709305e6bb75b53d4fc1f105387ab94f8463088d7768fef39c8780cf086f54a4668647236627
6
+ metadata.gz: d92038bd1cbc613f975a6106d0f289c797faf1d3bc3725d4a1343bded0a5f39c80fbd64de70191059819b169af3b3446478be3189668a827ee8cd3b9646aa049
7
+ data.tar.gz: 85e75f6e3ba8b8f09f87c4d24aaa27a11d1a9891ba5ce4e2a38b77593130d7f8cbab98ded6deb29e146fa6ab72c8c8e1ecc345473bb45f4a90ec0c2564944b9f
data/README.md CHANGED
@@ -1,29 +1,19 @@
1
- # Decidim::Accountability
1
+ # decidim-accountability
2
2
 
3
- The Accountability module adds results to any participatory process. It adds a CRUD engine to the admin and public views scoped inside the participatory process. Accountability will link to related meetings and proposals and will be used to show the progress on the related proposals.
3
+ The Accountability module adds results to any participatory space. It adds a CRUD engine to the admin and public views scoped inside the participatory space. Accountability will link to related meetings and proposals and will be used to show the progress on the related proposals.
4
4
 
5
5
  ## Usage
6
6
 
7
- Accountability will be available as a Component for a Participatory Process.
7
+ Accountability will be available as a Component for a Participatory Space.
8
8
 
9
9
  ## Installation
10
10
 
11
- Add this line to your application's Gemfile:
12
-
13
- ```ruby
14
- gem 'decidim-accountability'
15
- ```
16
-
17
- And then execute:
18
-
19
- ```bash
20
- bundle
21
- ```
11
+ This is on the default Decidim installation so you should not change anything to use this component.
22
12
 
23
13
  ## Contributing
24
14
 
25
- See [Decidim](https://github.com/AjuntamentdeBarcelona/decidim).
15
+ See [Decidim](https://github.com/decidim/decidim).
26
16
 
27
17
  ## License
28
18
 
29
- See [Decidim](https://github.com/AjuntamentdeBarcelona/decidim).
19
+ See [Decidim](https://github.com/decidim/decidim).
@@ -1,5 +1,5 @@
1
1
  <% items.each do |item| %>
2
- <div class="accountability__project-aside-item">
2
+ <div class="accountability__result-aside-item">
3
3
  <div><%= icon item[:icon], class: "w-3.5 h-3.5 fill-current text-gray" %><%= item[:text] %></div>
4
4
  <div><%= item[:value] %></div>
5
5
  </div>
@@ -23,7 +23,7 @@ module Decidim
23
23
  private
24
24
 
25
25
  def result_items
26
- return [dates_item, status_item, status_description] if template == :project_aside
26
+ return [dates_item, status_item, status_description] if template == :result_aside
27
27
  return [reference, versions] if template == :show_footer
28
28
 
29
29
  [dates_item_compact, status_item_compact] + taxonomy_items
@@ -1,10 +1,10 @@
1
- <ol class="accountability__project-milestones">
1
+ <ol class="accountability__result-milestones">
2
2
  <% milestones.each_with_index do |milestone, i| %>
3
- <li class="accountability__project-milestones-milestone">
4
- <div class="accountability__project-milestones-milestone-number">
3
+ <li class="accountability__result-milestones-milestone">
4
+ <div class="accountability__result-milestones-milestone-number">
5
5
  <span><%= i + 1 %></span>
6
6
  </div>
7
- <div class="accountability__project-milestones-milestone-attributes">
7
+ <div class="accountability__result-milestones-milestone-attributes">
8
8
  <h3>
9
9
  <%= decidim_sanitize_translated milestone.title %>
10
10
  </h3>
@@ -4,10 +4,11 @@ require "cell/partial"
4
4
 
5
5
  module Decidim
6
6
  module Accountability
7
- # This cell renders a project
8
- class ProjectCell < Decidim::ViewModel
7
+ # This cell renders a result
8
+ class ResultShowCell < Decidim::ViewModel
9
9
  include Decidim::Accountability::ApplicationHelper
10
10
  include Cell::ViewModel::Partial
11
+
11
12
  delegate :children, :milestones, to: :model
12
13
 
13
14
  alias result model
@@ -24,7 +25,7 @@ module Decidim
24
25
  text: t("decidim.accountability.results.milestones.title"),
25
26
  icon: "route-line",
26
27
  method: :cell,
27
- args: ["decidim/accountability/project", result, { template: :milestones }]
28
+ args: ["decidim/accountability/result_show", result, { template: :milestones }]
28
29
  },
29
30
  {
30
31
  enabled: ResultHistoryCell.new(result).render?,
@@ -7,7 +7,7 @@ module Decidim
7
7
  # This cell renders the status of a taxonomy or a result.
8
8
  class StatusCell < Decidim::ViewModel
9
9
  include Decidim::Accountability::ApplicationHelper
10
- include Decidim::Accountability::BreadcrumbHelper
10
+ include Decidim::Accountability::CalculatorHelper
11
11
  include ActionView::Helpers::NumberHelper
12
12
 
13
13
  def show
@@ -80,10 +80,6 @@ module Decidim
80
80
  options[:render_count]
81
81
  end
82
82
 
83
- def count_calculator(taxonomy_id)
84
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).count
85
- end
86
-
87
83
  def decidim
88
84
  Decidim::Accountability::Engine.routes.url_helpers
89
85
  end
@@ -3,7 +3,7 @@
3
3
  module Decidim
4
4
  module Accountability
5
5
  module Admin
6
- # A command with all the business logic when an admin imports projects from
6
+ # A command with all the business logic when an admin imports results from
7
7
  # one component to accountability.
8
8
  class ImportComponentToAccountability < Decidim::Command
9
9
  attr_reader :form
@@ -23,10 +23,6 @@ module Decidim
23
23
  collection.includes(:taxonomies).joins(:taxonomies)
24
24
  end
25
25
 
26
- def search_field_predicate
27
- :id_string_or_title_cont
28
- end
29
-
30
26
  def filters
31
27
  [
32
28
  :taxonomies_part_of_contains,
@@ -48,7 +44,7 @@ module Decidim
48
44
  end
49
45
 
50
46
  def status_ids_hash(statuses)
51
- statuses.each_with_object({}) { |status, hash| hash[status.id] = status.id }
47
+ statuses.to_h { |status| [status.id, status.id] }
52
48
  end
53
49
 
54
50
  def translated_status_id_eq(id)
@@ -9,8 +9,6 @@ module Decidim
9
9
  class AttachmentCollectionsController < Admin::ApplicationController
10
10
  include Decidim::Admin::Concerns::HasAttachmentCollections
11
11
 
12
- protected
13
-
14
12
  def after_destroy_path
15
13
  result_attachment_collections_path(result, result.component, current_participatory_space)
16
14
  end
@@ -9,8 +9,6 @@ module Decidim
9
9
  class AttachmentsController < Admin::ApplicationController
10
10
  include Decidim::Admin::Concerns::HasAttachments
11
11
 
12
- protected
13
-
14
12
  def after_destroy_path
15
13
  results_path
16
14
  end
@@ -15,20 +15,18 @@ module Decidim
15
15
  @form = form(Admin::ImportComponentForm).from_params(params, accountability_component: current_component)
16
16
 
17
17
  ImportComponentToAccountability.call(@form) do
18
- on(:ok) do |projects|
19
- flash[:notice] = I18n.t("import_components.new.success", scope: "decidim.accountability.admin", count: projects)
18
+ on(:ok) do |results|
19
+ flash[:notice] = I18n.t("import_components.new.success", scope: "decidim.accountability.admin", count: results)
20
20
  redirect_to results_path
21
21
  end
22
22
 
23
23
  on(:invalid) do
24
24
  flash[:alert] = I18n.t("import_components.create.invalid", scope: "decidim.accountability.admin")
25
- render action: "new", status: :unprocessable_entity
25
+ render action: "new", status: :unprocessable_content
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
- protected
31
-
32
30
  def results_import_params
33
31
  params[:results_import] || {}
34
32
  end
@@ -5,15 +5,13 @@ module Decidim
5
5
  module Admin
6
6
  # This controller allows an admin to import results from a csv file for the Accountability component
7
7
  class ImportResultsController < Admin::ApplicationController
8
- def new
9
- enforce_permission_to :create, :result
8
+ before_action :ensure_permissions
10
9
 
10
+ def new
11
11
  @form = form(Admin::ImportResultsForm).instance
12
12
  end
13
13
 
14
14
  def create
15
- enforce_permission_to :create, :result
16
-
17
15
  @form = form(Admin::ImportResultsForm).from_params(params, current_component:)
18
16
 
19
17
  if @form.valid?
@@ -23,9 +21,15 @@ module Decidim
23
21
  redirect_to import_results_path(current_participatory_space, current_component)
24
22
  else
25
23
  flash[:alert] = I18n.t("imports.create.invalid", scope: "decidim.accountability.admin")
26
- render action: "new", status: :unprocessable_entity
24
+ render action: "new", status: :unprocessable_content
27
25
  end
28
26
  end
27
+
28
+ private
29
+
30
+ def ensure_permissions
31
+ enforce_permission_to :create, :result
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -27,7 +27,7 @@ module Decidim
27
27
 
28
28
  on(:invalid) do
29
29
  flash.now[:alert] = I18n.t("milestones.create.invalid", scope: "decidim.accountability.admin")
30
- render action: "new", status: :unprocessable_entity
30
+ render action: "new", status: :unprocessable_content
31
31
  end
32
32
  end
33
33
  end
@@ -51,7 +51,7 @@ module Decidim
51
51
 
52
52
  on(:invalid) do
53
53
  flash.now[:alert] = I18n.t("milestones.update.invalid", scope: "decidim.accountability.admin")
54
- render action: "edit", status: :unprocessable_entity
54
+ render action: "edit", status: :unprocessable_content
55
55
  end
56
56
  end
57
57
  end
@@ -88,12 +88,12 @@ module Decidim
88
88
  end
89
89
 
90
90
  def result_params
91
- @result_params ||= params.require(:result_bulk_actions).permit(
92
- :decidim_accountability_status_id,
93
- :start_date,
94
- :end_date,
95
- result_ids: [],
96
- taxonomies: []
91
+ @result_params ||= params.expect(
92
+ result_bulk_actions: [:decidim_accountability_status_id,
93
+ :start_date,
94
+ :end_date,
95
+ { result_ids: [],
96
+ taxonomies: [] }]
97
97
  )
98
98
  end
99
99
  end
@@ -13,6 +13,11 @@ module Decidim
13
13
 
14
14
  helper_method :results, :parent_result, :parent_results, :statuses, :present, :bulk_actions_form
15
15
 
16
+ def collection
17
+ parent_id = params[:parent_id].presence
18
+ @collection ||= Result.where(component: current_component, parent_id:).page(params[:page]).per(15).order(created_at: :asc)
19
+ end
20
+
16
21
  def new
17
22
  enforce_permission_to :create, :result
18
23
 
@@ -33,7 +38,7 @@ module Decidim
33
38
 
34
39
  on(:invalid) do
35
40
  flash.now[:alert] = I18n.t("results.create.invalid", scope: "decidim.accountability.admin")
36
- render action: "new", status: :unprocessable_entity
41
+ render action: "new", status: :unprocessable_content
37
42
  end
38
43
  end
39
44
  end
@@ -57,18 +62,11 @@ module Decidim
57
62
 
58
63
  on(:invalid) do
59
64
  flash.now[:alert] = I18n.t("results.update.invalid", scope: "decidim.accountability.admin")
60
- render action: "edit", status: :unprocessable_entity
65
+ render action: "edit", status: :unprocessable_content
61
66
  end
62
67
  end
63
68
  end
64
69
 
65
- protected
66
-
67
- def collection
68
- parent_id = params[:parent_id].presence
69
- @collection ||= Result.where(component: current_component, parent_id:).page(params[:page]).per(15).order(created_at: :asc)
70
- end
71
-
72
70
  private
73
71
 
74
72
  def trashable_deleted_resource_type
@@ -5,6 +5,8 @@ module Decidim
5
5
  module Admin
6
6
  # This controller allows an admin to manage results from a Participatory Process
7
7
  class StatusesController < Admin::ApplicationController
8
+ include Decidim::Accountability::Admin::Filterable
9
+
8
10
  helper_method :statuses
9
11
 
10
12
  def new
@@ -26,7 +28,7 @@ module Decidim
26
28
 
27
29
  on(:invalid) do
28
30
  flash.now[:alert] = I18n.t("statuses.create.invalid", scope: "decidim.accountability.admin")
29
- render action: "new", status: :unprocessable_entity
31
+ render action: "new", status: :unprocessable_content
30
32
  end
31
33
  end
32
34
  end
@@ -50,7 +52,7 @@ module Decidim
50
52
 
51
53
  on(:invalid) do
52
54
  flash.now[:alert] = I18n.t("statuses.update.invalid", scope: "decidim.accountability.admin")
53
- render action: "edit", status: :unprocessable_entity
55
+ render action: "edit", status: :unprocessable_content
54
56
  end
55
57
  end
56
58
  end
@@ -68,8 +70,18 @@ module Decidim
68
70
 
69
71
  private
70
72
 
73
+ def base_query
74
+ Status.where(component: current_component)
75
+ end
76
+
77
+ def filtered_collection
78
+ query.sorts = ["progress asc", "key asc"] if query.sorts.empty?
79
+
80
+ paginate(query.result)
81
+ end
82
+
71
83
  def statuses
72
- @statuses ||= Status.where(component: current_component).page(params[:page]).per(15)
84
+ @statuses ||= filtered_collection
73
85
  end
74
86
 
75
87
  def status
@@ -5,22 +5,18 @@ module Decidim
5
5
  # Exposes the result resource so users can view them
6
6
  class ResultsController < Decidim::Accountability::ApplicationController
7
7
  include FilterResource
8
+
8
9
  helper Decidim::TraceabilityHelper
9
10
  helper Decidim::Accountability::BreadcrumbHelper
11
+ helper Decidim::Accountability::CalculatorHelper
10
12
 
11
- helper_method :results, :result, :count_calculator, :selected_root_taxonomy, :selected_taxonomy_children, :selected_taxonomy_grandchildren?
12
-
13
- before_action :set_controller_breadcrumb
13
+ helper_method :results, :result, :selected_root_taxonomy, :selected_taxonomy_children, :selected_taxonomy_grandchildren?
14
14
 
15
15
  def show
16
16
  raise ActionController::RoutingError, "Not Found" unless result
17
-
18
- enforce_permission_to :read, :result, result:
19
17
  end
20
18
 
21
19
  def home
22
- enforce_permission_to :read, :result
23
-
24
20
  @all_geocoded_results = results.geocoded
25
21
  end
26
22
 
@@ -70,27 +66,25 @@ module Decidim
70
66
  end
71
67
  end
72
68
 
73
- def count_calculator(taxonomy_id)
74
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).count
75
- end
76
-
77
- def controller_breadcrumb_items
78
- @controller_breadcrumb_items ||= []
79
- end
80
-
81
- def set_controller_breadcrumb
82
- controller_breadcrumb_items << breadcrumb_item
83
- end
84
-
85
- def breadcrumb_item
69
+ def add_parent_breadcrumb_item
86
70
  return {} if result&.parent.blank?
87
71
 
88
72
  {
89
73
  label: translated_attribute(result.parent.title),
90
- url: result_path(result.parent),
74
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result.parent),
91
75
  active: true
92
76
  }
93
77
  end
78
+
79
+ def add_breadcrumb_item
80
+ return {} if result.blank?
81
+
82
+ {
83
+ label: translated_attribute(result.title),
84
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result),
85
+ active: false
86
+ }
87
+ end
94
88
  end
95
89
  end
96
90
  end
@@ -10,15 +10,25 @@ module Decidim
10
10
 
11
11
  include Decidim::ResourceVersionsConcern
12
12
 
13
- private
14
-
15
13
  def versioned_resource
16
14
  result
17
15
  end
18
16
 
17
+ private
18
+
19
19
  def result
20
20
  @result ||= Result.includes(:milestones).where(component: current_component).find(params[:result_id])
21
21
  end
22
+
23
+ def add_breadcrumb_item
24
+ return {} if result.blank?
25
+
26
+ {
27
+ label: translated_attribute(result.title),
28
+ url: Decidim::EngineRouter.main_proxy(current_component).result_path(result),
29
+ active: false
30
+ }
31
+ end
22
32
  end
23
33
  end
24
34
  end
@@ -15,7 +15,6 @@ module Decidim
15
15
 
16
16
  validates :key, presence: true
17
17
  validates :name, translatable_presence: true
18
- validates :progress, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 }, if: ->(form) { form.progress.present? }
19
18
  end
20
19
  end
21
20
  end
@@ -5,10 +5,6 @@ module Decidim
5
5
  # Helpers needed to render the navigation breadcrumbs in results.
6
6
  #
7
7
  module BreadcrumbHelper
8
- def progress_calculator(taxonomy_id)
9
- Decidim::Accountability::ResultsCalculator.new(current_component, taxonomy_id).progress
10
- end
11
-
12
8
  def taxonomy
13
9
  return if (taxonomy_id = params.dig(:filter, :taxonomies_part_of_contains)).blank?
14
10
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Accountability
5
+ # Helpers for calculating results progress and count
6
+ module CalculatorHelper
7
+ def progress_calculator(taxonomy_id)
8
+ ResultsCalculator.new(current_component, taxonomy_id).progress
9
+ end
10
+
11
+ def count_calculator(taxonomy_id)
12
+ ResultsCalculator.new(current_component, taxonomy_id).count
13
+ end
14
+ end
15
+ end
16
+ end
@@ -3,12 +3,13 @@
3
3
  module Decidim
4
4
  module Accountability
5
5
  # This mailer sends a notification email containing the result of importing
6
- # Cprojects to the results.
6
+ # projects from one budget component to accountability.
7
7
  class ImportProjectsMailer < Decidim::ApplicationMailer
8
8
  include Decidim::TranslatableAttributes
9
+
9
10
  helper Decidim::TranslationsHelper
10
11
 
11
- # Public: Sends a notification email with the result of projects import selected projects to Accountability
12
+ # Public: Sends a notification email with the result of importing projects
12
13
  #
13
14
  # user - The user to be notified.
14
15
  #
@@ -6,6 +6,7 @@ module Decidim
6
6
  # proposals to the results.
7
7
  class ImportProposalsMailer < Decidim::ApplicationMailer
8
8
  include Decidim::TranslatableAttributes
9
+
9
10
  helper Decidim::TranslationsHelper
10
11
 
11
12
  # Public: Sends a notification email with the result of proposals import selected proposals to Accountability
@@ -39,13 +39,15 @@ module Decidim
39
39
 
40
40
  after_save :update_parent_progress, if: -> { parent_id.present? }
41
41
 
42
- searchable_fields(
43
- scope_id: :decidim_scope_id,
44
- participatory_space: { component: :participatory_space },
45
- A: :title,
46
- D: :description,
47
- datetime: :start_date
48
- )
42
+ searchable_fields({
43
+ scope_id: :decidim_scope_id,
44
+ participatory_space: { component: :participatory_space },
45
+ A: :title,
46
+ D: :description,
47
+ datetime: :start_date
48
+ },
49
+ index_on_create: ->(result) { result.visible? },
50
+ index_on_update: ->(result) { result.visible? })
49
51
 
50
52
  geocoded_by :address
51
53
 
@@ -22,8 +22,11 @@ module Decidim
22
22
  # Allow ransacker to search for a key in a hstore column (`name`.`en`)
23
23
  ransacker_i18n :name
24
24
 
25
- def self.ransackable_attributes(_auth_object = nil)
26
- %w(id name)
25
+ def self.ransackable_attributes(auth_object = nil)
26
+ base = %w(id name)
27
+ return base unless auth_object&.admin?
28
+
29
+ base + %w(key progress)
27
30
  end
28
31
 
29
32
  def self.log_presenter_class_for(_log)
@@ -91,7 +91,7 @@
91
91
  @apply text-3xl;
92
92
  }
93
93
 
94
- &__project &-title {
94
+ &__result &-title {
95
95
  @apply text-gray-2 text-md font-normal;
96
96
  }
97
97
  }
@@ -132,7 +132,7 @@
132
132
  @apply ml-auto rounded px-3 md:px-6 py-4 bg-background font-bold text-gray-2 text-xl w-full md:w-auto min-w-[120px] grid place-items-center;
133
133
  }
134
134
 
135
- &__project {
135
+ &__result {
136
136
  &-aside {
137
137
  @apply bg-background p-4 rounded divide-y divide-gray-3 [&>*]:py-4 first:[&>*]:pt-0 last:[&>*]:pb-0;
138
138
 
@@ -18,7 +18,7 @@ module Decidim
18
18
  def public_read_result_action?
19
19
  return unless permission_action.action == :read && permission_action.subject == :result
20
20
 
21
- toggle_allow(result.nil? || !result.deleted?)
21
+ toggle_allow(result && !result.deleted?)
22
22
  end
23
23
 
24
24
  def result
@@ -7,7 +7,7 @@
7
7
 
8
8
  <div class="item__edit item__edit-1col">
9
9
  <div class="item__edit-form">
10
- <%= render "form" %>
10
+ <%= render "decidim/accountability/admin/import_components/form" %>
11
11
  </div>
12
12
  </div>
13
13
 
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  <div class="item__edit item__edit-1col">
8
8
  <div class="item__edit-form">
9
- <%= decidim_form_for(@form, url: import_results_path, html: { class: "form form-defaults import_projects" }) do |form| %>
9
+ <%= decidim_form_for(@form, url: import_results_path, html: { class: "form form-defaults import_results" }) do |form| %>
10
10
  <div class="card py-4">
11
11
  <div class="card-section space-y-4 prose max-w-full">
12
12
  <div class="row column">
@@ -88,7 +88,7 @@
88
88
  <% else %>
89
89
  <li class="dropdown__item">
90
90
  <div class="dropdown__button-disabled">
91
- <%= with_tooltip t("tooltips.deleted_results_info", scope: "decidim.admin"), class: :left do %>
91
+ <%= with_tooltip t("tooltips.deleted_results_info", scope: "decidim.admin") do %>
92
92
  <%= icon "delete-bin-line", class: "text-gray" %>
93
93
  <span>
94
94
  <%= t("actions.soft_delete", scope: "decidim.admin") %>
@@ -48,11 +48,9 @@
48
48
  <% end %>
49
49
 
50
50
  <div class="row">
51
- <% if statuses.any? %>
52
- <div class="columns">
53
- <%= form.select :decidim_accountability_status_id, statuses.map { |status| [translated_attribute(status.name), status.id, { "data-progress" => status.progress }] }, include_blank: true %>
54
- </div>
55
- <% end %>
51
+ <div class="columns">
52
+ <%= form.select :decidim_accountability_status_id, statuses.map { |status| [translated_attribute(status.name), status.id, { "data-progress" => status.progress }] }, include_blank: true %>
53
+ </div>
56
54
 
57
55
  <div class="columns">
58
56
  <%= form.number_field :progress %>