decidim-budgets 0.20.1 → 0.23.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -3
  3. data/app/assets/images/decidim/budgets/icon.svg +1 -11
  4. data/app/assets/javascripts/decidim/budgets/projects.js.es6 +26 -4
  5. data/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +152 -24
  6. data/app/cells/decidim/budgets/base_cell.rb +22 -0
  7. data/app/cells/decidim/budgets/budget_cell.rb +21 -0
  8. data/app/cells/decidim/budgets/budget_information_modal/show.erb +28 -0
  9. data/app/cells/decidim/budgets/budget_information_modal_cell.rb +22 -0
  10. data/app/cells/decidim/budgets/budget_list_item/show.erb +22 -0
  11. data/app/cells/decidim/budgets/budget_list_item_cell.rb +40 -0
  12. data/app/cells/decidim/budgets/budget_m/data.erb +12 -0
  13. data/app/cells/decidim/budgets/budget_m/footer.erb +5 -0
  14. data/app/cells/decidim/budgets/budget_m_cell.rb +16 -0
  15. data/app/cells/decidim/budgets/budgets_header/show.erb +7 -0
  16. data/app/cells/decidim/budgets/budgets_header_cell.rb +14 -0
  17. data/app/cells/decidim/budgets/budgets_list/card_list.erb +7 -0
  18. data/app/cells/decidim/budgets/budgets_list/highlighted.erb +11 -0
  19. data/app/cells/decidim/budgets/budgets_list/show.erb +20 -0
  20. data/app/cells/decidim/budgets/budgets_list/voted.erb +43 -0
  21. data/app/cells/decidim/budgets/budgets_list_cell.rb +39 -0
  22. data/app/cells/decidim/budgets/limit_announcement_cell.rb +52 -0
  23. data/app/cells/decidim/budgets/project_list_item/project_data.erb +19 -0
  24. data/app/cells/decidim/budgets/project_list_item/project_data_vote_button.erb +15 -0
  25. data/app/cells/decidim/budgets/project_list_item/project_image.erb +5 -0
  26. data/app/cells/decidim/budgets/project_list_item/project_text.erb +23 -0
  27. data/app/cells/decidim/budgets/project_list_item/show.erb +5 -0
  28. data/app/cells/decidim/budgets/project_list_item_cell.rb +66 -0
  29. data/app/cells/decidim/budgets/project_m/data.erb +3 -3
  30. data/app/cells/decidim/budgets/project_m/footer.erb +1 -1
  31. data/app/cells/decidim/budgets/project_m_cell.rb +4 -0
  32. data/app/cells/decidim/budgets/project_selected_status_cell.rb +28 -0
  33. data/app/cells/decidim/budgets/project_tags/show.erb +5 -0
  34. data/app/cells/decidim/budgets/project_tags_cell.rb +18 -0
  35. data/app/cells/decidim/budgets/project_voted_hint_cell.rb +33 -0
  36. data/app/cells/decidim/budgets/project_votes_count_cell.rb +44 -0
  37. data/app/commands/decidim/budgets/add_line_item.rb +7 -10
  38. data/app/commands/decidim/budgets/admin/create_budget.rb +48 -0
  39. data/app/commands/decidim/budgets/admin/create_project.rb +26 -11
  40. data/app/commands/decidim/budgets/admin/destroy_budget.rb +42 -0
  41. data/app/commands/decidim/budgets/admin/import_proposals_to_budgets.rb +26 -25
  42. data/app/commands/decidim/budgets/admin/update_budget.rb +48 -0
  43. data/app/commands/decidim/budgets/admin/update_project.rb +20 -2
  44. data/app/commands/decidim/budgets/checkout.rb +7 -6
  45. data/app/commands/decidim/budgets/remove_line_item.rb +3 -2
  46. data/app/controllers/concerns/decidim/budgets/needs_current_order.rb +18 -2
  47. data/app/controllers/concerns/decidim/budgets/orderable.rb +57 -0
  48. data/app/controllers/decidim/budgets/admin/application_controller.rb +10 -2
  49. data/app/controllers/decidim/budgets/admin/attachment_collections_controller.rb +1 -1
  50. data/app/controllers/decidim/budgets/admin/attachments_controller.rb +2 -2
  51. data/app/controllers/decidim/budgets/admin/budgets_controller.rb +82 -0
  52. data/app/controllers/decidim/budgets/admin/projects_controller.rb +15 -12
  53. data/app/controllers/decidim/budgets/admin/proposals_imports_controller.rb +10 -2
  54. data/app/controllers/decidim/budgets/application_controller.rb +23 -0
  55. data/app/controllers/decidim/budgets/budgets_controller.rb +24 -0
  56. data/app/controllers/decidim/budgets/line_items_controller.rb +10 -6
  57. data/app/controllers/decidim/budgets/orders_controller.rb +20 -6
  58. data/app/controllers/decidim/budgets/projects_controller.rb +28 -7
  59. data/app/forms/decidim/budgets/admin/budget_form.rb +39 -0
  60. data/app/forms/decidim/budgets/admin/component_form.rb +44 -0
  61. data/app/forms/decidim/budgets/admin/project_form.rb +25 -9
  62. data/app/forms/decidim/budgets/admin/project_import_proposals_form.rb +4 -0
  63. data/app/helpers/decidim/budgets/admin/application_helper.rb +13 -0
  64. data/app/helpers/decidim/budgets/application_helper.rb +11 -0
  65. data/app/helpers/decidim/budgets/projects_helper.rb +13 -0
  66. data/app/jobs/decidim/budgets/send_order_summary_job.rb +15 -0
  67. data/app/mailers/decidim/budgets/order_summary_mailer.rb +36 -0
  68. data/app/models/decidim/budgets/budget.rb +34 -0
  69. data/app/models/decidim/budgets/line_item.rb +4 -4
  70. data/app/models/decidim/budgets/order.rb +46 -16
  71. data/app/models/decidim/budgets/project.rb +37 -4
  72. data/app/permissions/decidim/budgets/admin/permissions.rb +23 -10
  73. data/app/permissions/decidim/budgets/permissions.rb +28 -6
  74. data/app/presenters/decidim/budgets/admin_log/budget_presenter.rb +42 -0
  75. data/app/queries/decidim/budgets/filtered_projects.rb +9 -1
  76. data/app/queries/decidim/budgets/metrics/budget_followers_metric_measure.rb +3 -2
  77. data/app/queries/decidim/budgets/metrics/budget_participants_metric_measure.rb +6 -5
  78. data/app/serializers/decidim/budgets/data_portability_budgets_order_serializer.rb +3 -2
  79. data/app/services/decidim/budgets/project_search.rb +13 -17
  80. data/app/types/decidim/budgets/budget_type.rb +24 -0
  81. data/app/types/decidim/budgets/budgets_type.rb +32 -0
  82. data/app/types/decidim/budgets/project_type.rb +26 -0
  83. data/app/views/decidim/budgets/admin/budgets/_form.html.erb +23 -0
  84. data/app/views/decidim/budgets/admin/budgets/edit.html.erb +7 -0
  85. data/app/views/decidim/budgets/admin/budgets/index.html.erb +58 -0
  86. data/app/views/decidim/budgets/admin/budgets/new.html.erb +7 -0
  87. data/app/views/decidim/budgets/admin/projects/_form.html.erb +15 -10
  88. data/app/views/decidim/budgets/admin/projects/edit.html.erb +2 -2
  89. data/app/views/decidim/budgets/admin/projects/index.html.erb +20 -7
  90. data/app/views/decidim/budgets/admin/projects/new.html.erb +2 -2
  91. data/app/views/decidim/budgets/admin/projects/proposals_picker.html.erb +1 -0
  92. data/app/views/decidim/budgets/admin/proposals_imports/new.html.erb +1 -1
  93. data/app/views/decidim/budgets/budgets/index.html.erb +5 -0
  94. data/app/views/decidim/budgets/order_summary_mailer/order_summary.html.erb +22 -0
  95. data/app/views/decidim/budgets/projects/_budget_confirm.html.erb +3 -3
  96. data/app/views/decidim/budgets/projects/_budget_summary.html.erb +26 -7
  97. data/app/views/decidim/budgets/projects/_filters.html.erb +15 -7
  98. data/app/views/decidim/budgets/projects/_linked_projects.html.erb +2 -2
  99. data/app/views/decidim/budgets/projects/_order_progress.html.erb +14 -18
  100. data/app/views/decidim/budgets/projects/_order_selected_projects.html.erb +3 -3
  101. data/app/views/decidim/budgets/projects/_project.html.erb +1 -57
  102. data/app/views/decidim/budgets/projects/_project_budget_button.html.erb +36 -7
  103. data/app/views/decidim/budgets/projects/_projects.html.erb +8 -1
  104. data/app/views/decidim/budgets/projects/index.html.erb +15 -7
  105. data/app/views/decidim/budgets/projects/index.js.erb +8 -0
  106. data/app/views/decidim/budgets/projects/show.html.erb +18 -11
  107. data/config/locales/am-ET.yml +1 -0
  108. data/config/locales/ar.yml +3 -17
  109. data/config/locales/bg-BG.yml +7 -0
  110. data/config/locales/bg.yml +6 -0
  111. data/config/locales/ca.yml +126 -12
  112. data/config/locales/cs.yml +145 -31
  113. data/config/locales/da-DK.yml +1 -0
  114. data/config/locales/da.yml +1 -0
  115. data/config/locales/de.yml +115 -12
  116. data/config/locales/el.yml +169 -0
  117. data/config/locales/en.yml +126 -12
  118. data/config/locales/eo.yml +1 -0
  119. data/config/locales/es-MX.yml +126 -12
  120. data/config/locales/es-PY.yml +126 -12
  121. data/config/locales/es.yml +126 -12
  122. data/config/locales/et-EE.yml +1 -0
  123. data/config/locales/et.yml +1 -0
  124. data/config/locales/eu.yml +4 -14
  125. data/config/locales/fi-plain.yml +127 -13
  126. data/config/locales/fi.yml +137 -23
  127. data/config/locales/fr-CA.yml +266 -0
  128. data/config/locales/fr.yml +125 -12
  129. data/config/locales/ga-IE.yml +1 -0
  130. data/config/locales/gl.yml +3 -13
  131. data/config/locales/hr-HR.yml +1 -0
  132. data/config/locales/hr.yml +1 -0
  133. data/config/locales/hu.yml +19 -13
  134. data/config/locales/id-ID.yml +3 -12
  135. data/config/locales/is-IS.yml +1 -12
  136. data/config/locales/is.yml +114 -0
  137. data/config/locales/it.yml +97 -13
  138. data/config/locales/ja-JP.yml +172 -0
  139. data/config/locales/ja.yml +262 -0
  140. data/config/locales/ko-KR.yml +1 -0
  141. data/config/locales/ko.yml +1 -0
  142. data/config/locales/lt-LT.yml +1 -0
  143. data/config/locales/lt.yml +1 -0
  144. data/config/locales/lv.yml +164 -0
  145. data/config/locales/mt-MT.yml +1 -0
  146. data/config/locales/mt.yml +1 -0
  147. data/config/locales/nl.yml +113 -13
  148. data/config/locales/no.yml +39 -13
  149. data/config/locales/om-ET.yml +1 -0
  150. data/config/locales/pl.yml +175 -62
  151. data/config/locales/pt-BR.yml +4 -14
  152. data/config/locales/pt.yml +63 -47
  153. data/config/locales/ro-RO.yml +172 -0
  154. data/config/locales/ru.yml +3 -15
  155. data/config/locales/sk-SK.yml +180 -0
  156. data/config/locales/sk.yml +166 -0
  157. data/config/locales/sl.yml +1 -0
  158. data/config/locales/so-SO.yml +1 -0
  159. data/config/locales/sr-CS.yml +27 -0
  160. data/config/locales/sv.yml +126 -12
  161. data/config/locales/ti-ER.yml +1 -0
  162. data/config/locales/tr-TR.yml +3 -13
  163. data/config/locales/uk.yml +3 -15
  164. data/config/locales/vi-VN.yml +1 -0
  165. data/config/locales/vi.yml +1 -0
  166. data/config/locales/zh-CN.yml +260 -0
  167. data/config/locales/zh-TW.yml +1 -0
  168. data/db/migrate/20200617105120_create_decidim_budgets.rb +15 -0
  169. data/db/migrate/20200629072626_rename_budget_to_budget_ammount.rb +7 -0
  170. data/db/migrate/20200629134013_add_budget_reference_to_project.rb +7 -0
  171. data/db/migrate/20200706142609_add_budget_reference_to_order.rb +7 -0
  172. data/db/migrate/20200714103519_move_budgets_to_own_model.rb +109 -0
  173. data/db/migrate/20200717140012_add_scope_to_budgets.rb +7 -0
  174. data/db/migrate/20200728075039_add_selected_at_to_project.rb +7 -0
  175. data/db/migrate/20200804175222_votes_enabled_to_votes_choices.rb +35 -0
  176. data/db/migrate/20200827154129_add_commentable_counter_cache_to_projects.rb +9 -0
  177. data/lib/decidim/budgets.rb +1 -0
  178. data/lib/decidim/budgets/admin_engine.rb +12 -5
  179. data/lib/decidim/budgets/component.rb +94 -38
  180. data/lib/decidim/budgets/engine.rb +8 -6
  181. data/lib/decidim/budgets/seeds/city.jpeg +0 -0
  182. data/lib/decidim/budgets/test/factories.rb +71 -9
  183. data/lib/decidim/budgets/version.rb +1 -1
  184. data/lib/decidim/budgets/workflows.rb +17 -0
  185. data/lib/decidim/budgets/workflows/all.rb +20 -0
  186. data/lib/decidim/budgets/workflows/base.rb +132 -0
  187. data/lib/decidim/budgets/workflows/one.rb +33 -0
  188. metadata +121 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e9ce6f985c07de9ead8fe7abd959d3942245bdacf65a7fdd657c209be76c1c1
