decidim-accountability 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 (161) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/accountability/content_blocks/highlighted_results_cell.rb +3 -8
  3. data/app/cells/decidim/accountability/highlighted_results/show.erb +3 -1
  4. data/app/cells/decidim/accountability/highlighted_results_for_component/show.erb +19 -19
  5. data/app/cells/decidim/accountability/highlighted_results_for_component_cell.rb +29 -6
  6. data/app/cells/decidim/accountability/project/show.erb +11 -0
  7. data/app/cells/decidim/accountability/project/timeline.erb +22 -0
  8. data/app/cells/decidim/accountability/project_cell.rb +75 -0
  9. data/app/cells/decidim/accountability/result_activity_cell.rb +1 -4
  10. data/app/cells/decidim/accountability/result_card_cell.rb +21 -0
  11. data/app/cells/decidim/accountability/result_cell.rb +2 -2
  12. data/app/cells/decidim/accountability/result_l/extra_data.erb +3 -0
  13. data/app/cells/decidim/accountability/result_l_cell.rb +30 -0
  14. data/app/cells/decidim/accountability/result_metadata/project_aside.erb +6 -0
  15. data/app/cells/decidim/accountability/result_metadata/show_footer.erb +11 -0
  16. data/app/cells/decidim/accountability/result_metadata/versions.erb +1 -0
  17. data/app/cells/decidim/accountability/result_metadata_cell.rb +136 -0
  18. data/app/cells/decidim/accountability/results/show.erb +7 -0
  19. data/app/cells/decidim/accountability/results_cell.rb +14 -0
  20. data/app/cells/decidim/accountability/status/show.erb +9 -0
  21. data/app/cells/decidim/accountability/status/status.erb +16 -0
  22. data/app/cells/decidim/accountability/status_cell.rb +91 -0
  23. data/app/commands/decidim/accountability/admin/import_projects_to_accountability.rb +37 -0
  24. data/app/controllers/concerns/decidim/accountability/admin/filterable.rb +2 -2
  25. data/app/controllers/decidim/accountability/admin/import_results_controller.rb +18 -6
  26. data/app/controllers/decidim/accountability/admin/projects_import_controller.rb +31 -0
  27. data/app/controllers/decidim/accountability/admin/results_controller.rb +4 -5
  28. data/app/controllers/decidim/accountability/admin/statuses_controller.rb +3 -3
  29. data/app/controllers/decidim/accountability/admin/timeline_entries_controller.rb +3 -3
  30. data/app/controllers/decidim/accountability/results_controller.rb +20 -2
  31. data/app/events/decidim/accountability/proposal_linked_event.rb +18 -1
  32. data/app/events/decidim/accountability/result_progress_updated_event.rb +18 -2
  33. data/app/forms/decidim/accountability/admin/import_results_form.rb +22 -0
  34. data/app/forms/decidim/accountability/admin/result_import_projects_form.rb +51 -0
  35. data/app/helpers/decidim/accountability/admin/application_helper.rb +1 -0
  36. data/app/helpers/decidim/accountability/application_helper.rb +43 -2
  37. data/app/helpers/decidim/accountability/breadcrumb_helper.rb +10 -0
  38. data/app/jobs/decidim/accountability/admin/import_projects_job.rb +72 -0
  39. data/app/mailers/decidim/accountability/import_projects_mailer.rb +25 -0
  40. data/app/models/decidim/accountability/result.rb +1 -1
  41. data/app/packs/entrypoints/decidim_accountability.js +4 -1
  42. data/app/packs/entrypoints/decidim_accountability_admin_imports.js +3 -0
  43. data/app/packs/images/decidim/accountability/breadcrumb_arrow.svg +3 -0
  44. data/app/packs/src/decidim/accountability/admin/imports.js +15 -0
  45. data/app/packs/stylesheets/accountability.scss +169 -0
  46. data/app/permissions/decidim/accountability/admin/permissions.rb +17 -6
  47. data/app/presenters/decidim/accountability/admin_log/result_presenter.rb +2 -2
  48. data/app/presenters/decidim/accountability/admin_log/status_presenter.rb +2 -2
  49. data/app/presenters/decidim/accountability/admin_log/timeline_entry_presenter.rb +2 -2
  50. data/app/queries/decidim/accountability/metrics/results_metric_manage.rb +1 -1
  51. data/app/services/decidim/accountability/results_calculator.rb +1 -1
  52. data/app/services/decidim/accountability/results_csv_importer.rb +2 -2
  53. data/app/views/decidim/accountability/admin/import_results/new.html.erb +27 -23
  54. data/app/views/decidim/accountability/admin/projects_import/new.html.erb +45 -0
  55. data/app/views/decidim/accountability/admin/results/_form.html.erb +46 -46
  56. data/app/views/decidim/accountability/admin/results/edit.html.erb +18 -7
  57. data/app/views/decidim/accountability/admin/results/index.html.erb +102 -91
  58. data/app/views/decidim/accountability/admin/results/new.html.erb +18 -8
  59. data/app/views/decidim/accountability/admin/shared/_subnav.html.erb +1 -1
  60. data/app/views/decidim/accountability/admin/statuses/_form.html.erb +15 -17
  61. data/app/views/decidim/accountability/admin/statuses/edit.html.erb +16 -6
  62. data/app/views/decidim/accountability/admin/statuses/index.html.erb +33 -36
  63. data/app/views/decidim/accountability/admin/statuses/new.html.erb +16 -6
  64. data/app/views/decidim/accountability/admin/timeline_entries/_form.html.erb +12 -14
  65. data/app/views/decidim/accountability/admin/timeline_entries/edit.html.erb +17 -6
  66. data/app/views/decidim/accountability/admin/timeline_entries/index.html.erb +35 -34
  67. data/app/views/decidim/accountability/admin/timeline_entries/new.html.erb +17 -6
  68. data/app/views/decidim/accountability/import_projects_mailer/import.html.erb +2 -0
  69. data/app/views/decidim/accountability/results/_home_categories.html.erb +28 -73
  70. data/app/views/decidim/accountability/results/_linked_results.html.erb +3 -12
  71. data/app/views/decidim/accountability/results/_project.html.erb +29 -0
  72. data/app/views/decidim/accountability/results/_projects_aside.html.erb +40 -0
  73. data/app/views/decidim/accountability/results/_scope_filters.html.erb +27 -27
  74. data/app/views/decidim/accountability/results/_search.html.erb +15 -9
  75. data/app/views/decidim/accountability/results/_stats_box.html.erb +3 -3
  76. data/app/views/decidim/accountability/results/home.html.erb +34 -8
  77. data/app/views/decidim/accountability/results/index.html.erb +15 -15
  78. data/app/views/decidim/accountability/results/index.js.erb +3 -0
  79. data/app/views/decidim/accountability/results/show.html.erb +9 -10
  80. data/app/views/decidim/accountability/versions/show.html.erb +13 -10
  81. data/app/views/decidim/participatory_spaces/_result.html.erb +4 -4
  82. data/config/assets.rb +2 -2
  83. data/config/locales/ar.yml +23 -61
  84. data/config/locales/bg.yml +0 -96
  85. data/config/locales/ca.yml +54 -31
  86. data/config/locales/cs.yml +58 -29
  87. data/config/locales/da.yml +1 -36
  88. data/config/locales/de.yml +59 -36
  89. data/config/locales/el.yml +62 -29
  90. data/config/locales/en.yml +55 -31
  91. data/config/locales/es-MX.yml +52 -29
  92. data/config/locales/es-PY.yml +52 -29
  93. data/config/locales/es.yml +55 -32
  94. data/config/locales/eu.yml +53 -30
  95. data/config/locales/fi-plain.yml +51 -28
  96. data/config/locales/fi.yml +54 -31
  97. data/config/locales/fr-CA.yml +51 -28
  98. data/config/locales/fr.yml +52 -29
  99. data/config/locales/ga-IE.yml +0 -4
  100. data/config/locales/gl.yml +0 -41
  101. data/config/locales/hu.yml +41 -29
  102. data/config/locales/id-ID.yml +1 -30
  103. data/config/locales/is-IS.yml +0 -32
  104. data/config/locales/it.yml +0 -43
  105. data/config/locales/ja.yml +55 -39
  106. data/config/locales/kaa.yml +20 -1
  107. data/config/locales/ko.yml +0 -188
  108. data/config/locales/lb.yml +1 -42
  109. data/config/locales/lt.yml +60 -41
  110. data/config/locales/lv.yml +1 -36
  111. data/config/locales/nl.yml +0 -41
  112. data/config/locales/no.yml +8 -49
  113. data/config/locales/pl.yml +17 -61
  114. data/config/locales/pt-BR.yml +41 -29
  115. data/config/locales/pt.yml +0 -42
  116. data/config/locales/ro-RO.yml +39 -66
  117. data/config/locales/ru.yml +1 -30
  118. data/config/locales/si-LK.yml +0 -4
  119. data/config/locales/sk.yml +1 -40
  120. data/config/locales/sl.yml +0 -11
  121. data/config/locales/sq-AL.yml +82 -7
  122. data/config/locales/sr-CS.yml +1 -30
  123. data/config/locales/sv.yml +36 -51
  124. data/config/locales/th-TH.yml +0 -140
  125. data/config/locales/tr-TR.yml +9 -75
  126. data/config/locales/uk.yml +1 -28
  127. data/config/locales/zh-CN.yml +1 -36
  128. data/config/locales/zh-TW.yml +52 -43
  129. data/lib/decidim/accountability/admin_engine.rb +3 -2
  130. data/lib/decidim/accountability/component.rb +4 -99
  131. data/lib/decidim/accountability/engine.rb +9 -1
  132. data/lib/decidim/accountability/result_serializer.rb +1 -1
  133. data/lib/decidim/accountability/seeds.rb +115 -0
  134. data/lib/decidim/accountability/test/factories.rb +18 -29
  135. data/lib/decidim/accountability/version.rb +1 -1
  136. data/lib/decidim/api/result_type.rb +1 -0
  137. metadata +62 -51
  138. data/app/cells/decidim/accountability/content_blocks/highlighted_results/elements.erb +0 -5
  139. data/app/cells/decidim/accountability/content_blocks/highlighted_results/heading.erb +0 -1
  140. data/app/cells/decidim/accountability/result_m/data.erb +0 -23
  141. data/app/cells/decidim/accountability/result_m/footer.erb +0 -22
  142. data/app/cells/decidim/accountability/result_m/tags.erb +0 -1
  143. data/app/cells/decidim/accountability/result_m_cell.rb +0 -37
  144. data/app/events/decidim/accountability/base_result_event.rb +0 -29
  145. data/app/packs/stylesheets/decidim/accountability/_accountability.scss +0 -4
  146. data/app/packs/stylesheets/decidim/accountability/accountability/_cards.scss +0 -11
  147. data/app/packs/stylesheets/decidim/accountability/accountability/_categories.scss +0 -121
  148. data/app/packs/stylesheets/decidim/accountability/accountability/_lines_breadcrumb.scss +0 -37
  149. data/app/packs/stylesheets/decidim/accountability/accountability/_results.scss +0 -148
  150. data/app/views/decidim/accountability/admin/results/proposals_picker.html.erb +0 -1
  151. data/app/views/decidim/accountability/result_widgets/show.html.erb +0 -2
  152. data/app/views/decidim/accountability/results/_home_header.html.erb +0 -23
  153. data/app/views/decidim/accountability/results/_results_leaf.html.erb +0 -47
  154. data/app/views/decidim/accountability/results/_results_parent.html.erb +0 -32
  155. data/app/views/decidim/accountability/results/_show_leaf.html.erb +0 -81
  156. data/app/views/decidim/accountability/results/_show_parent.html.erb +0 -30
  157. data/app/views/decidim/accountability/results/_stats.html.erb +0 -15
  158. data/app/views/decidim/accountability/results/_timeline.html.erb +0 -30
  159. data/app/views/decidim/accountability/versions/index.html.erb +0 -12
  160. data/config/locales/he-IL.yml +0 -219
  161. data/decidim-accountability.gemspec +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc1978db16f83820e542adbfc287c430fd02ab7f033658b2a65eca7b45763043
