decidim-budgets 0.22.0 → 0.23.0

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 (171) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -3
  3. data/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +5 -0
  4. data/app/cells/decidim/budgets/base_cell.rb +22 -0
  5. data/app/cells/decidim/budgets/budget_cell.rb +21 -0
  6. data/app/cells/decidim/budgets/budget_information_modal/show.erb +28 -0
  7. data/app/cells/decidim/budgets/budget_information_modal_cell.rb +22 -0
  8. data/app/cells/decidim/budgets/budget_list_item/show.erb +22 -0
  9. data/app/cells/decidim/budgets/budget_list_item_cell.rb +40 -0
  10. data/app/cells/decidim/budgets/budget_m/data.erb +12 -0
  11. data/app/cells/decidim/budgets/budget_m/footer.erb +5 -0
  12. data/app/cells/decidim/budgets/budget_m_cell.rb +16 -0
  13. data/app/cells/decidim/budgets/budgets_header/show.erb +7 -0
  14. data/app/cells/decidim/budgets/budgets_header_cell.rb +14 -0
  15. data/app/cells/decidim/budgets/budgets_list/card_list.erb +7 -0
  16. data/app/cells/decidim/budgets/budgets_list/highlighted.erb +11 -0
  17. data/app/cells/decidim/budgets/budgets_list/show.erb +20 -0
  18. data/app/cells/decidim/budgets/budgets_list/voted.erb +43 -0
  19. data/app/cells/decidim/budgets/budgets_list_cell.rb +39 -0
  20. data/app/cells/decidim/budgets/limit_announcement_cell.rb +52 -0
  21. data/app/cells/decidim/budgets/project_list_item/project_data.erb +17 -3
  22. data/app/cells/decidim/budgets/project_list_item/project_data_vote_button.erb +2 -2
  23. data/app/cells/decidim/budgets/project_list_item/project_text.erb +11 -5
  24. data/app/cells/decidim/budgets/project_list_item/show.erb +3 -3
  25. data/app/cells/decidim/budgets/project_list_item_cell.rb +8 -28
  26. data/app/cells/decidim/budgets/project_m/data.erb +1 -1
  27. data/app/cells/decidim/budgets/project_m_cell.rb +4 -0
  28. data/app/cells/decidim/budgets/project_selected_status_cell.rb +28 -0
  29. data/app/cells/decidim/budgets/project_tags/show.erb +5 -0
  30. data/app/cells/decidim/budgets/project_tags_cell.rb +18 -0
  31. data/app/cells/decidim/budgets/project_voted_hint_cell.rb +33 -0
  32. data/app/cells/decidim/budgets/project_votes_count_cell.rb +44 -0
  33. data/app/commands/decidim/budgets/add_line_item.rb +7 -10
  34. data/app/commands/decidim/budgets/admin/create_budget.rb +48 -0
  35. data/app/commands/decidim/budgets/admin/create_project.rb +12 -7
  36. data/app/commands/decidim/budgets/admin/destroy_budget.rb +42 -0
  37. data/app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb +26 -25
  38. data/app/commands/decidim/budgets/admin/update_budget.rb +48 -0
  39. data/app/commands/decidim/budgets/admin/update_project.rb +8 -1
  40. data/app/commands/decidim/budgets/checkout.rb +6 -6
  41. data/app/commands/decidim/budgets/remove_line_item.rb +3 -2
  42. data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +14 -2
  43. data/app/controllers/concerns/decidim/budgets/orderable.rb +3 -7
  44. data/app/controllers/decidim/budgets/admin/application_controller.rb +10 -2
  45. data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +1 -1
  46. data/app/controllers/decidim/budgets/admin/attachments_controller.rb +2 -2
  47. data/app/controllers/decidim/budgets/admin/budgets_controller.rb +82 -0
  48. data/app/controllers/decidim/budgets/admin/projects_controller.rb +7 -7
  49. data/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb +10 -2
  50. data/app/controllers/decidim/budgets/application_controller.rb +23 -0
  51. data/app/controllers/decidim/budgets/budgets_controller.rb +24 -0
  52. data/app/controllers/decidim/budgets/line_items_controller.rb +9 -5
  53. data/app/controllers/decidim/budgets/orders_controller.rb +20 -6
  54. data/app/controllers/decidim/budgets/projects_controller.rb +19 -18
  55. data/app/forms/decidim/budgets/admin/budget_form.rb +39 -0
  56. data/app/forms/decidim/budgets/admin/project_form.rb +14 -10
  57. data/app/forms/decidim/budgets/admin/project_import_proposals_form.rb +4 -0
  58. data/app/helpers/decidim/budgets/admin/application_helper.rb +13 -0
  59. data/app/helpers/decidim/budgets/application_helper.rb +10 -0
  60. data/app/helpers/decidim/budgets/projects_helper.rb +0 -4
  61. data/app/mailers/decidim/budgets/order_summary_mailer.rb +5 -3
  62. data/app/models/decidim/budgets/budget.rb +34 -0
  63. data/app/models/decidim/budgets/line_item.rb +4 -4
  64. data/app/models/decidim/budgets/order.rb +22 -19
  65. data/app/models/decidim/budgets/project.rb +34 -5
  66. data/app/permissions/decidim/budgets/admin/permissions.rb +23 -10
  67. data/app/permissions/decidim/budgets/permissions.rb +28 -6
  68. data/app/presenters/decidim/budgets/admin_log/budget_presenter.rb +42 -0
  69. data/app/queries/decidim/budgets/filtered_projects.rb +9 -1
  70. data/app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb +3 -2
  71. data/app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb +6 -5
  72. data/app/serializers/decidim/budgets/data_portability_budgets_order_serializer.rb +3 -2
  73. data/app/services/decidim/budgets/project_search.rb +12 -24
  74. data/app/types/decidim/budgets/budget_type.rb +24 -0
  75. data/app/types/decidim/budgets/budgets_type.rb +6 -6
  76. data/app/types/decidim/budgets/project_type.rb +2 -1
  77. data/app/views/decidim/budgets/admin/budgets/_form.html.erb +23 -0
  78. data/app/views/decidim/budgets/admin/budgets/edit.html.erb +7 -0
  79. data/app/views/decidim/budgets/admin/budgets/index.html.erb +58 -0
  80. data/app/views/decidim/budgets/admin/budgets/new.html.erb +7 -0
  81. data/app/views/decidim/budgets/admin/projects/_form.html.erb +12 -4
  82. data/app/views/decidim/budgets/admin/projects/edit.html.erb +2 -2
  83. data/app/views/decidim/budgets/admin/projects/index.html.erb +20 -7
  84. data/app/views/decidim/budgets/admin/projects/new.html.erb +2 -2
  85. data/app/views/decidim/budgets/admin/proposals_imports/new.html.erb +1 -1
  86. data/app/views/decidim/budgets/budgets/index.html.erb +5 -0
  87. data/app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb +1 -0
  88. data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +3 -3
  89. data/app/views/decidim/budgets/projects/_budget_summary.html.erb +19 -6
  90. data/app/views/decidim/budgets/projects/_filters.html.erb +6 -2
  91. data/app/views/decidim/budgets/projects/_linked_projects.html.erb +1 -1
  92. data/app/views/decidim/budgets/projects/_order_progress.html.erb +10 -6
  93. data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +3 -3
  94. data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +36 -7
  95. data/app/views/decidim/budgets/projects/index.html.erb +12 -4
  96. data/app/views/decidim/budgets/projects/show.html.erb +17 -10
  97. data/config/locales/am-ET.yml +1 -0
  98. data/config/locales/ar.yml +2 -11
  99. data/config/locales/bg.yml +6 -0
  100. data/config/locales/ca.yml +102 -10
  101. data/config/locales/cs.yml +105 -13
  102. data/config/locales/da.yml +1 -0
  103. data/config/locales/de.yml +90 -9
  104. data/config/locales/el.yml +3 -9
  105. data/config/locales/en.yml +101 -9
  106. data/config/locales/eo.yml +1 -0
  107. data/config/locales/es-MX.yml +101 -9
  108. data/config/locales/es-PY.yml +101 -9
  109. data/config/locales/es.yml +102 -10
  110. data/config/locales/et.yml +1 -0
  111. data/config/locales/eu.yml +3 -8
  112. data/config/locales/fi-plain.yml +102 -10
  113. data/config/locales/fi.yml +103 -11
  114. data/config/locales/fr-CA.yml +100 -9
  115. data/config/locales/fr.yml +100 -9
  116. data/config/locales/gl.yml +2 -7
  117. data/config/locales/hr.yml +1 -0
  118. data/config/locales/hu.yml +2 -7
  119. data/config/locales/id-ID.yml +2 -6
  120. data/config/locales/is-IS.yml +0 -6
  121. data/config/locales/is.yml +114 -0
  122. data/config/locales/it.yml +71 -9
  123. data/config/locales/ja-JP.yml +1 -0
  124. data/config/locales/ja.yml +262 -0
  125. data/config/locales/ko-KR.yml +1 -0
  126. data/config/locales/ko.yml +1 -0
  127. data/config/locales/lt.yml +1 -0
  128. data/config/locales/{lv-LV.yml → lv.yml} +2 -10
  129. data/config/locales/mt.yml +1 -0
  130. data/config/locales/nl.yml +88 -10
  131. data/config/locales/no.yml +22 -9
  132. data/config/locales/om-ET.yml +1 -0
  133. data/config/locales/pl.yml +113 -22
  134. data/config/locales/pt-BR.yml +2 -7
  135. data/config/locales/pt.yml +3 -9
  136. data/config/locales/ro-RO.yml +3 -10
  137. data/config/locales/ru.yml +2 -9
  138. data/config/locales/sk.yml +2 -11
  139. data/config/locales/sl.yml +0 -4
  140. data/config/locales/so-SO.yml +1 -0
  141. data/config/locales/sr-CS.yml +0 -2
  142. data/config/locales/sv.yml +80 -9
  143. data/config/locales/ti-ER.yml +1 -0
  144. data/config/locales/tr-TR.yml +2 -7
  145. data/config/locales/uk.yml +2 -9
  146. data/config/locales/vi-VN.yml +1 -0
  147. data/config/locales/vi.yml +1 -0
  148. data/config/locales/zh-CN.yml +260 -0
  149. data/config/locales/zh-TW.yml +1 -0
  150. data/db/migrate/20200617105120_create_decidim_budgets.rb +15 -0
  151. data/db/migrate/20200629072626_rename_budget_to_budget_ammount.rb +7 -0
  152. data/db/migrate/20200629134013_add_budget_reference_to_project.rb +7 -0
  153. data/db/migrate/20200706142609_add_budget_reference_to_order.rb +7 -0
  154. data/db/migrate/20200714103519_move_budgets_to_own_model.rb +109 -0
  155. data/db/migrate/20200717140012_add_scope_to_budgets.rb +7 -0
  156. data/db/migrate/20200728075039_add_selected_at_to_project.rb +7 -0
  157. data/db/migrate/20200804175222_votes_enabled_to_votes_choices.rb +35 -0
  158. data/db/migrate/20200827154129_add_commentable_counter_cache_to_projects.rb +9 -0
  159. data/lib/decidim/budgets.rb +1 -0
  160. data/lib/decidim/budgets/admin_engine.rb +10 -5
  161. data/lib/decidim/budgets/component.rb +83 -38
  162. data/lib/decidim/budgets/engine.rb +8 -6
  163. data/lib/decidim/budgets/test/factories.rb +42 -13
  164. data/lib/decidim/budgets/version.rb +1 -1
  165. data/lib/decidim/budgets/workflows.rb +17 -0
  166. data/lib/decidim/budgets/workflows/all.rb +20 -0
  167. data/lib/decidim/budgets/workflows/base.rb +132 -0
  168. data/lib/decidim/budgets/workflows/one.rb +33 -0
  169. metadata +84 -17
  170. data/app/cells/decidim/budgets/project_list_item/project_data_number.erb +0 -3
  171. data/app/cells/decidim/budgets/project_list_item/project_data_votes.erb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a52564133c108bcd32c5b1f4729eb4e8430708fbc59dab774f90f07c517f5a01
