decidim-budgets 0.27.9 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/stylesheets/decidim/budgets/budget/_budget-vote-button.scss +5 -5
  4. data/app/cells/decidim/budgets/base_cell.rb +1 -1
  5. data/app/cells/decidim/budgets/budget_cell.rb +6 -1
  6. data/app/cells/decidim/budgets/budget_information_modal/show.erb +14 -26
  7. data/app/cells/decidim/budgets/budget_list_item/projects_count.erb +6 -0
  8. data/app/cells/decidim/budgets/budget_list_item/show.erb +35 -30
  9. data/app/cells/decidim/budgets/budget_list_item/vote_action.erb +13 -0
  10. data/app/cells/decidim/budgets/budget_list_item_cell.rb +24 -1
  11. data/app/cells/decidim/budgets/budget_metadata_cell.rb +29 -0
  12. data/app/cells/decidim/budgets/budget_s_cell.rb +15 -0
  13. data/app/cells/decidim/budgets/budgets_header/show.erb +2 -6
  14. data/app/cells/decidim/budgets/budgets_list/card_list.erb +8 -13
  15. data/app/cells/decidim/budgets/budgets_list/main_list.erb +5 -0
  16. data/app/cells/decidim/budgets/budgets_list/show.erb +12 -16
  17. data/app/cells/decidim/budgets/budgets_list/voted.erb +8 -44
  18. data/app/cells/decidim/budgets/budgets_list_cell.rb +34 -0
  19. data/app/cells/decidim/budgets/limit_announcement/show.erb +3 -0
  20. data/app/cells/decidim/budgets/limit_announcement_cell.rb +2 -2
  21. data/app/cells/decidim/budgets/order_activity_cell.rb +1 -4
  22. data/app/cells/decidim/budgets/project_cell.rb +6 -1
  23. data/app/cells/decidim/budgets/project_l/extra_data.erb +6 -0
  24. data/app/cells/decidim/budgets/project_l/metadata.erb +4 -0
  25. data/app/cells/decidim/budgets/project_l_cell.rb +38 -0
  26. data/app/cells/decidim/budgets/project_metadata_cell.rb +78 -0
  27. data/app/cells/decidim/budgets/project_s_cell.rb +21 -0
  28. data/app/cells/decidim/budgets/project_tags/show.erb +1 -0
  29. data/app/cells/decidim/budgets/project_vote_button/show.erb +21 -15
  30. data/app/cells/decidim/budgets/project_vote_button_cell.rb +69 -1
  31. data/app/cells/decidim/budgets/project_voted_hint_cell.rb +1 -1
  32. data/app/cells/decidim/budgets/project_votes_count_cell.rb +9 -8
  33. data/app/commands/decidim/budgets/admin/create_project.rb +0 -1
  34. data/app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb +1 -1
  35. data/app/commands/decidim/budgets/admin/update_project.rb +1 -2
  36. data/app/commands/decidim/budgets/admin/update_project_scope.rb +1 -1
  37. data/app/commands/decidim/budgets/admin/update_project_selection.rb +1 -1
  38. data/app/commands/decidim/budgets/admin/update_projects_budget.rb +57 -0
  39. data/app/controllers/concerns/decidim/budgets/admin/filterable.rb +1 -1
  40. data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +2 -2
  41. data/app/controllers/decidim/budgets/admin/budgets_controller.rb +5 -5
  42. data/app/controllers/decidim/budgets/admin/projects_controller.rb +52 -10
  43. data/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb +1 -1
  44. data/app/controllers/decidim/budgets/application_controller.rb +0 -4
  45. data/app/controllers/decidim/budgets/budgets_controller.rb +9 -0
  46. data/app/controllers/decidim/budgets/line_items_controller.rb +10 -16
  47. data/app/controllers/decidim/budgets/orders_controller.rb +7 -2
  48. data/app/controllers/decidim/budgets/projects_controller.rb +51 -4
  49. data/app/forms/decidim/budgets/admin/project_form.rb +1 -1
  50. data/app/helpers/decidim/budgets/application_helper.rb +4 -0
  51. data/app/helpers/decidim/budgets/projects_helper.rb +89 -33
  52. data/app/jobs/decidim/budgets/send_vote_reminder_job.rb +1 -1
  53. data/app/mailers/decidim/budgets/order_summary_mailer.rb +1 -1
  54. data/app/mailers/decidim/budgets/vote_reminder_mailer.rb +1 -1
  55. data/app/models/decidim/budgets/budget.rb +1 -0
  56. data/app/models/decidim/budgets/project.rb +17 -7
  57. data/app/packs/entrypoints/decidim_budgets.js +2 -0
  58. data/app/packs/src/decidim/budgets/exit_handler.js +11 -8
  59. data/app/packs/src/decidim/budgets/progressFixed.js +25 -11
  60. data/app/packs/src/decidim/budgets/projects.js +15 -10
  61. data/app/packs/stylesheets/budgets.scss +273 -0
  62. data/app/presenters/decidim/budgets/admin_log/budget_presenter.rb +2 -2
  63. data/app/presenters/decidim/budgets/admin_log/project_presenter.rb +2 -2
  64. data/app/services/decidim/budgets/order_reminder_generator.rb +4 -4
  65. data/app/views/decidim/budgets/admin/budgets/_form.html.erb +17 -12
  66. data/app/views/decidim/budgets/admin/budgets/edit.html.erb +16 -6
  67. data/app/views/decidim/budgets/admin/budgets/index.html.erb +58 -64
  68. data/app/views/decidim/budgets/admin/budgets/new.html.erb +16 -6
  69. data/app/views/decidim/budgets/admin/projects/_bulk-actions.html.erb +19 -10
  70. data/app/views/decidim/budgets/admin/projects/_form.html.erb +31 -35
  71. data/app/views/decidim/budgets/admin/projects/_project-tr.html.erb +15 -13
  72. data/app/views/decidim/budgets/admin/projects/bulk_actions/_budget-change.html.erb +22 -0
  73. data/app/views/decidim/budgets/admin/projects/bulk_actions/_change-selected.html.erb +3 -3
  74. data/app/views/decidim/budgets/admin/projects/bulk_actions/_dropdown.html.erb +8 -2
  75. data/app/views/decidim/budgets/admin/projects/bulk_actions/_recategorize.html.erb +3 -3
  76. data/app/views/decidim/budgets/admin/projects/bulk_actions/_scope-change.html.erb +5 -8
  77. data/app/views/decidim/budgets/admin/projects/edit.html.erb +16 -6
  78. data/app/views/decidim/budgets/admin/projects/index.html.erb +26 -31
  79. data/app/views/decidim/budgets/admin/projects/new.html.erb +16 -6
  80. data/app/views/decidim/budgets/admin/projects/update_attribute.js.erb +8 -4
  81. data/app/views/decidim/budgets/admin/proposals_imports/new.html.erb +40 -28
  82. data/app/views/decidim/budgets/budgets/index.html.erb +21 -3
  83. data/app/views/decidim/budgets/budgets/index.js.erb +6 -0
  84. data/app/views/decidim/budgets/line_items/update_budget.js.erb +21 -11
  85. data/app/views/decidim/budgets/projects/_addition_selector.html.erb +16 -0
  86. data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +42 -31
  87. data/app/views/decidim/budgets/projects/_budget_excess.html.erb +12 -12
  88. data/app/views/decidim/budgets/projects/_budget_summary.html.erb +2 -75
  89. data/app/views/decidim/budgets/projects/_exit_modal.html.erb +15 -18
  90. data/app/views/decidim/budgets/projects/_linked_projects.html.erb +3 -12
  91. data/app/views/decidim/budgets/projects/_order.html.erb +1 -0
  92. data/app/views/decidim/budgets/projects/_order_progress_progressbar_marks_right.html.erb +10 -0
  93. data/app/views/decidim/budgets/projects/_order_progress_summary_content.html.erb +113 -0
  94. data/app/views/decidim/budgets/projects/_order_total_budget.html.erb +6 -7
  95. data/app/views/decidim/budgets/projects/_project.html.erb +2 -1
  96. data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +11 -19
  97. data/app/views/decidim/budgets/projects/_projects.html.erb +8 -6
  98. data/app/views/decidim/budgets/projects/_projects_count.html.erb +5 -0
  99. data/app/views/decidim/budgets/projects/_projects_list.html.erb +3 -0
  100. data/app/views/decidim/budgets/projects/index.html.erb +58 -55
  101. data/app/views/decidim/budgets/projects/index.js.erb +5 -4
  102. data/app/views/decidim/budgets/projects/show.html.erb +78 -51
  103. data/config/assets.rb +0 -1
  104. data/config/locales/ar.yml +0 -50
  105. data/config/locales/bg.yml +0 -381
  106. data/config/locales/ca.yml +75 -84
  107. data/config/locales/cs.yml +73 -82
  108. data/config/locales/de.yml +76 -85
  109. data/config/locales/el.yml +34 -72
  110. data/config/locales/en.yml +79 -88
  111. data/config/locales/es-MX.yml +73 -82
  112. data/config/locales/es-PY.yml +73 -82
  113. data/config/locales/es.yml +75 -84
  114. data/config/locales/eu.yml +74 -86
  115. data/config/locales/fi-plain.yml +75 -84
  116. data/config/locales/fi.yml +79 -88
  117. data/config/locales/fr-CA.yml +74 -86
  118. data/config/locales/fr.yml +78 -90
  119. data/config/locales/ga-IE.yml +0 -12
  120. data/config/locales/gl.yml +0 -58
  121. data/config/locales/hu.yml +58 -81
  122. data/config/locales/id-ID.yml +0 -38
  123. data/config/locales/is-IS.yml +0 -22
  124. data/config/locales/it.yml +0 -84
  125. data/config/locales/ja.yml +69 -81
  126. data/config/locales/ko.yml +0 -54
  127. data/config/locales/lb.yml +0 -85
  128. data/config/locales/lt.yml +59 -82
  129. data/config/locales/lv.yml +0 -44
  130. data/config/locales/nl.yml +0 -96
  131. data/config/locales/no.yml +0 -84
  132. data/config/locales/pl.yml +0 -167
  133. data/config/locales/pt-BR.yml +9 -141
  134. data/config/locales/pt.yml +0 -85
  135. data/config/locales/ro-RO.yml +0 -95
  136. data/config/locales/ru.yml +0 -41
  137. data/config/locales/sk.yml +0 -44
  138. data/config/locales/sq-AL.yml +0 -52
  139. data/config/locales/sr-CS.yml +0 -4
  140. data/config/locales/sv.yml +42 -150
  141. data/config/locales/tr-TR.yml +2 -82
  142. data/config/locales/uk.yml +0 -41
  143. data/config/locales/zh-CN.yml +0 -65
  144. data/config/locales/zh-TW.yml +13 -59
  145. data/lib/decidim/budgets/admin_engine.rb +3 -2
  146. data/lib/decidim/budgets/component.rb +4 -90
  147. data/lib/decidim/budgets/engine.rb +30 -10
  148. data/lib/decidim/budgets/project_serializer.rb +3 -3
  149. data/lib/decidim/budgets/seeds.rb +69 -0
  150. data/lib/decidim/budgets/test/factories.rb +23 -37
  151. data/lib/decidim/budgets/version.rb +1 -1
  152. data/lib/decidim/budgets/workflows/base.rb +1 -1
  153. metadata +46 -42
  154. data/app/cells/decidim/budgets/budget_m/data.erb +0 -12
  155. data/app/cells/decidim/budgets/budget_m/footer.erb +0 -5
  156. data/app/cells/decidim/budgets/budget_m_cell.rb +0 -16
  157. data/app/cells/decidim/budgets/project_list_item/project_data.erb +0 -19
  158. data/app/cells/decidim/budgets/project_list_item/project_image.erb +0 -5
  159. data/app/cells/decidim/budgets/project_list_item/project_text.erb +0 -23
  160. data/app/cells/decidim/budgets/project_list_item/show.erb +0 -5
  161. data/app/cells/decidim/budgets/project_list_item_cell.rb +0 -70
  162. data/app/cells/decidim/budgets/project_m/data.erb +0 -12
  163. data/app/cells/decidim/budgets/project_m/footer.erb +0 -5
  164. data/app/cells/decidim/budgets/project_m_cell.rb +0 -22
  165. data/app/packs/stylesheets/decidim/budgets/_budgets.scss +0 -3
  166. data/app/packs/stylesheets/decidim/budgets/budget/_budget-list.scss +0 -198
  167. data/app/packs/stylesheets/decidim/budgets/budget/_budget-meter.scss +0 -83
  168. data/app/packs/stylesheets/decidim/budgets/budget/_progress.scss +0 -19
  169. data/app/views/decidim/budgets/admin/projects/proposals_picker.html.erb +0 -1
  170. data/app/views/decidim/budgets/projects/_filters.html.erb +0 -30
  171. data/app/views/decidim/budgets/projects/_filters_small_view.html.erb +0 -18
  172. data/app/views/decidim/budgets/projects/_order_progress.html.erb +0 -32
  173. data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +0 -27
  174. data/config/locales/he-IL.yml +0 -1
  175. data/decidim-budgets.gemspec +0 -34
  176. data/lib/decidim/budgets/seeds/city.jpeg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97a5590dd1ff0443a745a9da5bf8fa946a8f8f525834d168eef4424de48a5d26