4
- data.tar.gz: 6808a813b46e256c9c1a2a55c78795f1ce24096daa33f28287813275a0220440
3
+ metadata.gz: 53d0e9219637a9369c6b8ffca3060c9c11cc4127ad6b3588e5caeb35eb415778
4
+ data.tar.gz: 767f052eb960ba0e461a7864b121f410db02cb0da5981f9aa277762928a68cbf
5
5
  SHA512:
6
- metadata.gz: 66cd16d5cffe68589d6c09bb5500610a7d3bb9f938ae7cd88b1e1a9f816131297b416517336eb24aab7956fed6cc1d7c0b423368cfb6a8e8e958d537f2f9fd30
7
- data.tar.gz: 5a0bf55f147a7225d149a08c599ba6b554f5dc377d1d4a651843b839403e073a3508cc18d90d9d15276701e0d35e0e1836697b80514edd4ba56ef498a8df6606
6
+ metadata.gz: e82ced7fbbacd1dfbb756a514fe506fdfa66b281b891313bde90c460bdf67243705224703d5c4c66cae7a82c3fc49b03fbd77cd3425e4fda135da28dba264cd9
7
+ data.tar.gz: d8189bdc78ceeaef893356c262eba1d32269a4a976f9b6c4d4e38cd4617181c064d106f1820e38559fc697ba7e3b199891b1e099651bf7913f5b66688dc7cbd3
@@ -3,15 +3,10 @@
3
3
  module Decidim