4
- data.tar.gz: e3cc8184fdba7e909b34b89e1ad94955a99134521aed3e4222096b8d10f8f934
3
+ metadata.gz: 077d69766f3c2f74c8cfd5086383104ccdb406f05d58248ac11c4a93ea6bed0c
4
+ data.tar.gz: 957fb8550045fdf6acf9fe3453083698deedeb09632e2c7be628574446fd3a60
5
5
  SHA512:
6
- metadata.gz: f3711ec5978d688a91da72965fa96141cd3ae37a15a709e9529bd7d7a15416313339ebbdfbbf3524fa1a4ee4f734b4a8ac82460ea5bc96732bd92ffea3cfe63c
7
- data.tar.gz: ee3b9d5b2ca5ab49f195c3ebc76dc7579ce85d2dfed11e591a5ad1ca56fe4e16e9fa77dd19479e1c0af016aed5b5dbcbf4a8789b6be64bc9ddef975573c10e73
6
+ metadata.gz: 328372626474416b447a01819af4236c6f23a2f87db34c93de38f874a9f753b0d328693a68bcdbad6e64a7f3a621e8b493aa040ba6096d128db6e94f607e7d3f
7
+ data.tar.gz: ae2d589d569d8e51355e6f928e9185d9cb0728f1667de5d34029e39bbf6a6465b8f77947a6d0314159a2edb36877aae5af3703786749075ad94de621c80ff913
data/README.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Decidim::Budgets
2
2
 