4
- data.tar.gz: 42524da9525237fbc73e4a5eb0b3daead7ddd80032cb029f5c2695a4d361d20c
3
+ metadata.gz: 040e6569d57ec31a084de567cf3745c278b1e871b4b65c1f6c74193b25a5869a
4
+ data.tar.gz: 6fef0d93ae7c58c114c7f2ca7c04d266a870828055baf00be01640088d932012
5
5
  SHA512:
6
- metadata.gz: '020788c513d9936c7273100823f7c7043f9db48b1035618ace11477de2ecd9f37b8acd47d016385e8db66e2dd188c78306cd0bbac4f818a4e55e7d7f25436f8e'
7
- data.tar.gz: 35cefdc0f73f6fd9a01adcf8e533ce3a71da229a796e859577bb59467f8625733f1e4a95387890eb2a13f62590598c6d22852b50c9063c0f17c49ffe43f3be0e
6
+ metadata.gz: dbbc7b01a81c4c170850e8a2513b231eb3b5b66b6870af26776f0520810cd86cd63b8f1dc200f47d00d11101107ffed28870d09faae190b8365c37d1295c9d95
7
+ data.tar.gz: dc79f3ccf7dcd1a986ab3916370959459e61245ceff5f69c732bd5fba6060d8cfb1291a6d99ae3445107d02d442c7a7261a7b09ccf1b089f5653b68187098bbf
data/README.md CHANGED
@@ -30,7 +30,7 @@ bundle
30
30
 