4
4
  module Accountability
5
5
  module ContentBlocks
6
- class HighlightedResultsCell < Decidim::ContentBlocks::HighlightedElementsCell
7
- include Cell::ViewModel::Partial
8
- include Decidim::IconHelper
9
- include Decidim::Accountability::ApplicationHelper
10
- include ActiveSupport::NumberHelper
6
+ class HighlightedResultsCell < Decidim::ContentBlocks::HighlightedElementsWithCellForListCell
7
+ private
11
8
 
12
- def base_relation
13
- @base_relation ||= Decidim::Accountability::Result.where(component: published_components)
14
- end
9
+ def list_cell_path = "decidim/accountability/highlighted_results_for_component"
15
10
  end
16
11
  end
17
12
  end
@@ -1,3 +1,5 @@
1
1
  <% published_components.each do |component| %>
2
- <%= cell "decidim/accountability/highlighted_results_for_component", component %>
2
+ <section class="content-block">
3
+ <%= cell "decidim/accountability/highlighted_results_for_component", component %>
4
+ </section>
3
5
  <% end %>
@@ -1,21 +1,21 @@
1
- <section class="section row collapse highlighted_results">
2
- <h3 class="section-heading">
3
- <%= decidim_escape_translated(model.name) %> <a href="<%= main_component_path(model) %>" class="text-small"><%= t("decidim.participatory_spaces.highlighted_results.see_all", count: results_count) %></a>
4
- </h3>
1
+ <%# NOTE: Since this call can be called from outside decidim-accountability, frontend assets are required %>
2
+ <%= apply_accountability_pack_tags %>
5
3
 
