decidim-participatory_processes 0.23.3 → 0.24.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/app/cells/decidim/participatory_process_groups/content_block_cell.rb +17 -0
  3. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters.erb +22 -0
  4. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters_small_view.erb +18 -0
  5. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/participatory_space_filters.erb +6 -0
  6. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/show.erb +7 -0
  7. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/title_filter_order.erb +8 -0
  8. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb +65 -0
  9. data/app/cells/decidim/participatory_process_groups/content_blocks/html/show.erb +3 -0
  10. data/app/cells/decidim/participatory_process_groups/content_blocks/html_cell.rb +13 -0
  11. data/app/cells/decidim/participatory_process_groups/content_blocks/metadata/show.erb +28 -0
  12. data/app/cells/decidim/participatory_process_groups/content_blocks/metadata_cell.rb +15 -0
  13. data/app/cells/decidim/participatory_process_groups/content_blocks/stats/show.erb +13 -0
  14. data/app/cells/decidim/participatory_process_groups/content_blocks/stats_cell.rb +17 -0
  15. data/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb +43 -0
  16. data/app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb +56 -0
  17. data/app/cells/decidim/participatory_process_groups/process_filters_cell.rb +78 -0
  18. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/show.erb +2 -16
  19. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/single_process.erb +32 -28
  20. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +33 -10
  21. data/app/cells/decidim/participatory_processes/filtered_participatory_processes/show.erb +3 -0
  22. data/app/cells/decidim/participatory_processes/filtered_participatory_processes_cell.rb +56 -0
  23. data/app/cells/decidim/participatory_processes/process_cell.rb +6 -1
  24. data/app/cells/decidim/participatory_processes/process_filters_cell.rb +1 -1
  25. data/app/cells/decidim/participatory_processes/process_group_cell.rb +6 -1
  26. data/app/cells/decidim/participatory_processes/process_group_m_cell.rb +3 -1
  27. data/app/cells/decidim/participatory_processes/process_group_s/image.erb +1 -0
  28. data/app/cells/decidim/participatory_processes/process_group_s/show.erb +8 -0
  29. data/app/cells/decidim/participatory_processes/process_group_s_cell.rb +23 -0
  30. data/app/cells/decidim/participatory_processes/process_s/image.erb +1 -0
  31. data/app/cells/decidim/participatory_processes/process_s/show.erb +14 -0
  32. data/app/cells/decidim/participatory_processes/process_s_cell.rb +35 -0
  33. data/app/cells/decidim/participatory_processes/statistic/show.erb +3 -3
  34. data/app/cells/decidim/participatory_processes/statistics/show.erb +1 -1
  35. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +1 -0
  36. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_admin.rb +7 -75
  37. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +11 -2
  38. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +1 -0
  39. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +11 -2
  40. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +1 -0
  41. data/app/controllers/decidim/participatory_processes/admin/imports_controller.rb +14 -0
  42. data/app/controllers/decidim/participatory_processes/admin/moderations/reports_controller.rb +18 -0
  43. data/app/controllers/decidim/participatory_processes/admin/participatory_process_group_landing_page_content_blocks_controller.rb +48 -0
  44. data/app/controllers/decidim/participatory_processes/admin/participatory_process_group_landing_page_controller.rb +53 -0
  45. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +3 -1
  46. data/app/controllers/decidim/participatory_processes/participatory_process_groups_controller.rb +1 -2
  47. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +14 -1
  48. data/app/events/decidim/participatory_process_role_assigned_event.rb +1 -1
  49. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +3 -0
  50. data/app/forms/decidim/participatory_processes/admin/participatory_process_group_form.rb +34 -2
  51. data/app/forms/decidim/participatory_processes/admin/participatory_process_step_form.rb +1 -1
  52. data/app/helpers/decidim/participatory_processes/admin/participatory_processes_menu_helper.rb +23 -0
  53. data/app/helpers/decidim/participatory_processes/admin/process_groups_for_select_helper.rb +1 -1
  54. data/app/helpers/decidim/participatory_processes/application_helper.rb +0 -12
  55. data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +35 -0
  56. data/app/models/decidim/participatory_process.rb +2 -2
  57. data/app/models/decidim/participatory_process_group.rb +9 -1
  58. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_group_presenter.rb +10 -2
  59. data/app/presenters/decidim/participatory_processes/participatory_process_group_stats_presenter.rb +67 -0
  60. data/app/presenters/decidim/participatory_processes/participatory_process_presenter.rb +4 -3
  61. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +3 -3
  62. data/app/queries/decidim/participatory_processes/group_participatory_processes.rb +16 -0
  63. data/app/queries/decidim/participatory_processes/group_published_participatory_processes.rb +21 -0
  64. data/app/queries/decidim/participatory_processes/organization_participatory_processes.rb +1 -1
  65. data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb +1 -1
  66. data/app/queries/decidim/participatory_processes/promoted_participatory_process_groups.rb +12 -0
  67. data/app/queries/decidim/participatory_processes/stats_followers_count.rb +18 -4
  68. data/app/queries/decidim/participatory_processes/stats_participants_count.rb +18 -4
  69. data/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb +6 -2
  70. data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +1 -1
  71. data/app/serializers/decidim/participatory_processes/participatory_process_serializer.rb +1 -1
  72. data/app/services/decidim/participatory_processes/participatory_process_search.rb +2 -1
  73. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +2 -0
  74. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/_form.html.erb +68 -13
  75. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +7 -14
  76. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +12 -3
  77. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +2 -8
  78. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/show.html.erb +10 -2
  79. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/edit.html.erb +1 -0
  80. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/index.html.erb +6 -0
  81. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/edit.html.erb +2 -0
  82. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/index.html.erb +8 -0
  83. data/app/views/decidim/participatory_processes/admin/participatory_process_user_roles/new.html.erb +2 -0
  84. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +4 -0
  85. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +14 -3
  86. data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +2 -0
  87. data/app/views/decidim/participatory_processes/admin/shared/_secondary_nav.html.erb +2 -16
  88. data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +18 -8
  89. data/app/views/decidim/participatory_processes/participatory_process_groups/show.js.erb +12 -0
  90. data/app/views/decidim/participatory_processes/participatory_processes/_participatory_process_group.html.erb +4 -0
  91. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process_group.html.erb +31 -0
  92. data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +4 -2
  93. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +4 -4
  94. data/app/views/layouts/decidim/admin/participatory_process.html.erb +8 -1
  95. data/app/views/layouts/decidim/admin/participatory_process_group.html.erb +17 -0
  96. data/config/locales/ar.yml +3 -10
  97. data/config/locales/ca.yml +52 -5
  98. data/config/locales/cs.yml +56 -9
  99. data/config/locales/de.yml +52 -5
  100. data/config/locales/el.yml +3 -6
  101. data/config/locales/en.yml +52 -5
  102. data/config/locales/es-MX.yml +52 -5
  103. data/config/locales/es-PY.yml +52 -5
  104. data/config/locales/es.yml +52 -5
  105. data/config/locales/eu.yml +3 -6
  106. data/config/locales/fi-plain.yml +53 -6
  107. data/config/locales/fi.yml +53 -6
  108. data/config/locales/fr-CA.yml +52 -5
  109. data/config/locales/fr.yml +52 -5
  110. data/config/locales/gl.yml +84 -5
  111. data/config/locales/hu.yml +3 -6
  112. data/config/locales/id-ID.yml +3 -5
  113. data/config/locales/is-IS.yml +3 -3
  114. data/config/locales/it.yml +8 -6
  115. data/config/locales/ja.yml +3 -5
  116. data/config/locales/lv.yml +3 -7
  117. data/config/locales/nl.yml +50 -6
  118. data/config/locales/no.yml +3 -6
  119. data/config/locales/pl.yml +63 -13
  120. data/config/locales/pt-BR.yml +3 -6
  121. data/config/locales/pt.yml +3 -6
  122. data/config/locales/ro-RO.yml +74 -25
  123. data/config/locales/ru.yml +4 -9
  124. data/config/locales/sk.yml +3 -8
  125. data/config/locales/sr-CS.yml +4 -0
  126. data/config/locales/sv.yml +33 -5
  127. data/config/locales/tr-TR.yml +51 -5
  128. data/config/locales/uk.yml +4 -9
  129. data/config/locales/zh-CN.yml +3 -5
  130. data/db/migrate/20170220110740_remove_steps_short_description.rb +1 -1
  131. data/db/migrate/20201007215105_add_hashtag_to_participatory_process_groups.rb +7 -0
  132. data/db/migrate/20201008154315_add_metadata_columns_to_participatory_process_groups.rb +13 -0
  133. data/db/migrate/20201013105520_rename_name_column_to_title_in_decidim_participatory_process_groups.rb +39 -0
  134. data/db/migrate/20201030133444_add_promoted_flag_to_decidim_participatory_process_groups.rb +7 -0
  135. data/db/migrate/20210204154593_add_weight_field_to_participatory_processes.rb +7 -0
  136. data/db/migrate/20210310120750_add_followable_counter_cache_to_participatory_processes.rb +16 -0
  137. data/lib/decidim/api/participatory_process_group_type.rb +17 -0
  138. data/{app/types/decidim/participatory_processes → lib/decidim/api}/participatory_process_input_filter.rb +0 -0
  139. data/{app/types/decidim/participatory_processes → lib/decidim/api}/participatory_process_input_sort.rb +2 -2
  140. data/lib/decidim/api/participatory_process_step_type.rb +23 -0
  141. data/lib/decidim/api/participatory_process_type.rb +50 -0
  142. data/lib/decidim/participatory_processes.rb +2 -6
  143. data/lib/decidim/participatory_processes/admin_engine.rb +49 -1
  144. data/lib/decidim/participatory_processes/api.rb +11 -0
  145. data/lib/decidim/participatory_processes/engine.rb +90 -8
  146. data/lib/decidim/participatory_processes/participatory_space.rb +47 -24
  147. data/lib/decidim/participatory_processes/query_extensions.rb +18 -20
  148. data/lib/decidim/participatory_processes/test/factories.rb +15 -2
  149. data/lib/decidim/participatory_processes/version.rb +1 -1
  150. metadata +59 -17
  151. data/app/functions/decidim/participatory_processes/participatory_process_finder.rb +0 -10
  152. data/app/functions/decidim/participatory_processes/participatory_process_list.rb +0 -11
  153. data/app/types/decidim/participatory_processes/participatory_process_group_type.rb +0 -20
  154. data/app/types/decidim/participatory_processes/participatory_process_step_type.rb +0 -28
  155. data/app/types/decidim/participatory_processes/participatory_process_type.rb +0 -54
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a7d9401a97e25072d4fa8d7d7c93c350bd317a73254a7e2af1e545069975091
4
- data.tar.gz: 169180c333f2fd47ec242f0c97e20fef22d23d9cf0bcf3d8b70c5ba83c06fdf5
3
+ metadata.gz: 5cc840bc8f8e0626b1f85c64f3c7def8c19be168118fee8cb8fa43617ac0f892
4
+ data.tar.gz: d9cb7577da65efae1adc6e1d6eed862163f607dc5a0277e6632360d53d1cb7c2
5
5
  SHA512:
6
- metadata.gz: d608d180a2b8a66432202f038fe96be994146e192d00dc7e43bea6289e5ddefd9092827660bdf4bcd56954892bee8f577abd1124c382a534448316f17d2cdb27
7
- data.tar.gz: bd3297b8df7165257e95f8a0f99e5f4e3a24375713bd005ce99261a8d2f14e3363a18610fa4fabb2dcc6aff7d9c8236bc5efd17a5916eb4339c2d6d2642030e3
6
+ metadata.gz: 71bcb29769ba2496d4b1d1060d64b1feebc18c41385cd7fd30e70291b187d6e3bdfa7caf1a534f613928bb24f269b181b300290e9d237cadc48ddddf8895e465
7
+ data.tar.gz: a7da2535a902559761461356362e0a123b03e9f78eae73411035b02d96b6578c57fbd96932cb7bc895758c14aa124ce55e5eba5d5313edd2cd9f9a3917e0a88d
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ class ContentBlockCell < Decidim::Admin::ContentBlockCell
6
+ delegate :scoped_resource, to: :controller
7
+
8
+ def edit_content_block_path
9
+ decidim_participatory_processes.edit_participatory_process_group_landing_page_content_block_path(scoped_resource, manifest_name)
10
+ end
11
+
12
+ def decidim_participatory_processes
13
+ Decidim::ParticipatoryProcesses::AdminEngine.routes.url_helpers
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ <%= filter_form_for filter, decidim_participatory_processes.participatory_process_group_path(participatory_process_group) do |form| %>
2
+ <div class="columns mediumlarge-6 large-5">
3
+ <%= cell(
4
+ "decidim/scopes_picker",
5
+ form,
6
+ attribute: :scope_id,
7
+ multiple: true,
8
+ legend_title: I18n.t("decidim.scopes.scopes"),
9
+ label: false,
10
+ checkboxes_on_top: false
11
+ ) %>
12
+ </div>
13
+ <div class="columns mediumlarge-6 large-5">
14
+ <%= form.areas_select :area_id,
15
+ areas_for_select(current_organization),
16
+ legend_title: t("decidim.shared.participatory_space_filters.filters.areas"),
17
+ label: "",
18
+ selected: filter.area_id,
19
+ include_blank: t("decidim.shared.participatory_space_filters.filters.select_an_area") %>
20
+ </div>
21
+ <% end %>
22
+ <%= javascript_include_tag "decidim/filters" %>
@@ -0,0 +1,18 @@
1
+ <div class="filters-controls hide-for-mediumlarge">
2
+ <button data-open="filter-box" class="filters-controls__trigger">
3
+ <%= t("filter", scope: "decidim.searches.filters_small_view") %>
4
+ <%= icon "caret-bottom", class: "icon--small float-right", aria_label: t("unfold", scope: "decidim.searches.filters_small_view"), role: "img" %>
5
+ </button>
6
+ </div>
7
+
8
+ <div class="reveal" id="filter-box" data-reveal>
9
+ <div class="reveal__header">
10
+ <h3 class="reveal__title"><%= t("filter_by", scope: "decidim.searches.filters_small_view") %>:</h3>
11
+ <button class="close-button" data-close aria-label="<%= 't("close_modal", scope: "decidim.searches.filters_small_view")' %>" type="button">
12
+ <span aria-hidden="true">&times;</span>
13
+ </button>
14
+ </div>
15
+ <div class="filters">
16
+ <%= render :filters %>
17
+ </div>
18
+ </div>
@@ -0,0 +1,6 @@
1
+ <div class="row" id="participatory-space-filters">
2
+ <%= render :filters_small_view %>
3
+ <div class="show-for-mediumlarge">
4
+ <%= render :filters %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,7 @@
1
+ <section class="section" id="<%= block_id %>">
2
+ <%= render :title_filter_order %>
3
+ <%= render :participatory_space_filters %>
4
+ <div class="row small-up-1 medium-up-2 large-up-3 card-grid">
5
+ <%= cell "decidim/participatory_processes/filtered_participatory_processes", filtered_relation, default_filter: default_date_filter %>
6
+ </div>
7
+ </section>
@@ -0,0 +1,8 @@
1
+ <div class="processes-grid-order-by">
2
+ <%= cell(
3
+ "decidim/participatory_process_groups/process_filters",
4
+ participatory_process_group,
5
+ base_relation: filtered_relation,
6
+ default_filter: default_date_filter
7
+ ) %>
8
+ </div>
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ module ContentBlocks
6
+ class HighlightedParticipatoryProcessesCell < Decidim::ViewModel
7
+ include Decidim::CardHelper
8
+ include Decidim::IconHelper
9
+ include ActionView::Helpers::FormOptionsHelper
10
+ include Decidim::FiltersHelper
11
+ include Decidim::FilterResource
12
+
13
+ def participatory_process_group
14
+ @participatory_process_group ||= Decidim::ParticipatoryProcessGroup.find(model.scoped_resource_id)
15
+ end
16
+
17
+ def decidim_participatory_processes
18
+ Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
19
+ end
20
+
21
+ def block_id
22
+ "processes-grid"
23
+ end
24
+
25
+ def filtered_relation
26
+ @filtered_relation ||= search.results
27
+ end
28
+
29
+ def default_date_filter
30
+ return "active" if filtered_relation.any?(&:active?)
31
+ return "upcoming" if filtered_relation.any?(&:upcoming?)
32
+ return "past" if filtered_relation.any?(&:past?)
33
+
34
+ "all"
35
+ end
36
+
37
+ private
38
+
39
+ def search_klass
40
+ Decidim::ParticipatoryProcesses::ParticipatoryProcessSearch
41
+ end
42
+
43
+ def default_filter_params
44
+ {
45
+ scope_id: nil,
46
+ area_id: nil
47
+ }
48
+ end
49
+
50
+ def default_search_params
51
+ {
52
+ base_relation: base_relation
53
+ }
54
+ end
55
+
56
+ def base_relation
57
+ @base_relation ||= Decidim::ParticipatoryProcesses::GroupPublishedParticipatoryProcesses.new(
58
+ participatory_process_group,
59
+ current_user
60
+ ).query
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ <section class="section" id="<%= block_id %>">
2
+ <%= html_content %>
3
+ </section>
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ module ContentBlocks
6
+ class HtmlCell < Decidim::ContentBlocks::HtmlCell
7
+ def block_id
8
+ model.manifest_name.parameterize.gsub("_", "-")
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ <section class="section" id="participatory_process_group-metadata">
2
+ <article class="card card__row">
3
+ <div>
4
+ <div class="mb-xs"><strong><%= t("decidim.participatory_process_groups.content_blocks.metadata.developer_group") %></strong></div>
5
+ <div class="text-small">
6
+ <%= decidim_sanitize translated_attribute(participatory_process_group.developer_group) %>
7
+ </div>
8
+ </div>
9
+ <div>
10
+ <div class="mb-xs"><strong><%= t("decidim.participatory_process_groups.content_blocks.metadata.target") %></strong></div>
11
+ <div class="text-small">
12
+ <%= decidim_sanitize translated_attribute(participatory_process_group.target) %>
13
+ </div>
14
+ </div>
15
+ <div>
16
+ <div class="mb-xs"><strong><%= t("decidim.participatory_process_groups.content_blocks.metadata.participatory_scope") %></strong></div>
17
+ <div class="text-small">
18
+ <%= decidim_sanitize translated_attribute(participatory_process_group.participatory_scope) %>
19
+ </div>
20
+ </div>
21
+ <div>
22
+ <div class="mb-xs"><strong><%= t("decidim.participatory_process_groups.content_blocks.metadata.participatory_structure") %></strong></div>
23
+ <div class="text-small">
24
+ <%= decidim_sanitize translated_attribute(participatory_process_group.participatory_structure) %>
25
+ </div>
26
+ </div>
27
+ </article>
28
+ </section>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ module ContentBlocks
6
+ class MetadataCell < Decidim::ViewModel
7
+ include Decidim::SanitizeHelper
8
+
9
+ def participatory_process_group
10
+ @participatory_process_group ||= Decidim::ParticipatoryProcessGroup.find(model.scoped_resource_id)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ <section class="section" id="participatory_process_group-statistics">
2
+ <h2 class="section-heading">
3
+ <%= t("decidim.participatory_process_groups.content_blocks.stats.name") %>
4
+ </h2>
5
+
6
+ <div class="space-stats">
7
+ <% if stats.collection.present? %>
8
+ <%= cell("decidim/participatory_processes/statistic", collection: stats.collection) %>
9
+ <% else %>
10
+ <span class="muted"><%= t("decidim.participatory_processes.statistics.no_stats") %></span>
11
+ <% end %>
12
+ </div>
13
+ </section>
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ module ContentBlocks
6
+ class StatsCell < Decidim::ViewModel
7
+ def stats
8
+ @stats ||= Decidim::ParticipatoryProcesses::ParticipatoryProcessGroupStatsPresenter.new(participatory_process_group: participatory_process_group)
9
+ end
10
+
11
+ def participatory_process_group
12
+ @participatory_process_group ||= Decidim::ParticipatoryProcessGroup.find(model.scoped_resource_id)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,43 @@
1
+ <section class="section">
2
+ <h2 class="heading2"><%= translated_attribute(participatory_process_group.title) %></h2>
3
+ <div class="row">
4
+ <div class="columns medium-9">
5
+ <%= decidim_sanitize translated_attribute(participatory_process_group.description) %>
6
+ <div class="row">
7
+ <div class="column medium-2 text-muted">
8
+ <%= icon "grid-three-up", role: "img", class: "mr-xs" %>
9
+ <%= t("decidim.participatory_process_groups.content_blocks.title.participatory_processes", count: participatory_processes_count) %>
10
+ </div>
11
+ <% if has_meta_scope? %>
12
+ <div class="column medium-3 end text-muted">
13
+ <%= icon "globe", class: "mr-xs" %>
14
+ <strong><%= t("decidim.participatory_process_groups.content_blocks.title.meta_scope") %></strong>
15
+ <%= translated_attribute(meta_scope) %>
16
+ </div>
17
+ <% end %>
18
+ </div>
19
+ </div>
20
+ <div class="columns medium-3">
21
+ <% if has_hashtag? %>
22
+ <div class="mb-s text-muted">
23
+ <%= icon "twitter", role: "img", aria_label: "Twitter", class: "mr-xs" %>
24
+ <%= link_to(
25
+ "##{hashtag_text}",
26
+ "https://twitter.com/hashtag/#{hashtag_text}",
27
+ target: "_blank"
28
+ ) %>
29
+ </div>
30
+ <% end %>
31
+ <% if has_group_url? %>
32
+ <div class="text-muted">
33
+ <%= icon "external-link", class: "mr-xs" %>
34
+ <%= link_to(
35
+ group_url_text,
36
+ group_url,
37
+ target: "_blank"
38
+ ) %>
39
+ </div>
40
+ <% end %>
41
+ </div>
42
+ </div>
43
+ </section>
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ module ContentBlocks
6
+ class TitleCell < Decidim::ViewModel
7
+ include Decidim::SanitizeHelper
8
+ include Decidim::IconHelper
9
+
10
+ delegate :group_url, to: :participatory_process_group
11
+
12
+ def participatory_process_group
13
+ @participatory_process_group ||= Decidim::ParticipatoryProcessGroup.find(model.scoped_resource_id)
14
+ end
15
+
16
+ def hashtag_text
17
+ @hashtag_text ||= decidim_html_escape(participatory_process_group.hashtag || "")
18
+ end
19
+
20
+ def has_hashtag?
21
+ hashtag_text.present?
22
+ end
23
+
24
+ def has_group_url?
25
+ group_url.present?
26
+ end
27
+
28
+ def meta_scope
29
+ @meta_scope ||= translated_attribute(participatory_process_group.meta_scope)
30
+ end
31
+
32
+ def has_meta_scope?
33
+ meta_scope.present?
34
+ end
35
+
36
+ def group_url_text
37
+ group_uri.host + group_uri.path
38
+ end
39
+
40
+ def decidim_participatory_processes
41
+ Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
42
+ end
43
+
44
+ def participatory_processes_count
45
+ @participatory_processes_count ||= participatory_process_group.participatory_processes.count
46
+ end
47
+
48
+ private
49
+
50
+ def group_uri
51
+ @group_uri = URI.parse(group_url)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcessGroups
5
+ # This cell renders the filter tabs of participatory processes
6
+ # in a group. It's inherited from ProcessFiltersCell of participatory
7
+ # processes index but is based in the group processes
8
+ #
9
+ # The `model` must be a Decidim::ParticipatoryProcessGroup`
10
+ #
11
+ # Available options:
12
+ #
13
+ # - `:base_relation` => A relation of participatory processes. If not
14
+ # provided is based on the model processes using
15
+ # GroupPublishedParticipatoryProcesses query.
16
+ # - `default_date_filter` => The date filter to use if not given by
17
+ # params. If not provided is inferred from the base relation
18
+ #
19
+ # Example:
20
+ #
21
+ # cell(
22
+ # "decidim/participatory_process_groups/process_filters",
23
+ # group,
24
+ # base_relation: group.participatory_processes.published,
25
+ # date_filter: "active"
26
+ # )
27
+ class ProcessFiltersCell < Decidim::ParticipatoryProcesses::ProcessFiltersCell
28
+ def filter_link(filter)
29
+ Decidim::ParticipatoryProcesses::Engine
30
+ .routes
31
+ .url_helpers
32
+ .participatory_process_group_path(
33
+ model,
34
+ filter: {
35
+ scope_id: get_filter(:scope_id),
36
+ area_id: get_filter(:area_id),
37
+ date: filter
38
+ }
39
+ )
40
+ end
41
+
42
+ def current_filter
43
+ get_filter(:date, default_date_filter)
44
+ end
45
+
46
+ def base_relation
47
+ @base_relation ||= options[:base_relation].presence || Decidim::ParticipatoryProcesses::GroupPublishedParticipatoryProcesses.new(
48
+ model,
49
+ current_user
50
+ ).query
51
+ end
52
+
53
+ def process_count_by_filter
54
+ @process_count_by_filter ||= begin
55
+ counts = ALL_FILTERS.without("all").each_with_object({}) do |filter_name, collection_by_filter|
56
+ collection_by_filter.update(filter_name => filtered_processes(filter_name).results.count)
57
+ end
58
+ counts.update("all" => counts.values.sum)
59
+ end
60
+ end
61
+
62
+ def filtered_processes(date_filter)
63
+ Decidim::ParticipatoryProcesses::ParticipatoryProcessSearch.new(
64
+ base_relation: base_relation,
65
+ date: date_filter,
66
+ scope_id: get_filter(:scope_id),
67
+ area_id: get_filter(:area_id),
68
+ current_user: current_user,
69
+ organization: current_organization
70
+ )
71
+ end
72
+
73
+ def default_date_filter
74
+ @default_date_filter ||= options[:default_filter].presence || process_count_by_filter.find { |_, count| count.positive? }&.first || "all"
75
+ end
76
+ end
77
+ end
78
+ end