4
- data.tar.gz: 9cdbba896b3130d27226c34a7939bea4b4ee6edb4576623b28e44e609b35cede
3
+ metadata.gz: 8d8202bc5b020026971f5e5aed7654f2b01492ad20f027fd31dc829301fc5cc8
4
+ data.tar.gz: 7e2694e4acf2474d34f8104ff546718e34e08eb967f645fa936fa3d04662a1bf
5
5
  SHA512:
6
- metadata.gz: dd11bcea8e6b62bbf93e632b573bfb4de4225fc6e0395b101d8794af6bdd0284e58e1a539b74bd1c61b3fba11e0f4dc120f0571185f5c1f7ced50507d949b229
7
- data.tar.gz: 96af9c618b53fd5d58110dd5af0a0738cb43d382fb51eaef54d961f7c9b8da5bdf3ab62b1c9ba1463211d9813af01a9a45f8b3e02b853e0a72c152059cb446e6
6
+ metadata.gz: 6cac8af76f499fd4aab8aa50b3e9d0b5290210503bb5ba0991f9f010cdacfd2165e5fd8de26f46e9cc268df0d6dccc0597e250128145d0f8b83efeb6f32b9f0e
7
+ data.tar.gz: fad58039edad5afc0c28ff1ef16c3cfa35651d241952a5c6eac87c174c0ce6c4fcac8a491bf2d2d920d76a1f295dea9bd57964bcab612e80d3b50eac99c37645
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).
@@ -1,11 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 36 36" style="enable-background:new 0 0 36 36;" xml:space="preserve">
2
- <g>
3
- <path d="M18,36C8.1,36,0,27.9,0,18S8.1,0,18,0s18,8.1,18,18S27.9,36,18,36z M18,2C9.2,2,2,9.2,2,18s7.2,16,16,16s16-7.2,16-16 S26.8,2,18,2z"/>
4
- </g>
5
- <g>
6
- <g>
7
- <path d="M17.1,28.3c-5.3,0-9.9-4.4-9.9-9.8c0-5.5,4.9-9.5,9.3-9.5H18v9h9v0.9C27,23.2,22.7,28.3,17.1,28.3z M16,10.7 c-4,0.6-6.5,3.7-6.5,7.6c0,4.3,3.6,8,7.7,8c3.9,0,7-3.3,7.6-6.3H16V10.7z"/>
8
- </g>
9
- <path d="M30,16H20V6h0.6c4.5,0,9.4,4.4,9.4,8.9V16z M22,14h5.5C27,11,24,8.6,22,8V14z"/>
10
- </g>
11
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" x="0" y="0" enable-background="new 0 0 36 36" viewBox="0 0 36 36" xml:space="preserve"><g><path d="M18,36C8.1,36,0,27.9,0,18S8.1,0,18,0s18,8.1,18,18S27.9,36,18,36z M18,2C9.2,2,2,9.2,2,18s7.2,16,16,16s16-7.2,16-16 S26.8,2,18,2z"/></g><g><g><path d="M17.1,28.3c-5.3,0-9.9-4.4-9.9-9.8c0-5.5,4.9-9.5,9.3-9.5H18v9h9v0.9C27,23.2,22.7,28.3,17.1,28.3z M16,10.7 c-4,0.6-6.5,3.7-6.5,7.6c0,4.3,3.6,8,7.7,8c3.9,0,7-3.3,7.6-6.3H16V10.7z"/></g><path d="M30,16H20V6h0.6c4.5,0,9.4,4.4,9.4,8.9V16z M22,14h5.5C27,11,24,8.6,22,8V14z"/></g></svg>
@@ -5,7 +5,7 @@ $(() => {
5
5
  const $projects = $("#projects, #project");
6
6
  const $budgetSummaryTotal = $(".budget-summary__total");
7
7
  const $budgetExceedModal = $("#budget-excess");
8
-
8
+ const $budgetSummary = $(".budget-summary__progressbox");
9
9
  const totalBudget = parseInt($budgetSummaryTotal.attr("data-total-budget"), 10);
10
10
 
11
11
  const cancelEvent = (event) => {
@@ -13,17 +13,39 @@ $(() => {
13
13
  event.preventDefault();
14
14
  };
15
15
 
16
- $projects.on("click", ".budget--list__action", (event) => {
17
- const currentBudget = parseInt($(".budget-summary__progressbox").attr("data-current-budget"), 10);
16
+ $projects.on("click", ".budget-list__action", (event) => {
17
+ const currentBudget = parseInt($budgetSummary.attr("data-current-budget"), 10);
18
18
  const $currentTarget = $(event.currentTarget);
19
19
  const projectBudget = parseInt($currentTarget.attr("data-budget"), 10);
20
20
 
21
21
  if ($currentTarget.attr("disabled")) {
22
22
  cancelEvent(event);
23
23
 
24
- } else if ($currentTarget.attr("data-add") && ((currentBudget + projectBudget) > totalBudget)) {
24
+ } else if (($currentTarget.attr("data-add") === "true") && ((currentBudget + projectBudget) > totalBudget)) {
25
25
  $budgetExceedModal.foundation("toggle");
26
26
  cancelEvent(event);
27
27
  }
28
28
  });
29
+
30
+ if ($("#order-progress [data-toggle=budget-confirm]").length > 0) {
31
+ const safeUrl = $(".budget-summary").attr("data-safe-url").split("?")[0];
32
+ $(document).on("click", "a", (event) => {
33
+ window.exitUrl = event.currentTarget.href;
34
+ });
35
+ $(document).on("submit", "form", (event) => {
36
+ window.exitUrl = event.currentTarget.action;
37
+ });
38
+
39
+ window.onbeforeunload = () => {
40
+ const currentBudget = parseInt($budgetSummary.attr("data-current-budget"), 10);
41
+ const exitUrl = window.exitUrl;
42
+ window.exitUrl = null;
43
+
44
+ if (currentBudget === 0 || (exitUrl && exitUrl.startsWith(safeUrl))) {
45
+ return null;
46
+ }
47
+
48
+ return "";
49
+ }
50
+ }
29
51
  });
@@ -1,36 +1,164 @@
1
- .budget-list__title{
2
- @include breakpoint(smallmedium down){
3
- font-size: $global-font-size;
4
- }
5
- }
1
+ .budget-list{
2
+ margin-bottom: 2rem;
6
3
 
7
- .budget-list__data{
8
- flex-basis: 9rem;
4
+ &__item{
5
+ padding: 0;
6
+ background: $card-bg;
7
+ border: $border;
8
+ border-bottom: 0;
9
+ overflow: hidden;
10
+ display: flex;
9
11
 
10
- @include breakpoint(medium){
11
- flex-direction: row;
12
- flex-basis: 16rem;
12
+ &:first-child{
13
+ border-top-left-radius: $card-border-radius;
14
+ border-top-right-radius: $card-border-radius;
15
+ }
16
+
17
+ &:last-child{
18
+ border-bottom-left-radius: $card-border-radius;
19
+ border-bottom-right-radius: $card-border-radius;
20
+ border-bottom: $border;
21
+ }
13
22
  }
14
- }
15
23
 
16
- .budget-list__data--added{
17
- background-color: tint($success, 80%);
18
- }
24
+ &__image{
25
+ overflow: hidden;
26
+ width: 3.5em;
27
+ height: 3.5rem;
28
+ flex-shrink: 0;
29
+ margin-top: $card-padding-small * .7;
30
+ margin-bottom: $card-padding-small * .7;
31
+ margin-left: $card-padding-small / 2;
32
+
33
+ @include breakpoint(medium){
34
+ width: 6rem;
35
+ height: 4rem;
36
+ flex-shrink: 0;
37
+ margin: $card-padding;
38
+ margin-right: 0;
39
+ }
19
40
 
20
- .budget-list__number{
21
- @include breakpoint(medium down){
22
- font-size: 1rem;
41
+ img{
42
+ width: 100%;
43
+ height: 100%;
44
+ object-fit: cover;
45
+ object-position: center;
46
+ }
23
47
  }
24
48
 
25
- @include breakpoint(medium){
49
+ &__text{
50
+ padding: $card-padding-small / 2;
26
51
  flex-grow: 1;
52
+
53
+ @include breakpoint(medium){
54
+ padding: $card-padding;
55
+ display: flex;
56
+ align-items: center;
57
+ }
58
+
59
+ .card__text--status{
60
+ display: block;
61
+ }
62
+ }
63
+
64
+ &__data{
65
+ flex-shrink: 0;
66
+ align-self: stretch;
67
+ display: flex;
68
+ flex-direction: column;
69
+ align-items: center;
70
+ justify-content: center;
71
+ text-align: center;
72
+ font-size: 85%;
73
+ line-height: 1;
74
+ color: $muted;
75
+ padding: $card-padding-small / 2;
76
+ background: $card-secondary-bg;
77
+
78
+ @include breakpoint(medium){
79
+ min-width: 7rem;
80
+ flex-direction: row;
81
+ justify-content: flex-end;
82
+ flex-basis: 12rem;
83
+ padding: 1rem $card-padding;
84
+ }
85
+
86
+ &:last-child{
87
+ margin-bottom: 0;
88
+ }
89
+ }
90
+
91
+ &__data__icon{
92
+ .icon{
93
+ width: 20px;
94
+ height: 20px;
95
+ fill: $muted;
96
+ }
97
+
98
+ &:hover{
99
+ .icon{
100
+ fill: $anchor-color;
101
+ }
102
+ }
103
+ }
104
+
105
+ &__data__number{
106
+ @extend .card-data__item__number;
107
+
27
108
  font-size: 1.5rem;
28
- margin-right: 1rem;
29
- margin-bottom: 0;
30
- text-align: right;
109
+ line-height: 1.2;
31
110
  }
32
- }
33
111
 
34
- .budget--list__action{
35
- margin-bottom: 0;
112
+ &__data__votes{
113
+ @extend .card-data__item__number;
114
+
115
+ @include breakpoint(medium){
116
+ flex-grow: 1;
117
+ font-size: 1.2rem;
118
+ margin-left: 1rem;
119
+ margin-right: 1rem;
120
+ margin-bottom: 0;
121
+ text-align: cemter;
122
+ }
123
+ }
124
+
125
+ &__data--added{
126
+ background-color: tint($success, 80%);
127
+ }
128
+
129
+ &__title{
130
+ font-size: $global-font-size;
131
+ }
132
+
133
+ &__number{
134
+ @include breakpoint(medium down){
135
+ font-size: 1rem;
136
+ }
137
+
138
+ @include breakpoint(medium){
139
+ flex-grow: 1;
140
+ font-size: 1.2rem;
141
+ margin-left: 1rem;
142
+ margin-right: 1rem;
143
+ margin-bottom: 0;
144
+ text-align: right;
145
+ }
146
+ }
147
+
148
+ &__action{
149
+ margin-bottom: 0;
150
+ border-radius: 50%;
151
+ align-self: center;
152
+ flex-shrink: 0;
153
+ width: 2em;
154
+ height: 2em;
155
+ padding: 0;
156
+ display: flex;
157
+ justify-content: center;
158
+ align-items: center;
159
+
160
+ &--disabled{
161
+ pointer-events: none;
162
+ }
163
+ }
36
164
  }
@@ -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>