6
- <div class="row">
7
- <div class="columns accountability">
8
- <div class="card card--action card--list">
9
- <% results_to_render.each do |result| %>
10
- <%= render partial: "decidim/participatory_spaces/result.html", locals: { result: result } %>
11
- <% end %>
12
- </div>
13
- </div>
14
- </div>
4
+ <div class="content-block__title">
5
+ <h2 class="h2 decorator">
6
+ <%= single_component? ? translated_attribute(model.name) : t("decidim.accountability.content_blocks.highlighted_results.results") %>
7
+ </h2>
8
+ <div class="label text-lg"><%= results_count %></div>
9
+ <% if single_component? %>
10
+ <%= link_to main_component_path(model), class: "button button__sm button__text-secondary" do %>
11
+ <span><%= t("decidim.participatory_spaces.highlighted_results.see_all") %></span>
12
+ <%= icon "arrow-right-line" %>
13
+ <% end %>
14
+ <% end %>
15
+ </div>
15
16
 
16
- <%= link_to(
17
- t("decidim.participatory_spaces.highlighted_results.see_all", count: results_count),
18
- main_component_path(model),
19
- class: "button button--sc hollow button--right"
20
- ) %>
21
- </section>
17
+ <div>
18
+ <% results_to_render.each do |result| %>
19
+ <%= cell "decidim/accountability/result_l", result, title_tag: :h3, **options.slice(:show_space) %>
20
+ <% end %>
21
+ </div>
@@ -14,22 +14,37 @@ module Decidim
14
14
  include Decidim::LayoutHelper