3
- The Budgets module adds projects to any participatory process. It adds a CRUD engine to the admin and public views scoped inside the participatory process. Projects will link to related proposals and have a budget. The users should be able to distribute a budget between these projects.
3
+ The Budgets module adds budgets with projects related to them to any participatory process. It adds a CRUD engine to the admin and public views scoped inside the participatory space. Projects will link to related proposals and have a budget. The users should be able to distribute a budget between these projects.
4
4
 
5
5
  ## Usage
6
6
 
7
- Budgets will be available as a Component for a Participatory Process.
7
+ Budgets will be available as a Component for a Participatory Space.
8
+
9
+ This plugin provides:
10
+
11
+ * A CRUD engine to manage budgets.
12
+ * A CRUD engine to manage projects related to a budget.
13
+ * Participant orders with the voted projects
14
+ * Budgets workflow to add different rules for budget voting.
15
+ * Public views for budgets and projects.
8
16
 
9
17
  ## Installation
10
18
 
11
19
  Add this line to your application's Gemfile:
12
20
 
13
21
  ```ruby
14
- gem 'decidim-budgets
22
+ gem "decidim-budgets"
15
23
  ```
16
24
 
17
25
  And then execute:
@@ -20,6 +28,33 @@ And then execute:
20
28
  bundle