31
31
  ## Budget Workflows
32
32
 
33
- A budget workflow, let's an admin pick, at the component level, how a user can participate in it.
33
+ A budget workflow, lets an admin pick, at the component level, how a user can participate in it.
34
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
35
 
36
36
  ### Adding a custom workflow
@@ -1,20 +1,20 @@
1
- .budget-vote-button.expanded{
1
+ .budget-vote-button.expanded {
2
2
  display: flex;
3
3
  text-align: left;
4
4
  justify-content: space-between;
5
5
  align-items: center;
6
6
 
7
- span{
7
+ span {
8
8
  font-size: 1rem;
9
9
  }
10
10
 
11
- &.added{
11
+ &.added {
12
12
  background-color: tint($success, 80%);
13
13
  color: $body-font-color;
14
14
  }
15
15
 
16
- &:not(.added){
17
- .budget-list__action{
16
+ &:not(.added) {
17
+ .budget-list__action {
18
18
  border-color: white;
19
19
  color: white;
20
20
  }
@@ -13,7 +13,7 @@ module Decidim
13
13
  delegate :settings, to: :current_component
14
14
 
15
15
  def budgets_link_list(budgets)
16
- budgets.map { |budget| link_to(decidim_escape_translated(budget.title), resource_locator(budget).path) }
16
+ budgets.map { |budget| link_to(translated_attribute(budget.title), resource_locator(budget).path) }
17
17
  .to_sentence
18
18
  .html_safe
19
19
  end
@@ -14,7 +14,12 @@ module Decidim
14
14
  private
15
15
 
16
16
  def card_size
17
- "decidim/budgets/budget_m"
17
+ case @options[:size]
18
+ when :s
19
+ "decidim/budgets/budget_s"
20
+ else
21
+ "decidim/budgets/budget_list_item"
22
+ end
18
23
  end
19
24
  end
20
25
  end
@@ -1,28 +1,16 @@
1
- <button class="link" data-open="budget-modal-info" aria-controls="budget-modal-info" aria-haspopup="dialog" tabindex="0">
2
- <%= t(:more_information, scope: i18n_scope) %>
3
- </button>
4
-
5
- <div class="reveal" data-reveal id="budget-modal-info" aria-modal="true" aria-labelledby="budget-modal-info-label">
6
- <div class="reveal__header">
7
- <h3 id="budget-modal-info-label" 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 %>
1
+ <%= decidim_modal id: "budget-modal-info" do %>
2
+ <div data-dialog-container>
3
+ <%= icon "information-line" %>
4
+ <h3 class="h3" id="dialog-title-budget-modal-info" tabindex="-1" data-dialog-title>
5
+ <%= decidim_sanitize(component_name) %>
6
+ </h3>
7
+ <p id="dialog-desc-budget-modal-info">
8
+ <%= content_tag(:p, more_information) if more_information %>
18
9
  </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
10
  </div>
28
- </div>
11
+ <div data-dialog-actions>
12
+ <button class="button button__sm md:button__lg button__secondary" data-dialog-close="budget-modal-info">
13
+ <%= t("continue", scope: "decidim.budgets.budget_information_modal") %>
14
+ </button>
15
+ </div>
16
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <div class="inline-block pr-4">
2
+ <%= icon "git-pull-request-line", class: "text-gray fill-current inline-block" , aria_label: t("activerecord.models.decidim/budgets/project", count: 1) %>
3
+ <span class="text-sm">
4
+ <%= t(:projects_count, scope: "decidim.budgets.projects.count", count: budget.projects.size) %>
5
+ </span>
6
+ </div>
@@ -1,38 +1,43 @@
1
- <div class="<%= card_class %> budget-list__item budget-list__item-cell">
2
- <div class="budget-list__text flex-horizontal">
3
- <%= link_to budget_path(budget), class: link_class do %>
4
- <h3 class="card--list__heading">
5
- <%= decidim_escape_translated(title) %>
1
+ <div class="<%= card_class %> card__highlight">
2
+ <div class="card__highlight-text md:w-[70%] p-0">
3
+ <%= link_to resource_path, class: "p-4" do %>
4
+ <h3 class="h3 text-secondary inline-block align-middle">
5
+ <%= translated_attribute(title) %>
6
6
  </h3>
7
+ <% if voted? %>
8
+ <%= icon "check-double-line", class: "inline-block align-middle fill-success ml-2 h-[1.5em] w-[1.5em]" %>
9
+ <% end %>
10
+ <div class="my-2">
11
+ <%= decidim_sanitize html_truncate(translated_attribute(description), length: 70) %>
12
+ </div>
13
+ <% unless voted? %>
14
+ <div class="divide-x-2 divide-gray-3">
15
+ <%= render :projects_count %>
16
+ <%= render :vote_action if voting_context? %>
17
+ </div>
18
+ <% end %>
19
+ <% end %>
20
+ <% if voted? %>
21
+ <div class="divide-x-2 divide-gray-3 p-4 pt-0">
22
+ <%= render :projects_count %>
23
+ <%= render :vote_action if voting_context? %>
24
+ </div>
7
25
  <% end %>
8
-
9
- <div class="heading5">
10
- <strong>
11
- <%= budget_to_currency(total_budget) %>
12
- </strong>
13
- </div>
14
-
15
- <%= decidim_sanitize html_truncate(translated_attribute(description), length: 140) %>
16
26
  </div>
17
-
18
- <% if !voting_finished? %>
19
- <div class="budget-list__icon mr-s">
20
- <% if voted? %>
21
- <span class="button tiny success card--list__check card--list__check--disabled card--list__check--inline">
22
- <%= icon "check", class: "icon--small", role: "img", aria_label: t("decidim.budgets.budget_list_item.voting_finished") %>
27
+ <% if voting_context? %>
28
+ <%= link_to resource_path, class: "budget__card__highlight-vote" do %>
29
+ <div class="budget__card__highlight-vote__header">
30
+ <span class="budget__card__highlight-vote__text">
31
+ <%= t("name", scope: "decidim.budgets.admin.models.budget") %>
23
32
  </span>
24
- <% elsif progress? %>
25
- <span class="button tiny warning card--list__check card--list__check--disabled card--list__check--inline">
26
- <%= icon "bookmark", class: "icon--small", role: "img", aria_label: t("decidim.budgets.budget_list_item.voting_started") %>
33
+ <span class="budget__card__highlight-vote__number">
34
+ <%= budget_to_currency(total_budget) %>
27
35
  </span>
36
+ </div>
37
+ <%= button_tag class: "button button__sm #{button_class} #{voted? ? "button__transparent-secondary" : "button__secondary"} budget__card__highlight-vote__button" do %>
38
+ <span><%= button_text %></span>
39
+ <%= icon "arrow-right-line" %>
28
40
  <% end %>
29
- </div>
30
- <% end %>
31
-
32
- <div class="budget-list__data">
33
- <%= link_to budget_path(budget), class: "button button--sc expanded #{button_class} mb-none" do %>
34
- <span><%= button_text %></span>
35
- <%= icon "chevron-right", class: "icon--small", role: "img" %>
36
41
  <% end %>
37
- </div>
42
+ <% end %>
38
43
  </div>
@@ -0,0 +1,13 @@
1
+ <% if voted? %>
2
+ <%= link_to(
3
+ budget_order_path(budget),
4
+ method: :delete,
5
+ class: "pl-4",
6
+ data: { confirm: t(:are_you_sure, scope: "decidim.budgets.projects.budget_summary") }
7
+ ) do %>
8
+ <%= icon "delete-bin-line", class: "inline-block align-middle text-gray fill-current" %>
9
+ <span class="inline-block align-middle underline text-alert">
10
+ <%= t("cancel_order", scope: "decidim.budgets.projects.budget_summary") %>
11
+ </span>
12
+ <% end %>
13
+ <% end %>
@@ -9,7 +9,6 @@ module Decidim
9
9
  include ActiveSupport::NumberHelper
10
10
  include Decidim::Budgets::ProjectsHelper
11
11
 
12
- delegate :voting_finished?, to: :controller
13
12
  delegate :highlighted, to: :current_workflow
14
13
 
15
14
  property :title, :description, :total_budget
@@ -64,6 +63,30 @@ module Decidim
64
63
  def i18n_scope
65
64
  "decidim.budgets.budgets_list"
66
65
  end
66
+
67
+ def resource_path
68
+ resource_locator(budget).path
69
+ end
70
+
71
+ def current_workflow
72
+ @current_workflow ||=
73
+ controller.try(:current_workflow) ||
74
+ Decidim::Budgets.workflows[component.settings.workflow.to_sym].new(component, current_user)
75
+ end
76
+
77
+ def component
78
+ @component ||= controller.try(:current_component) || budget.component
79
+ end
80
+
81
+ def voting_context?
82
+ controller.respond_to?(:voting_finished?)
83
+ end
84
+
85
+ def voting_finished?
86
+ return unless voting_context?
87
+
88
+ controller.voting_finished?
89
+ end
67
90
  end
68
91
  end
69
92
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders metadata for an instance of a budget
6
+ class BudgetMetadataCell < Decidim::CardMetadataCell
7
+ alias budget model
8
+
9
+ def initialize(*)
10
+ super
11
+
12
+ @items.prepend(*budget_items)
13
+ end
14
+
15
+ private
16
+
17
+ def budget_items
18
+ [project_count]
19
+ end
20
+
21
+ def project_count
22
+ {
23
+ text: t(:projects_count, scope: "decidim.budgets.projects.count", count: budget.projects.size),
24
+ icon: "git-pull-request-line"
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Budgets
5
+ # This cell renders the Search (:s) budget card
6
+ # for a given instance of a Budget
7
+ class BudgetSCell < Decidim::CardSCell
8
+ private
9
+
10
+ def metadata_cell
11
+ "decidim/budgets/budget_metadata"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,3 @@
1
- <div class="row">
2
- <div class="columns medium-7 mediumlarge-8">
3
- <div class="section">
4
- <%= decidim_sanitize_editor_admin(landing_page_content) %>
5
- </div>
6
- </div>
1
+ <div class="editor-content">
2
+ <%= decidim_sanitize_editor_admin(landing_page_content) %>
7
3
  </div>
@@ -1,18 +1,13 @@
1
- <%# show highlighted budgets first %>
2
1
  <% if highlighted.any? %>
3
- <div id="highlighted-budgets" class="card card--list budget-list">
4
- <% highlighted.each do |budget| %>
5
- <%= cell("decidim/budgets/budget_list_item", budget) %>
6
- <% end %>
7
- </div>
2
+ <% reordered_highlighted_budgets.each do |budget| %>
3
+ <%= cell("decidim/budgets/budget_list_item", budget) %>
4
+ <% end %>
8
5
  <% end %>
9
6
 
10
- <% non_highlighted = (budgets - highlighted - voted) %>
7
+ <% non_highlighted = reorder(budgets).where.not(id: (highlighted + voted).map(&:id)) %>
11
8
 
12
- <% if non_highlighted.any? %>
13
- <div id="budgets" class="card card--list budget-list">
14
- <% non_highlighted.each do |budget| %>
15
- <%= cell("decidim/budgets/budget_list_item", budget) %>
16
- <% end %>
17
- </div>
9
+ <% if non_highlighted.exists? %>
10
+ <% non_highlighted.each do |budget| %>
11
+ <%= cell("decidim/budgets/budget_list_item", budget) %>
12
+ <% end %>
18
13
  <% end %>
@@ -0,0 +1,5 @@
1
+ <h2 class="h5 md:h3 decorator"><%= t(:count, scope: i18n_scope, count: budgets.length) %></h2>
2
+
3
+ <%= render partial: "decidim/shared/orders", formats: [:html], locals: { orders: AVAILABLE_ORDERS, i18n_scope: "decidim.budgets.projects.orders" } %>
4
+
5
+ <%= render :card_list %>
@@ -1,19 +1,15 @@
1
- <div class="row">
2
- <div class="columns medium-7 mediumlarge-8">
3
- <% if !voting_finished? && (voted?) %>
4
- <div class="section">
5
- <h2 class="section-heading">
6
- <%= t(:my_budgets, scope: i18n_scope) %>
7
- </h2>
1
+ <% if !voting_finished? && voted? %>
2
+ <h2 class="h5 md:h3 decorator mb-8">
3
+ <%= t("voted_budgets", scope: "decidim.budgets.budgets_list") %>
4
+ </h2>
8
5
 
9
- <%= render :voted %>
10
- </div>
11
- <% end %>
6
+ <%= render :voted %>
7
+ <% end %>
12
8
 
13
- <div class="row">
14
- <div class="columns mediumlarge-12">
15
- <%= render :card_list %>
16
- </div>
17
- </div>
9
+ <% if budgets.where.not(id: voted.map(&:id)).exists? %>
10
+ <div id="budgets" class="card__list-list">
11
+ <%= main_list %>
18
12
  </div>
19
- </div>
13
+ <% end %>
14
+
15
+ <%= decidim_paginate budget_paginate %>
@@ -1,49 +1,13 @@
1
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>
2
+ <p><%= t(:voted_on, scope: i18n_scope, links: budgets_link_list(voted)) %></p>
6
3
 
7
- <div id="voted-budgets-list" class="card card--list budget-list">
8
- <% voted.each do |budget| %>
9
- <%= cell("decidim/budgets/budget_list_item", budget) %>
10
- <% end %>
11
- </div>
12
-
13
- <% if finished? %>
14
- <p class="lead">
15
- <%= t(:finished_message, scope: i18n_scope) %>
16
- </p>
17
- <% end %>
18
-
19
- <% if voting_open? %>
20
- <div>
21
- <p>
22
- <%= t(:if_change_opinion, scope: i18n_scope) %>
23
- <%= link_to(
24
- t("cancel_order.only_one", scope: i18n_scope),
25
- budget_order_path(voted.first),
26
- method: :delete,
27
- data: { confirm: t("projects.budget_summary.are_you_sure", scope: "decidim.budgets") }) if voted.one? %>
28
- </p>
29
-
30
- <% if !voted.one? && voted.any? %>
31
- <ul>
32
- <% voted.each do |budget| %>
33
- <li>
34
- <%= link_to(
35
- t("cancel_order.more_than_one", scope: i18n_scope, name: decidim_escape_translated(budget.title)),
36
- budget_order_path(budget),
37
- method: :delete,
38
- class: "cancel-order",
39
- data: {
40
- confirm: t("projects.budget_summary.are_you_sure", scope: "decidim.budgets")
41
- }) %>
42
- </li>
43
- <% end %>
44
- </ul>
45
- <% end %>
46
- </div>
4
+ <div id="voted-budgets" class="card__list-list">
5
+ <% voted.each do |budget| %>
6
+ <%= cell("decidim/budgets/budget_list_item", budget) %>
47
7
  <% end %>
48
8
  </div>
9
+
10
+ <% if finished? %>
11
+ <p><%= t(:finished_message, scope: i18n_scope) %></p>
12
+ <% end %>
49
13
  <% end %>
@@ -4,6 +4,13 @@ module Decidim
4
4
  module Budgets
5
5
  # This cell renders the budgets list of a Budget component
6
6
  class BudgetsListCell < BaseCell
7
+ AVAILABLE_ORDERS = %w(random highest_cost lowest_cost).freeze
8
+
9
+ include Decidim::CellsPaginateHelper
10
+ include Decidim::OrdersHelper
11
+ include Decidim::Orderable
12
+ include Cell::ViewModel::Partial
13
+
7
14
  alias current_workflow model
8
15
 
9
16
  delegate :allowed, :budgets, :highlighted, :voted, to: :current_workflow
@@ -15,6 +22,8 @@ module Decidim
15
22
  render
16
23
  end
17
24
 
25
+ def main_list = render
26
+
18
27
  private
19
28
 
20
29
  def highlighted?
@@ -34,6 +43,31 @@ module Decidim
34
43
  def i18n_scope
35
44
  "decidim.budgets.budgets_list"
36
45
  end
46
+
47
+ def budget_paginate
48
+ @budget_paginate ||= Kaminari.paginate_array(budgets).page(params[:page]).per(10)
49
+ end
50
+
51
+ def reordered_highlighted_budgets
52
+ return highlighted if highlighted.length < 2
53
+
54
+ reorder(budgets.where(id: highlighted.map(&:id)))
55
+ end
56
+
57
+ def reorder(budgets)
58
+ case order
59
+ when "highest_cost"
60
+ budgets.order(total_budget: :desc)
61
+ when "lowest_cost"
62
+ budgets.order(total_budget: :asc)
63
+ when "random"
64
+ budgets.order_randomly(random_seed)
65
+ else
66
+ budgets
67
+ end
68
+ end
69
+
70
+ def available_orders = AVAILABLE_ORDERS
37
71
  end
38
72
  end
39
73
  end
@@ -0,0 +1,3 @@
1
+ <section class="layout-main__section">
2
+ <%= cell("decidim/announcement", announcement_message, callout_class: "warning") %>
3
+ </section>
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Decidim
4
4
  module Budgets
5
- # This cell renders information when current user can't create more budgets orders.
5
+ # This cell renders information when current user cannot create more budgets orders.
6
6
  class LimitAnnouncementCell < BaseCell
7
7
  alias budget model
8
8
  delegate :voted?, :vote_allowed?, :discardable, :limit_reached?, to: :current_workflow
9
9
  delegate :voting_open?, to: :controller
10
10
 
11
11
  def show
12
- cell("decidim/announcement", announcement_message, callout_class: "warning") if announce?
12
+ render if announce?
13
13
  end
14
14
 
15
15
  private
@@ -5,10 +5,7 @@ module Decidim
5
5
  # A cell to display when actions happen on an order.
6
6
  class OrderActivityCell < ActivityCell
7
7
  def title
8
- I18n.t(
9
- "decidim.budgets.last_activity.new_vote_at_html",
10
- link: participatory_space_link
11
- )
8
+ I18n.t("decidim.budgets.last_activity.new_vote_at")
12
9
  end
13
10
 
14
11
  def resource_link_path
@@ -14,7 +14,12 @@ module Decidim
14
14
  private
15
15
 
16
16
  def card_size
17
- "decidim/budgets/project_m"
17
+ case @options[:size]
18
+ when :s
19
+ "decidim/budgets/project_s"
20
+ else
21
+ "decidim/budgets/project_l"
22
+ end
18
23
  end
19
24
  end
20
25
  end
@@ -0,0 +1,6 @@
1
+ <div class="budget__card__list-project">
2
+ <span class="budget__card__list-project__amount">
3
+ <%= budget_to_currency(project.budget_amount) %>
4
+ </span>
5
+ <%= cell("decidim/budgets/project_vote_button", project, show_only_added:) %>
6
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="card__list-metadata">
2
+ <%= cell metadata_cell, project %>
3
+ </div>
4
+ <%= cell("decidim/budgets/project_voted_hint", project, class: "margin-left-1") if current_order_checked_out? && resource_added? %>
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Budgets
7
+ # This cell renders the List (:l) project card
8
+ # for an instance of a Project
9
+ class ProjectLCell < Decidim::CardLCell
10
+ include ActiveSupport::NumberHelper
11
+ include Decidim::Budgets::ProjectsHelper
12
+
13
+ alias project model
14
+
15
+ private
16
+
17
+ def resource_path
18
+ resource_locator([project.budget, project]).path(url_extra_params)
19
+ end
20
+
21
+ def resource_added?
22
+ current_order && current_order.projects.include?(model)
23
+ end
24
+
25
+ def current_order
26
+ @current_order ||= controller.try(:current_order)
27
+ end
28
+
29
+ def show_only_added
30
+ options[:show_only_added]
31
+ end
32
+
33
+ def resource_id = "project-#{project.id}-item"
34
+
35
+ def metadata_cell = "decidim/budgets/project_metadata"
36
+ end
37
+ end
38
+ end