15
15
  include Cell::ViewModel::Partial
16
16
 
17
+ delegate :snippets, to: :controller
18
+
17
19
  def show
18
- render unless results_count.zero?
20
+ render unless items_blank?
21
+ end
22
+
23
+ def items_blank?
24
+ results_count.zero?
19
25
  end
20
26
 
21
27
  private
22
28
 
29
+ def results_count
30
+ @results_count ||= results.size
31
+ end
32
+
23
33
  def results
24
- @results ||= Decidim::Accountability::Result.where(component: model).order_randomly((rand * 2) - 1)
34
+ @results ||= case options[:order]
35
+ when "recent"
36
+ Decidim::Accountability::Result.where(component: model).order_by_most_recent
37
+ else
38
+ Decidim::Accountability::Result.where(component: model).order_randomly(random_seed)
39
+ end
25
40
  end
26
41
 
27
- def results_to_render
28
- @results_to_render ||= results.includes(:component, :status).limit(4)
42
+ def single_component?
43
+ @single_component ||= model.is_a?(Decidim::Component)
29
44
  end
30
45
 
31
- def results_count
32
- @results_count ||= results.count
46
+ def results_to_render
47
+ @results_to_render ||= results.includes(:component, :status).limit(limit)
33
48
  end
34
49
 
35
50
  def cache_hash
@@ -43,6 +58,14 @@ module Decidim
43
58
  def cache_expiry_time
44
59
  10.minutes
45
60
  end
61
+
62
+ def limit
63
+ 4
64
+ end
65
+
66
+ def random_seed
67
+ (rand * 2) - 1
68
+ end
46
69
  end
47
70
  end
48
71
  end