21
29
  ```
22
30
 
31
+ ## Budget Workflows
32
+
33
+ A budget workflow, let's an admin pick, at the component level, how a user can participate in it.
34
+ By default there are two workflows included in this module, `:one` and `:all` that can be found in the `lib/decidim/budgets/workflows/` directory, any app can add its own workflow.
35
+
36
+ ### Adding a custom workflow
37
+
38
+ To add a custom workflow, create a workflow that inherits from the `base`, such as:
39
+
40
+ ```rb
41
+ # lib/budgets_workflow_random.rb
42
+ class BudgetsWorkflowRandom < Decidim::Budgets::Workflows::Base
43
+ # your code here ...
44
+ end
45
+ ```
46
+
47
+ And then add it to the decidim initializer (`config/initializers/decidim_budgets.rb`):
48
+
49
+ ```rb
50
+ require "budgets_workflow_random"
51
+ Decidim::Budgets.workflows[:random] = BudgetsWorkflowRandom
52
+ ```
53
+
54
+ Also remember to add the translated name for the `:random` workflow.
55
+
56
+ As an example, the `BudgetsWorkflowRandom` (`decidim-generators/lib/decidim/generators/app_templates/budgets_workflow_random.rb`) workflow is added by the generator in the `development_app` and `test_app`.
57
+
23
58
  ## Contributing
24
59
 
25
60
  See [Decidim](https://github.com/decidim/decidim).
@@ -55,6 +55,10 @@
55
55
  display: flex;
56
56
  align-items: center;
57
57
  }
58
+
59
+ .card__text--status{
60
+ display: block;
61
+ }
58
62
  }
59
63
 
60
64
  &__data{
@@ -102,6 +106,7 @@
102
106
  @extend .card-data__item__number;
103
107
 
104
108
  font-size: 1.5rem;
109
+ line-height: 1.2;
105
110
  }
106
111
 
107
112
  &__data__votes{
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell has the commons for the budgets cells
6
+ class BaseCell < Decidim::ViewModel
7
+ include Decidim::LayoutHelper
8
+ include Decidim::SanitizeHelper
9
+ include Decidim::ComponentPathHelper
10
+ include Decidim::Budgets::Engine.routes.url_helpers
11
+
12
+ delegate :current_user, :current_settings, :current_component, :current_workflow, to: :controller
13
+ delegate :settings, to: :current_component
14
+
15
+ def budgets_link_list(budgets)
16
+ budgets.map { |budget| link_to(translated_attribute(budget.title), resource_locator(budget).path) }
17
+ .to_sentence
18
+ .html_safe
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the budget card for an instance of a budget
6
+ # the default size is the Medium Card (:m)
7
+ class BudgetCell < Decidim::ViewModel
8
+ include Cell::ViewModel::Partial
9
+
10
+ def show
11
+ cell card_size, model, options
12
+ end
13
+
14
+ private
15
+
16
+ def card_size
17
+ "decidim/budgets/budget_m"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,28 @@
1
+ <button class="link" data-open="budget-modal-info" aria-controls="budget-modal-info" aria-haspopup="true" tabindex="0">
2
+ <%= t(:more_information, scope: i18n_scope) %>
3
+ </button>
4
+
5
+ <div class="reveal" data-reveal id="budget-modal-info">
6
+ <div class="reveal__header">
7
+ <h3 class="reveal__title"><%= decidim_sanitize(component_name) %></h3>
8
+ <button class="close-button" data-close aria-label="<%= t(:close_modal, scope: i18n_scope) %>" type="button">
9
+ <span aria-hidden="true">×</span>
10
+ </button>
11
+ </div>
12
+
13
+ <%= content_tag(:p, more_information) if more_information %>
14
+
15
+ <% unless current_workflow.single? %>
16
+ <p>
17
+ <%= link_to t(:back_to, scope: i18n_scope, component_name: component_name), budgets_path %>
18
+ </p>
19
+ <% end %>
20
+
21
+ <div class="row">
22
+ <div class="columns medium-8 medium-offset-2">
23
+ <button class="button expanded" data-close>
24
+ <%= t(:continue, scope: i18n_scope) %>
25
+ </button>
26
+ </div>
27
+ </div>
28
+ </div>
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the Budgets component "More information" modal dialog
6
+ class BudgetInformationModalCell < BaseCell
7
+ alias budget model
8
+
9
+ def more_information
10
+ translated_attribute(current_settings.more_information_modal).presence || translated_attribute(settings.more_information_modal)
11
+ end
12
+
13
+ def component_name
14
+ translated_attribute(current_component.name)
15
+ end
16
+
17
+ def i18n_scope
18
+ "decidim.budgets.budget_information_modal"
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ <div class="<%= card_class %>">
2
+ <div class="card--list__text">
3
+ <%= link_to budget_path(budget), class: link_class do %>
4
+ <% if voted? && !voting_finished? %>
5
+ <strong>
6
+ <%= translated_attribute(title) %>
7
+ </strong>
8
+ <span class="button tiny success card--list__check card--list__check--disabled">
9
+ <%= icon "check", class: "icon--small", role: "img" %>
10
+ </span>
11
+ <% else %>
12
+ <%= translated_attribute(title) %>
13
+
14
+ <% if progress? && !voting_finished? %>
15
+ <span class="button tiny hollow secondary card--list__check card--list__check--disabled">
16
+ <%= icon "bookmark", class: "icon--small", role: "img" %>
17
+ </span>
18
+ <% end %>
19
+ <% end %>
20
+ <% end %>
21
+ </div>
22
+ </div>
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the budget item list in the budgets list
6
+ class BudgetListItemCell < BaseCell
7
+ delegate :voting_finished?, to: :controller
8
+
9
+ property :title
10
+ alias budget model
11
+
12
+ private
13
+
14
+ def card_class
15
+ ["card--list__item"].tap do |list|
16
+ unless voting_finished?
17
+ list << "card--list__data-added" if voted?
18
+ list << "card--list__data-progress" if progress?
19
+ end
20
+ end.join(" ")
21
+ end
22
+
23
+ def link_class
24
+ "card__link card--list__heading"
25
+ end
26
+
27
+ def voted?
28
+ current_user && status == :voted
29
+ end
30
+
31
+ def progress?
32
+ current_user && status == :progress
33
+ end
34
+
35
+ def status
36
+ @status ||= current_workflow.status(budget)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ <div class="card__icondata">
2
+ <ul class="card-data">
3
+ <li class="card-data__item">
4
+ <%= icon "euro-outline", class: "icon--big", role: "img", "aria-hidden": true %>
5
+ </li>
6
+ <li class="card-data__item">
7
+ <div class="text-left">
8
+ <strong class="heading4"><%= budget_to_currency model.total_budget %></strong>
9
+ </div>
10
+ </li>
11
+ </ul>
12
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="card__footer">
2
+ <div class="card__support">
3
+ <%= link_to t("view", scope: "decidim.budgets.budget"), resource_path, class: "card__button button button--sc small" %>
4
+ </div>
5
+ </div>
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the Medium (:m) budget card
6
+ # for an given instance of a Decidim::Budgets::Budget
7
+ class BudgetMCell < Decidim::CardMCell
8
+ include ActiveSupport::NumberHelper
9
+ include Decidim::Budgets::ProjectsHelper
10
+
11
+ def statuses
12
+ []
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ <div class="row">
2
+ <div class="columns medium-7 mediumlarge-8">
3
+ <div class="section">
4
+ <%= decidim_sanitize(landing_page_content) %>
5
+ </div>
6
+ </div>
7
+ </div>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the Budgets component header
6
+ class BudgetsHeaderCell < BaseCell
7
+ private
8
+
9
+ def landing_page_content
10
+ translated_attribute(current_settings.landing_page_content).presence || translated_attribute(settings.landing_page_content)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ <div id="budgets" class="card card--list card--list--mini">
2
+ <% budgets.each do |budget| %>
3
+ <% next if highlighted.include?(budget) && !voting_finished? %>
4
+
5
+ <%= cell("decidim/budgets/budget_list_item", budget) %>
6
+ <% end %>
7
+ </div>
@@ -0,0 +1,11 @@
1
+ <% if highlighted? %>
2
+ <p id="highlighted-budget">
3
+ <% highlighted.each do |budget| %>
4
+ <%= link_to(
5
+ t("highlighted_cta", scope: i18n_scope,
6
+ name: translated_attribute(budget.title)),
7
+ resource_locator(budget).path,
8
+ class: :button ) %>
9
+ <% end %>
10
+ </p>
11
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <div class="row">
2
+ <div class="columns medium-7 mediumlarge-8">
3
+ <% if !voting_finished? && (highlighted? || voted?) %>
4
+ <div class="section">
5
+ <h3 class="section-heading">
6
+ <%= t(:my_budgets, scope: i18n_scope) %>
7
+ </h3>
8
+
9
+ <%= render :highlighted %>
10
+ <%= render :voted %>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="row">
15
+ <div class="columns mediumlarge-6">
16
+ <%= render :card_list %>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </div>
@@ -0,0 +1,43 @@
1
+ <% if voted? %>
2
+ <div id="voted-budgets">
3
+ <p class="lead">
4
+ <%= t(:voted_on, scope: i18n_scope, links: budgets_link_list(voted)) %>
5
+ </p>
6
+
7
+ <% if finished? %>
8
+ <p class="lead">
9
+ <%= t(:finished_message, scope: i18n_scope) %>
10
+ </p>
11
+ <% end %>
12
+
13
+ <% if voting_open? %>
14
+ <div>
15
+ <p>
16
+ <%= t(:if_change_opinion, scope: i18n_scope) %>
17
+ <%= link_to(
18
+ t("cancel_order.only_one", scope: i18n_scope),
19
+ budget_order_path(voted.first),
20
+ method: :delete,
21
+ data: { confirm: t("projects.budget_summary.are_you_sure", scope: "decidim.budgets") }) if voted.one? %>
22
+ </p>
23
+
24
+ <% if !voted.one? && voted.any? %>
25
+ <ul>
26
+ <% voted.each do |budget| %>
27
+ <li>
28
+ <%= link_to(
29
+ t("cancel_order.more_than_one", scope: i18n_scope, name: translated_attribute(budget.title)),
30
+ budget_order_path(budget),
31
+ method: :delete,
32
+ class: "cancel-order",
33
+ data: {
34
+ confirm: t("projects.budget_summary.are_you_sure", scope: "decidim.budgets")
35
+ }) %>
36
+ </li>
37
+ <% end %>
38
+ </ul>
39
+ <% end %>
40
+ </div>
41
+ <% end %>
42
+ </div>
43
+ <% end %>
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the budgets list of a Budget component
6
+ class BudgetsListCell < BaseCell
7
+ alias current_workflow model
8
+
9
+ delegate :allowed, :budgets, :highlighted, :voted, to: :current_workflow
10
+ delegate :voting_open?, :voting_finished?, to: :controller
11
+
12
+ def show
13
+ return unless budgets
14
+
15
+ render
16
+ end
17
+
18
+ private
19
+
20
+ def highlighted?
21
+ current_user && highlighted.any?
22
+ end
23
+
24
+ def voted?
25
+ current_user && voted.any?
26
+ end
27
+
28
+ def finished?
29
+ return unless budgets.any?
30
+
31
+ current_user && (allowed - voted).none?
32
+ end
33
+
34
+ def i18n_scope
35
+ "decidim.budgets.budgets_list"
36
+ end
37
+ end
38
+ end
39
+ end