@@ -0,0 +1,11 @@
1
+ <section class="layout-main__section layout-main__heading">
2
+ <h1 class="h2 decorator"><%= title %></h1>
3
+ </section>
4
+
5
+ <section class="layout-main__section">
6
+ <div class="editor-content mt-8">
7
+ <%= description %>
8
+ </div>
9
+ </section>
10
+
11
+ <%= cell "decidim/tab_panels", tab_panel_items %>
@@ -0,0 +1,22 @@
1
+ <ol class="accountability__project-timeline">
2
+ <% timeline_entries.each_with_index do |timeline_entry, i| %>
3
+ <li class="accountability__project-timeline-entry">
4
+ <div class="accountability__project-timeline-entry-number">
5
+ <span><%= i + 1 %></span>
6
+ </div>
7
+ <div class="accountability__project-timeline-entry-attributes">
8
+ <h3>
9
+ <%= translated_attribute timeline_entry.title %>
10
+ </h3>
11
+ <div>
12
+ <%= l timeline_entry.entry_date, format: :decidim_short %>
13
+ </div>
14
+ <% if translated_attribute(timeline_entry.description).present? %>
15
+ <div>
16
+ <%= translated_attribute(timeline_entry.description).html_safe %>
17
+ </div>
18
+ <% end %>
19
+ </div>
20
+ </li>
21
+ <% end %>
22
+ </ol>
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Accountability
7
+ # This cell renders a project
8
+ class ProjectCell < Decidim::ViewModel
9
+ include ApplicationHelper
10
+ include Decidim::ResourceHelper
11
+ include Decidim::TranslationsHelper
12
+ include Decidim::AttachmentsHelper
13
+
14
+ delegate :current_component, :component_settings, to: :controller
15
+ delegate :children, :timeline_entries, to: :model
16
+
17
+ alias result model
18
+
19
+ def show
20
+ render
21
+ end
22
+
23
+ private
24
+
25
+ def title
26
+ translated_attribute result.title
27
+ end
28
+
29
+ def description
30
+ translated_attribute(result.description).html_safe
31
+ end
32
+
33
+ def scope
34
+ current_scope.presence
35
+ end
36
+
37
+ def tab_panel_items
38
+ [
39
+ {
40
+ enabled: children.any?,
41
+ id: "list",
42
+ text: t("decidim.accountability.results.timeline.title"),
43
+ icon: "route-line",
44
+ method: :cell,
45
+ args: ["decidim/accountability/results", result.children]
46
+ },
47
+ {
48
+ enabled: result.linked_resources(:proposals, "included_proposals").present?,
49
+ id: "included_proposals",
50
+ text: t("activemodel.attributes.result.proposals"),
51
+ icon: "chat-new-line",
52
+ method: :cell,
53
+ args: ["decidim/linked_resources_for", result, { type: :proposals, link_name: "included_proposals" }]
54
+ },
55
+ {
56
+ enabled: result.linked_resources(:projects, "included_projects").present?,
57
+ id: "included_projects",
58
+ text: t("activemodel.attributes.result.project_ids"),
59
+ icon: "git-pull-request-line",
60
+ method: :cell,
61
+ args: ["decidim/linked_resources_for", result, { type: :projects, link_name: "included_projects" }]
62
+ },
63
+ {
64
+ enabled: result.linked_resources(:meetings, "meetings_through_proposals").present?,
65
+ id: "included_meetings",
66
+ text: t("activemodel.attributes.result.meetings_ids"),
67
+ icon: "treasure-map-line",
68
+ method: :cell,
69
+ args: ["decidim/linked_resources_for", result, { type: :meetings, link_name: "meetings_through_proposals" }]
70
+ }
71
+ ] + attachments_tab_panel_items(result)
72
+ end
73
+ end
74
+ end
75
+ end
@@ -5,10 +5,7 @@ module Decidim
5
5
  # A cell to display when a Result has been created.
6
6
  class ResultActivityCell < ActivityCell
7
7
  def title
8
- I18n.t(
9
- "decidim.accountability.last_activity.new_result_at_html",
10
- link: participatory_space_link
11
- )
8
+ I18n.t("decidim.accountability.last_activity.new_result")
12
9
  end
13
10
  end
14
11
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Accountability
7
+ # This cell renders the result card for an instance of a Result
8
+ # the default size is the List Card (:l)
9
+ class ResultCardCell < Decidim::ViewModel
10
+ def show
11
+ cell card_size, model, options
12
+ end
13
+
14
+ private
15
+
16
+ def card_size
17
+ "decidim/accountability/result_l"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -5,7 +5,7 @@ require "cell/partial"
5
5
  module Decidim
6
6
  module Accountability
7
7
  # This cell renders the result card for an instance of a Result
8
- # the default size is the Medium Card (:m)
8
+ # the default size is the List Card (:l)
9
9
  class ResultCell < Decidim::ViewModel
10
10
  def show
11
11
  cell card_size, model, options
@@ -14,7 +14,7 @@ module Decidim
14
14
  private
15
15
 
16
16
  def card_size
17
- "decidim/accountability/result_m"
17
+ "decidim/accountability/result_l"
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,3 @@
1
+ <% if component_settings.try(:display_progress_enabled?) && result.progress.present? %>
2
+ <div class="accountability__progress"><%= display_percentage result.progress %></div>
3
+ <% end %>
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Accountability
7
+ # This cell renders the List (:l) result card
8
+ # for an instance of a Result
9
+ class ResultLCell < Decidim::CardLCell
10
+ include ApplicationHelper
11
+ include ActiveSupport::NumberHelper
12
+
13
+ alias result model
14
+
15
+ def component_settings
16
+ controller.try(:component_settings) || result.component.settings
17
+ end
18
+
19
+ def render_extra_data?
20
+ true
21
+ end
22
+
23
+ private
24
+
25
+ def metadata_cell
26
+ "decidim/accountability/result_metadata"
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,6 @@
1
+ <% items.each do |item| %>
2
+ <div class="accountability__project-aside-item">
3
+ <div><%= icon item[:icon], class: "w-3.5 h-3.5 fill-current text-gray" %><%= item[:text] %></div>
4
+ <div><%= item[:value] %></div>
5
+ </div>
6
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <ul class="metadata__container layout-main__section" data-metadata-footer>
2
+ <% items.each do |item| %>
3
+ <li class="metadata__item">
4
+ <% if item.has_key? :partial %>
5
+ <%= render item[:partial] %>
6
+ <% else %>
7
+ <%= item[:text] %>
8
+ <% end %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
@@ -0,0 +1 @@
1
+ <%= resource_version(result, versions_path: result_version_path(result, result.versions.count)) %>
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Accountability
5
+ # This cell renders metadata for an instance of a Result
6
+ class ResultMetadataCell < Decidim::CardMetadataCell
7
+ include Decidim::SanitizeHelper
8
+ include Decidim::TranslationsHelper
9
+ include ActiveSupport::NumberHelper
10
+ include Decidim::ResourceReferenceHelper
11
+ include Decidim::ResourceVersionsHelper
12
+ include Decidim::Accountability::Engine.routes.url_helpers
13
+ include Decidim::LayoutHelper
14
+
15
+ delegate :start_date, :end_date, :status, :category, :parent, :reference, to: :model
16
+
17
+ alias result model
18
+
19
+ def show
20
+ render template
21
+ end
22
+
23
+ def initialize(*)
24
+ super
25
+
26
+ @items.prepend(*result_items)
27
+ end
28
+
29
+ private
30
+
31
+ def result_items
32
+ return [dates_item, status_item, status_description] if template == :project_aside
33
+ return [reference, versions] if template == :show_footer
34
+
35
+ [dates_item_compact, status_item_compact, category_item]
36
+ end
37
+
38
+ def template
39
+ @template ||= options[:template] || :show
40
+ end
41
+
42
+ def dates_item_compact
43
+ return if start_date.blank?
44
+
45
+ {
46
+ text: date_values(format: :decidim_with_month_name_short).join(" - "),
47
+ icon: "calendar-todo-line"
48
+ }
49
+ end
50
+
51
+ def reference
52
+ { text: resource_reference(result) }
53
+ end
54
+
55
+ def versions_count
56
+ @versions_count ||= result.versions_count
57
+ end
58
+
59
+ def versions
60
+ return if result.versions.blank?
61
+
62
+ { partial: :versions }
63
+ end
64
+
65
+ def category_item
66
+ return if inherited_category.blank?
67
+
68
+ {
69
+ text: translated_attribute(inherited_category.name),
70
+ icon: resource_type_icon_key(category.class)
71
+ }
72
+ end
73
+
74
+ def status_item_compact
75
+ return if status.blank?
76
+
77
+ {
78
+ text: translated_attribute(status.name),
79
+ icon: "focus-2-line"
80
+ }
81
+ end
82
+
83
+ def inherited_category
84
+ return category if category.present?
85
+
86
+ parent&.category
87
+ end
88
+
89
+ def dates_item
90
+ return if start_date.blank?
91
+
92
+ date_title = [
93
+ *(t("models.result.fields.start_date", scope: "decidim.accountability") if start_date),
94
+ *(t("models.result.fields.end_date", scope: "decidim.accountability") if end_date)
95
+ ].join(" / ")
96
+
97
+ {
98
+ text: date_title,
99
+ icon: "calendar-todo-line",
100
+ value: date_values.join(" / ")
101
+ }
102
+ end
103
+
104
+ def date_values(format: :decidim_short_with_month_name_short)
105
+ @date_values ||= [
106
+ *(l(start_date, format:) if start_date),
107
+ *(l(end_date, format:) if end_date)
108
+ ]
109
+ end
110
+
111
+ def status_item
112
+ return if status.blank?
113
+
114
+ {
115
+ text: t("models.result.fields.status", scope: "decidim.accountability"),
116
+ icon: "focus-2-line",
117
+ value: translated_attribute(status.name)
118
+ }
119
+ end
120
+
121
+ def status_description
122
+ return unless status.present? && (description = translated_attribute(status.description)).present?
123
+
124
+ {
125
+ text: t("models.status.fields.description", scope: "decidim.accountability"),
126
+ icon: "file-text-line",
127
+ value: description
128
+ }
129
+ end
130
+
131
+ def has_dates?
132
+ start_date.present? && end_date.present?
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,7 @@
1
+ <% if results.any? %>
2
+ <% results.each do |result| %>
3
+ <%= card_for result %>
4
+ <% end %>
5
+ <% else %>
6
+ <%= cell("decidim/announcement", t("no_results", scope: "decidim.accountability.results")) %>
7
+ <% end %>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Accountability
7
+ # This cell renders a list of results
8
+ class ResultsCell < Decidim::ViewModel
9
+ include Decidim::CardHelper
10
+
11
+ alias results model
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ <% if url %>
2
+ <a href="<%= url %>" class="accountability__status <%= extra_classes %>">
3
+ <%= render :status %>
4
+ </a>
5
+ <% else %>
6
+ <div class="accountability__status <%= extra_classes %>">
7
+ <%= render :status %>
8
+ </div>
9
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <p class="accountability__status-title"><%= title %></p>
2
+
3
+ <% if component_settings.display_progress_enabled? && progress.present? %>
4
+ <div class="accountability__status-progress">
5
+ <div style="width:<%= progress %>%"></div>
6
+ </div>
7
+ <% end %>
8
+
9
+ <div class="accountability__status-value">
10
+ <% if progress.present? %>
11
+ <span><%= display_percentage progress %></span>
12
+ <% end %>
13
+ <% if count %>
14
+ <span><%= count %></span>
15
+ <% end %>
16
+ </div>
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cell/partial"
4
+
5
+ module Decidim
6
+ module Accountability
7
+ # This cell renders the status of a category
8
+ class StatusCell < Decidim::ViewModel
9
+ include ApplicationHelper
10
+ include BreadcrumbHelper
11
+ include Decidim::TranslationsHelper
12
+ include ActiveSupport::NumberHelper
13
+
14
+ delegate :current_component, :component_settings, to: :controller
15
+
16
+ def show
17
+ return unless render?
18
+
19
+ render
20
+ end
21
+
22
+ def render?
23
+ options[:render_blank] || has_results?
24
+ end
25
+
26
+ def has_results?
27
+ results_count&.positive? || progress.present?
28
+ end
29
+
30
+ private
31
+
32
+ def scope
33
+ current_scope.presence
34
+ end
35
+
36
+ def url
37
+ options[:url]
38
+ end
39
+
40
+ def title
41
+ if model.is_a? Decidim::Category
42
+ translated_attribute(model.name)
43
+ else
44
+ options[:title]
45
+ end
46
+ end
47
+
48
+ def results_count
49
+ @results_count ||= if model.is_a? Decidim::Category
50
+ count_calculator(scope, model.id)
51
+ else
52
+ options[:count]
53
+ end
54
+ end
55
+
56
+ def progress
57
+ if model.is_a? Decidim::Category
58
+ progress_calculator(scope, model.id).presence
59
+ elsif model.respond_to?(:progress)
60
+ model.progress
61
+ else
62
+ options[:progress] || progress_calculator(scope, nil).presence
63
+ end
64
+ end
65
+
66
+ def extra_classes
67
+ options[:extra_classes]
68
+ end
69
+
70
+ def count
71
+ return unless results_count&.positive? && render_count
72
+
73
+ display_count(results_count)
74
+ end
75
+
76
+ def render_count
77
+ return true unless options.has_key?(:render_count)
78
+
79
+ options[:render_count]
80
+ end
81
+
82
+ def count_calculator(scope_id, category_id)
83
+ Decidim::Accountability::ResultsCalculator.new(current_component, scope_id, category_id).count
84
+ end
85
+
86
+ def decidim
87
+ Decidim::Accountability::Engine.routes.url_helpers
88
+ end
89
+ end
90
+ end
91
+ end