decidim-participatory_processes 0.26.10 → 0.27.0.rc1

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 +0 -4
  3. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/filters.erb +3 -3
  4. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes/show.erb +1 -0
  5. data/app/cells/decidim/participatory_process_groups/content_blocks/highlighted_participatory_processes_cell.rb +6 -11
  6. data/app/cells/decidim/participatory_process_groups/content_blocks/title/show.erb +1 -1
  7. data/app/cells/decidim/participatory_process_groups/content_blocks/title_cell.rb +1 -8
  8. data/app/cells/decidim/participatory_process_groups/process_filters_cell.rb +15 -18
  9. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/show.erb +1 -1
  10. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes/single_process.erb +1 -1
  11. data/app/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell.rb +1 -1
  12. data/app/cells/decidim/participatory_processes/filtered_participatory_processes_cell.rb +11 -7
  13. data/app/cells/decidim/participatory_processes/process_filters/show.erb +13 -9
  14. data/app/cells/decidim/participatory_processes/process_filters/type_filter.erb +17 -0
  15. data/app/cells/decidim/participatory_processes/process_filters_cell.rb +49 -21
  16. data/app/cells/decidim/participatory_processes/process_group_s/image.erb +1 -1
  17. data/app/cells/decidim/participatory_processes/process_s/image.erb +1 -1
  18. data/app/commands/decidim/participatory_processes/admin/activate_participatory_process_step.rb +1 -1
  19. data/app/commands/decidim/participatory_processes/admin/copy_participatory_process.rb +11 -8
  20. data/app/commands/decidim/participatory_processes/admin/create_participatory_process.rb +2 -1
  21. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_group.rb +1 -1
  22. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_step.rb +1 -1
  23. data/app/commands/decidim/participatory_processes/admin/create_participatory_process_type.rb +47 -0
  24. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_admin.rb +1 -6
  25. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_group.rb +1 -1
  26. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_step.rb +1 -1
  27. data/app/commands/decidim/participatory_processes/admin/destroy_participatory_process_type.rb +49 -0
  28. data/app/commands/decidim/participatory_processes/admin/import_participatory_process.rb +9 -6
  29. data/app/commands/decidim/participatory_processes/admin/notify_role_assigned_to_participatory_process.rb +1 -1
  30. data/app/commands/decidim/participatory_processes/admin/publish_participatory_process.rb +1 -1
  31. data/app/commands/decidim/participatory_processes/admin/reorder_participatory_process_steps.rb +1 -1
  32. data/app/commands/decidim/participatory_processes/admin/unpublish_participatory_process.rb +1 -1
  33. data/app/commands/decidim/participatory_processes/admin/update_participatory_process.rb +2 -1
  34. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_group.rb +1 -1
  35. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_step.rb +1 -1
  36. data/app/commands/decidim/participatory_processes/admin/update_participatory_process_type.rb +49 -0
  37. data/app/controllers/decidim/participatory_processes/admin/participatory_process_copies_controller.rb +1 -1
  38. data/app/controllers/decidim/participatory_processes/admin/participatory_process_groups_controller.rb +3 -2
  39. data/app/controllers/decidim/participatory_processes/admin/participatory_process_types_controller.rb +98 -0
  40. data/app/controllers/decidim/participatory_processes/admin/participatory_processes_controller.rb +1 -1
  41. data/app/controllers/decidim/participatory_processes/admin/reminders_controller.rb +14 -0
  42. data/app/controllers/decidim/participatory_processes/participatory_processes_controller.rb +8 -7
  43. data/app/events/decidim/participatory_process_role_assigned_event.rb +1 -1
  44. data/app/forms/decidim/participatory_processes/admin/participatory_process_form.rb +16 -0
  45. data/app/forms/decidim/participatory_processes/admin/participatory_process_import_form.rb +5 -7
  46. data/app/forms/decidim/participatory_processes/admin/participatory_process_type_form.rb +20 -0
  47. data/app/helpers/decidim/participatory_processes/participatory_process_helper.rb +2 -2
  48. data/app/models/decidim/participatory_process.rb +35 -6
  49. data/app/models/decidim/participatory_process_type.rb +27 -0
  50. data/app/permissions/decidim/participatory_processes/permissions.rb +14 -0
  51. data/app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb +27 -0
  52. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_presenter.rb +3 -2
  53. data/app/presenters/decidim/participatory_processes/admin_log/participatory_process_type_presenter.rb +38 -0
  54. data/app/presenters/decidim/participatory_processes/participatory_process_group_stats_presenter.rb +4 -1
  55. data/app/presenters/decidim/participatory_processes/participatory_process_metric_charts_presenter.rb +5 -1
  56. data/app/presenters/decidim/participatory_processes/participatory_process_stats_presenter.rb +4 -1
  57. data/app/queries/decidim/participatory_processes/admin/admin_users.rb +1 -1
  58. data/app/queries/decidim/participatory_processes/admin/moderators.rb +1 -1
  59. data/app/queries/decidim/participatory_processes/filtered_participatory_process_groups.rb +3 -5
  60. data/app/queries/decidim/participatory_processes/filtered_participatory_processes.rb +1 -1
  61. data/app/queries/decidim/participatory_processes/group_participatory_processes.rb +1 -1
  62. data/app/queries/decidim/participatory_processes/group_published_participatory_processes.rb +2 -2
  63. data/app/queries/decidim/participatory_processes/highlighted_participatory_processes.rb +1 -1
  64. data/app/queries/decidim/participatory_processes/organization_participatory_process_groups.rb +1 -1
  65. data/app/queries/decidim/participatory_processes/organization_participatory_processes.rb +1 -1
  66. data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_process_groups.rb +2 -2
  67. data/app/queries/decidim/participatory_processes/organization_prioritized_participatory_processes.rb +2 -2
  68. data/app/queries/decidim/participatory_processes/organization_promoted_participatory_process_groups.rb +1 -1
  69. data/app/queries/decidim/participatory_processes/organization_published_participatory_processes.rb +2 -2
  70. data/app/queries/decidim/participatory_processes/participatory_processes_by_group.rb +1 -1
  71. data/app/queries/decidim/participatory_processes/prioritized_participatory_processes.rb +1 -1
  72. data/app/queries/decidim/participatory_processes/promoted_participatory_process_groups.rb +1 -1
  73. data/app/queries/decidim/participatory_processes/promoted_participatory_processes.rb +1 -1
  74. data/app/queries/decidim/participatory_processes/published_participatory_processes.rb +1 -1
  75. data/app/queries/decidim/participatory_processes/stats_followers_count.rb +2 -2
  76. data/app/queries/decidim/participatory_processes/stats_participants_count.rb +2 -14
  77. data/app/queries/decidim/participatory_processes/visible_participatory_process_groups.rb +1 -1
  78. data/app/queries/decidim/participatory_processes/visible_participatory_processes.rb +1 -1
  79. data/app/serializers/decidim/participatory_processes/participatory_process_importer.rb +4 -15
  80. data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +1 -1
  81. data/app/views/decidim/participatory_processes/admin/participatory_process_copies/new.html.erb +2 -1
  82. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/_form.html.erb +1 -1
  83. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/edit.html.erb +0 -1
  84. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/index.html.erb +0 -1
  85. data/app/views/decidim/participatory_processes/admin/participatory_process_groups/new.html.erb +0 -1
  86. data/app/views/decidim/participatory_processes/admin/participatory_process_steps/_form.html.erb +1 -1
  87. data/app/views/decidim/participatory_processes/admin/participatory_process_types/_form.html.erb +11 -0
  88. data/app/views/decidim/participatory_processes/admin/participatory_process_types/edit.html.erb +9 -0
  89. data/app/views/decidim/participatory_processes/admin/participatory_process_types/index.html.erb +60 -0
  90. data/app/views/decidim/participatory_processes/admin/participatory_process_types/new.html.erb +9 -0
  91. data/app/views/decidim/participatory_processes/admin/participatory_processes/_form.html.erb +11 -1
  92. data/app/views/decidim/participatory_processes/admin/participatory_processes/index.html.erb +1 -0
  93. data/app/views/decidim/participatory_processes/admin/participatory_processes/new.html.erb +1 -0
  94. data/app/views/decidim/participatory_processes/participatory_process_groups/show.html.erb +3 -1
  95. data/app/views/decidim/participatory_processes/participatory_process_groups/show.js.erb +9 -6
  96. data/app/views/decidim/participatory_processes/participatory_process_steps/index.html.erb +1 -0
  97. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process.html.erb +1 -1
  98. data/app/views/decidim/participatory_processes/participatory_processes/_promoted_process_group.html.erb +1 -1
  99. data/app/views/decidim/participatory_processes/participatory_processes/index.html.erb +3 -1
  100. data/app/views/decidim/participatory_processes/participatory_processes/index.js.erb +3 -1
  101. data/app/views/decidim/participatory_processes/participatory_processes/show.html.erb +2 -2
  102. data/app/views/layouts/decidim/_process_header.html.erb +1 -1
  103. data/app/views/layouts/decidim/admin/participatory_process_type.html.erb +15 -0
  104. data/config/locales/am-ET.yml +1 -0
  105. data/config/locales/ar.yml +10 -13
  106. data/config/locales/bg.yml +1 -6
  107. data/config/locales/ca.yml +51 -16
  108. data/config/locales/cs.yml +62 -27
  109. data/config/locales/da.yml +1 -0
  110. data/config/locales/de.yml +20 -32
  111. data/config/locales/el.yml +9 -69
  112. data/config/locales/en.yml +42 -8
  113. data/config/locales/eo.yml +1 -0
  114. data/config/locales/es-MX.yml +46 -11
  115. data/config/locales/es-PY.yml +46 -11
  116. data/config/locales/es.yml +47 -12
  117. data/config/locales/et.yml +1 -0
  118. data/config/locales/eu.yml +121 -136
  119. data/config/locales/fi-plain.yml +48 -13
  120. data/config/locales/fi.yml +49 -14
  121. data/config/locales/fr-CA.yml +49 -14
  122. data/config/locales/fr.yml +51 -16
  123. data/config/locales/ga-IE.yml +1 -2
  124. data/config/locales/gl.yml +14 -10
  125. data/config/locales/hr.yml +1 -0
  126. data/config/locales/hu.yml +60 -136
  127. data/config/locales/id-ID.yml +10 -13
  128. data/config/locales/is-IS.yml +16 -6
  129. data/config/locales/it.yml +20 -15
  130. data/config/locales/ja.yml +53 -18
  131. data/config/locales/ko.yml +1 -0
  132. data/config/locales/lb.yml +8 -10
  133. data/config/locales/lt.yml +1 -505
  134. data/config/locales/lv.yml +10 -19
  135. data/config/locales/mt.yml +1 -0
  136. data/config/locales/nl.yml +16 -11
  137. data/config/locales/no.yml +36 -15
  138. data/config/locales/om-ET.yml +1 -0
  139. data/config/locales/pl.yml +19 -8
  140. data/config/locales/pt-BR.yml +14 -11
  141. data/config/locales/pt.yml +15 -10
  142. data/config/locales/ro-RO.yml +11 -15
  143. data/config/locales/ru.yml +10 -10
  144. data/config/locales/si-LK.yml +1 -0
  145. data/config/locales/sk.yml +11 -19
  146. data/config/locales/sl.yml +1 -3
  147. data/config/locales/so-SO.yml +1 -0
  148. data/config/locales/sr-CS.yml +1 -0
  149. data/config/locales/sv.yml +29 -13
  150. data/config/locales/sw-KE.yml +1 -0
  151. data/config/locales/ti-ER.yml +1 -0
  152. data/config/locales/tr-TR.yml +15 -10
  153. data/config/locales/uk.yml +10 -10
  154. data/config/locales/val-ES.yml +1 -0
  155. data/config/locales/vi.yml +1 -0
  156. data/config/locales/zh-CN.yml +10 -18
  157. data/config/locales/zh-TW.yml +1 -477
  158. data/db/migrate/20211125202008_create_decidim_participatory_process_types.rb +22 -0
  159. data/lib/decidim/api/participatory_process_type_type.rb +17 -0
  160. data/lib/decidim/participatory_processes/admin_engine.rb +12 -1
  161. data/lib/decidim/participatory_processes/api.rb +1 -0
  162. data/lib/decidim/participatory_processes/participatory_space.rb +17 -8
  163. data/lib/decidim/participatory_processes/query_extensions.rb +22 -0
  164. data/lib/decidim/participatory_processes/test/factories.rb +17 -4
  165. data/lib/decidim/participatory_processes/version.rb +1 -1
  166. metadata +31 -24
  167. data/app/services/decidim/participatory_processes/participatory_process_search.rb +0 -27
  168. data/config/environment.rb +0 -3
  169. data/config/locales/fa-IR.yml +0 -1
  170. data/config/locales/gn-PY.yml +0 -1
  171. data/config/locales/ka-GE.yml +0 -1
  172. data/config/locales/kaa.yml +0 -6
  173. data/config/locales/lo-LA.yml +0 -1
  174. data/config/locales/oc-FR.yml +0 -1
  175. data/config/locales/sq-AL.yml +0 -1
  176. data/config/locales/th-TH.yml +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a95c4d0dbdee61ca0400470956d3b0b480e4be7091348da82e03d489a19f816
4
- data.tar.gz: 5a1a992ef12a5d6fd4d86ebb91723887289b9617b69f47343c305754b239ebfd
3
+ metadata.gz: b7ad9fa0949340ca366968accdef04f3802a9db9feb5db05fb866ea3195b3765
4
+ data.tar.gz: 8e0d7f0ed95de5f80c855b54b5d9f490bc35defd151f255fc06f00548fd87595
5
5
  SHA512:
6
- metadata.gz: d810a6e0b52bf343a8f7aeda9a2575496a63a45186081a06a0fac4bd0e0e9edd25896cf4ae73e1c2e00f50681eb525880c76f9e7a96f88c589b95662fe934411
7
- data.tar.gz: 347e436a64905691288c5f0bcc2e5c2490bec19f1b903bc1f04ef29205697e12817a1dd8025ba374efedb45003402dfa5bb0dfd3b587b455d29e8ecad6a73859
6
+ metadata.gz: c449ea83582883a26d1b7426d31c9abc30012bc1e3acd4cb266dceff6fc1dc62ae2471a78ddf588c4196c06b517ec1b158be722c03b8fc5a3ac7facb7e439005
7
+ data.tar.gz: a35d3a5af6ec6c3293e3f4a8a93032653d67c493206b344c291b66aa4815bc4330224c6b309a488256254eef018e60ad90c60eb803d4b0039e02e3c392d74ac5
data/README.md CHANGED
@@ -33,10 +33,6 @@ This is on the default Decidim installation so you shouldn't change anything to
33
33
 
34
34
  ![Admin View](docs/screenshot02.png)
35
35
 
36
- ## Documentation
37
-
38
- Read more about this Space on [Admin Manual](https://docs.decidim.org/admin-manual/en/processess/).
39
-
40
36
  ## Contributing
41
37
 
42
38
  See [Decidim](https://github.com/decidim/decidim).
@@ -3,7 +3,7 @@
3
3
  <%= cell(
4
4
  "decidim/scopes_picker",
5
5
  form,
6
- attribute: :scope_id,
6
+ attribute: :with_scope,
7
7
  multiple: true,
8
8
  legend_title: I18n.t("decidim.scopes.scopes"),
9
9
  label: false,
@@ -11,11 +11,11 @@
11
11
  ) %>
12
12
  </div>
13
13
  <div class="columns mediumlarge-6 large-5">
14
- <%= form.areas_select :area_id,
14
+ <%= form.areas_select :with_area,
15
15
  areas_for_select(current_organization),
16
16
  legend_title: t("decidim.shared.participatory_space_filters.filters.areas"),
17
17
  label: "",
18
- selected: filter.area_id,
18
+ selected: filter.with_area,
19
19
  include_blank: t("decidim.shared.participatory_space_filters.filters.select_an_area") %>
20
20
  </div>
21
21
  <% end %>
@@ -1,6 +1,7 @@
1
1
  <section class="section" id="<%= block_id %>">
2
2
  <%= render :title_filter_order %>
3
3
  <%= render :participatory_space_filters %>
4
+ <p class="loading"><%= t("loading", scope: "decidim.participatory_processes.participatory_processes.index") %></p>
4
5
  <div class="row small-up-1 medium-up-2 large-up-3 card-grid">
5
6
  <%= cell "decidim/participatory_processes/filtered_participatory_processes", filtered_relation, default_filter: default_date_filter %>
6
7
  </div>
@@ -23,7 +23,7 @@ module Decidim
23
23
  end
24
24
 
25
25
  def filtered_relation
26
- @filtered_relation ||= search.results
26
+ @filtered_relation ||= search.result
27
27
  end
28
28
 
29
29
  def default_date_filter
@@ -36,20 +36,15 @@ module Decidim
36
36
 
37
37
  private
38
38
 
39
- def search_klass
40
- Decidim::ParticipatoryProcesses::ParticipatoryProcessSearch
39
+ def search_collection
40
+ base_relation
41
41
  end
42
42
 
43
43
  def default_filter_params
44
44
  {
45
- scope_id: nil,
46
- area_id: nil
47
- }
48
- end
49
-
50
- def default_search_params
51
- {
52
- base_relation: base_relation
45
+ with_scope: nil,
46
+ with_area: nil,
47
+ with_type: nil
53
48
  }
54
49
  end
55
50
 
@@ -2,7 +2,7 @@
2
2
  <h2 class="heading2"><%= translated_attribute(participatory_process_group.title) %></h2>
3
3
  <div class="row">
4
4
  <div class="columns medium-9">
5
- <%= decidim_sanitize_editor_admin translated_attribute(participatory_process_group.description) %>
5
+ <%= decidim_sanitize_editor translated_attribute(participatory_process_group.description) %>
6
6
  <div class="row">
7
7
  <div class="column medium-6 text-muted">
8
8
  <%= icon "grid-three-up", role: "img", "aria-hidden": true, class: "mr-xs" %>
@@ -43,18 +43,11 @@ module Decidim
43
43
  end
44
44
 
45
45
  def participatory_processes_count
46
- @participatory_processes_count ||= processes.count
46
+ @participatory_processes_count ||= participatory_process_group.participatory_processes.count
47
47
  end
48
48
 
49
49
  private
50
50
 
51
- def processes
52
- @processes ||= Decidim::ParticipatoryProcesses::GroupPublishedParticipatoryProcesses.new(
53
- participatory_process_group,
54
- current_user
55
- ).query
56
- end
57
-
58
51
  def group_uri
59
52
  @group_uri = URI.parse(group_url)
60
53
  end
@@ -25,22 +25,15 @@ module Decidim
25
25
  # date_filter: "active"
26
26
  # )
27
27
  class ProcessFiltersCell < Decidim::ParticipatoryProcesses::ProcessFiltersCell
28
- def filter_link(filter)
28
+ def filter_link(date_filter, type_filter = nil)
29
29
  Decidim::ParticipatoryProcesses::Engine
30
30
  .routes
31
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
- )
32
+ .participatory_process_group_path(model, **filter_params(date_filter, type_filter))
40
33
  end
41
34
 
42
35
  def current_filter
43
- get_filter(:date, default_date_filter)
36
+ get_filter(:with_date, default_date_filter)
44
37
  end
45
38
 
46
39
  def base_relation
@@ -53,21 +46,25 @@ module Decidim
53
46
  def process_count_by_filter
54
47
  @process_count_by_filter ||= begin
55
48
  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)
49
+ collection_by_filter.update(filter_name => filtered_processes(filter_name).count)
57
50
  end
58
51
  counts.update("all" => counts.values.sum)
59
52
  end
60
53
  end
61
54
 
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),
55
+ def filtered_processes(date_filter, filter_with_type: true)
56
+ query = base_relation.ransack(
57
+ {
58
+ with_date: date_filter,
59
+ with_scope: get_filter(:with_scope),
60
+ with_area: get_filter(:with_area),
61
+ with_type: filter_with_type ? get_filter(:with_type) : nil
62
+ },
68
63
  current_user: current_user,
69
64
  organization: current_organization
70
- )
65
+ ).result
66
+
67
+ query.published.visible_for(current_user)
71
68
  end
72
69
 
73
70
  def default_date_filter
@@ -1,4 +1,4 @@
1
- <section class="wrapper-home home-section">
1
+ <section id="highlighted_processes" class="wrapper-home home-section">
2
2
  <div class="row" id="highlighted-processes">
3
3
  <h3 class="section-heading"><%= t("active_processes", scope: i18n_scope) %></h3>
4
4
  <div class="row collapse">
@@ -22,7 +22,7 @@
22
22
  </div>
23
23
  </div>
24
24
  <div class="column large-6 card--process__column">
25
- <div class="card--full__image" style="background-image:url('<%= process.attached_uploader(:hero_image).path %>')">
25
+ <div class="card--full__image" style="background-image:url(<%= process.attached_uploader(:hero_image).path %>)">
26
26
  <div class="card__content row collapse">
27
27
  <div class="large-6 large-offset-6 columns">
28
28
  <%= link_to decidim_participatory_processes.participatory_process_path(process), class: "button expanded button--sc" do %>
@@ -51,7 +51,7 @@ module Decidim
51
51
  OrganizationPublishedParticipatoryProcesses.new(current_organization, current_user) |
52
52
  HighlightedParticipatoryProcesses.new |
53
53
  FilteredParticipatoryProcesses.new("active")
54
- ).query.includes([:organization]).limit(highlighted_processes_max_results)
54
+ ).query.with_attached_hero_image.includes([:organization, :hero_image_attachment]).limit(highlighted_processes_max_results)
55
55
  end
56
56
  end
57
57
 
@@ -17,26 +17,30 @@ module Decidim
17
17
  # cell(
18
18
  # "decidim/participatory_processes/filtered_participatory_processes",
19
19
  # group.participatory_processes.published,
20
- # date_filter: "active"
20
+ # default_filter: "active"
21
21
  # )
22
22
  class FilteredParticipatoryProcessesCell < Decidim::ViewModel
23
23
  include Decidim::FilterResource
24
24
  include Decidim::CardHelper
25
25
 
26
26
  def elements
27
- @elements ||= search.results
27
+ @elements ||= search.result
28
28
  end
29
29
 
30
30
  private
31
31
 
32
- def search_klass
33
- Decidim::ParticipatoryProcesses::ParticipatoryProcessSearch
32
+ def search_collection
33
+ base_relation.published.visible_for(current_user).includes(:area)
34
34
  end
35
35
 
36
- def default_search_params
36
+ def base_relation
37
+ model
38
+ end
39
+
40
+ def default_filter_params
37
41
  {
38
- base_relation: model,
39
- date: default_date_filter
42
+ with_date: default_date_filter,
43
+ with_type: nil
40
44
  }
41
45
  end
42
46
 
@@ -1,13 +1,17 @@
1
- <div class="row collapse order-by">
2
- <h3 class="order-by__text section-heading">
3
- <%= title %>
4
- <%= render :filter_tabs %>
5
- </h3>
6
- </div>
7
- <% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
8
1
  <div class="row column">
9
- <div class="callout warning mb-sm">
10
- <p><%= t("decidim.participatory_processes.participatory_processes.filters.explanations.no_active_nor_upcoming_callout") %></p>
2
+ <div class="flex--sbe">
3
+ <h3 class="section-heading collapse">
4
+ <%= title %>
5
+ <%= render :filter_tabs %>
6
+ </h3>
7
+ <%= render :type_filter if participatory_process_types_for_select.present? %>
11
8
  </div>
9
+ <hr class="reset mt-s mb-s">
12
10
  </div>
11
+ <% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
12
+ <div class="row column">
13
+ <div class="callout warning mb-sm">
14
+ <p><%= t("decidim.participatory_processes.participatory_processes.filters.explanations.no_active_nor_upcoming_callout") %></p>
15
+ </div>
16
+ </div>
13
17
  <% end %>
@@ -0,0 +1,17 @@
1
+ <div id="process-type-filter" class="inline-filters">
2
+ <div id="inline-filter-sort" class="dropdown-pane" data-position="bottom" data-alignment="right" data-dropdown data-auto-focus="true">
3
+ <ul class="list-reset">
4
+ <% participatory_process_types_for_select.each do |title, id| %>
5
+ <li>
6
+ <%= link_to filter_link(current_filter, id), remote: true do %>
7
+ <%= title %>
8
+ <% end %>
9
+ </li>
10
+ <% end %>
11
+ </ul>
12
+ </div>
13
+ <label>
14
+ <span><%= filter_type_label %></span>
15
+ <button id="button-text" data-toggle="inline-filter-sort"><%= current_type_filter_name %></button>
16
+ </label>
17
+ </div>
@@ -5,48 +5,57 @@ module Decidim
5
5
  class ProcessFiltersCell < Decidim::ViewModel
6
6
  ALL_FILTERS = %w(active upcoming past all).freeze
7
7
 
8
- def filter_link(filter)
8
+ def filter_link(date_filter, type_filter = nil)
9
9
  Decidim::ParticipatoryProcesses::Engine
10
10
  .routes
11
11
  .url_helpers
12
- .participatory_processes_path(
13
- filter: {
14
- scope_id: get_filter(:scope_id),
15
- area_id: get_filter(:area_id),
16
- date: filter
17
- }
18
- )
12
+ .participatory_processes_path(**filter_params(date_filter, type_filter))
19
13
  end
20
14
 
21
15
  def current_filter
22
- date_filter = get_filter(:date)
23
- return model[:default_filter] unless date_filter
24
- return date_filter if ALL_FILTERS.include?(date_filter)
16
+ get_filter(:with_date, model[:default_filter])
17
+ end
25
18
 
26
- # Default to "all" in case the filter is unknown, as the search also
27
- # defaults to this.
28
- "all"
19
+ def current_type_filter_name
20
+ participatory_process_types_for_select.find { |_, id| id == get_filter(:with_type) }&.first ||
21
+ I18n.t("all_types", scope: "decidim.participatory_processes.participatory_processes.filters")
29
22
  end
30
23
 
31
24
  def get_filter(filter_name, default = nil)
32
25
  params&.dig(:filter, filter_name) || default
33
26
  end
34
27
 
35
- def filtered_processes(date_filter)
36
- ParticipatoryProcessSearch.new(
37
- date: date_filter,
38
- scope_id: get_filter(:scope_id),
39
- area_id: get_filter(:area_id),
28
+ def filter_params(date_filter, type_filter)
29
+ {
30
+ filter: {
31
+ with_date: date_filter,
32
+ with_scope: get_filter(:with_scope),
33
+ with_area: get_filter(:with_area),
34
+ with_type: type_filter || get_filter(:with_type)
35
+ }
36
+ }
37
+ end
38
+
39
+ def filtered_processes(date_filter, filter_with_type: true)
40
+ query = ParticipatoryProcess.ransack(
41
+ {
42
+ with_date: date_filter,
43
+ with_scope: get_filter(:with_scope),
44
+ with_area: get_filter(:with_area),
45
+ with_type: filter_with_type ? get_filter(:with_type) : nil
46
+ },
40
47
  current_user: current_user,
41
48
  organization: current_organization
42
- )
49
+ ).result
50
+
51
+ query.published.visible_for(current_user)
43
52
  end
44
53
 
45
54
  def process_count_by_filter
46
55
  return @process_count_by_filter if @process_count_by_filter
47
56
 
48
57
  @process_count_by_filter = %w(active upcoming past).inject({}) do |collection_by_filter, filter_name|
49
- filtered_processes = filtered_processes(filter_name).results
58
+ filtered_processes = filtered_processes(filter_name)
50
59
  processes = filtered_processes.groupless
51
60
  groups = Decidim::ParticipatoryProcessGroup.where(id: filtered_processes.grouped.group_ids)
52
61
  collection_by_filter.merge(filter_name => processes.count + groups.count)
@@ -73,6 +82,10 @@ module Decidim
73
82
  I18n.t(current_filter, scope: "decidim.participatory_processes.participatory_processes.filters.counters", count: process_count_by_filter[current_filter])
74
83
  end
75
84
 
85
+ def filter_type_label
86
+ I18n.t("filter_by", scope: "decidim.participatory_processes.participatory_processes.filters")
87
+ end
88
+
76
89
  def filter_name(filter)
77
90
  I18n.t(filter, scope: "decidim.participatory_processes.participatory_processes.filters.names")
78
91
  end
@@ -92,6 +105,21 @@ module Decidim
92
105
 
93
106
  "no_active_nor_upcoming"
94
107
  end
108
+
109
+ def participatory_process_types
110
+ @participatory_process_types ||= Decidim::ParticipatoryProcessType.joins(:processes).where(
111
+ decidim_participatory_processes: { id: filtered_processes(current_filter, filter_with_type: false) }
112
+ ).distinct
113
+ end
114
+
115
+ def participatory_process_types_for_select
116
+ return if participatory_process_types.blank?
117
+
118
+ [[I18n.t("all_types", scope: "decidim.participatory_processes.participatory_processes.filters"), ""]] +
119
+ participatory_process_types.map do |type|
120
+ [translated_attribute(type.title), type.id.to_s]
121
+ end
122
+ end
95
123
  end
96
124
  end
97
125
  end
@@ -1 +1 @@
1
- <div aria-hidden="true" class="card__image-top" style="background-image:url('<%= resource_image_path %>')"></div>
1
+ <div aria-hidden="true" class="card__image-top" style="background-image:url(<%= resource_image_path %>)"></div>
@@ -1 +1 @@
1
- <div aria-hidden="true" class="card__image-top" style="background-image:url('<%= resource_image_path %>')"></div>
1
+ <div aria-hidden="true" class="card__image-top" style="background-image:url(<%= resource_image_path %>)"></div>
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command that sets a step in a participatory process as active (and
7
7
  # unsets a previous active step)
8
- class ActivateParticipatoryProcessStep < Rectify::Command
8
+ class ActivateParticipatoryProcessStep < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # step - A ParticipatoryProcessStep that will be activated
@@ -5,14 +5,15 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when copying a new participatory
7
7
  # process in the system.
8
- class CopyParticipatoryProcess < Rectify::Command
8
+ class CopyParticipatoryProcess < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
12
12
  # participatory_process - A participatory_process we want to duplicate
13
- def initialize(form, participatory_process)
13
+ def initialize(form, participatory_process, current_user)
14
14
  @form = form
15
15
  @participatory_process = participatory_process
16
+ @current_user = current_user
16
17
  end
17
18
 
18
19
  # Executes the command. Broadcasts these events:
@@ -24,12 +25,14 @@ module Decidim
24
25
  def call
25
26
  return broadcast(:invalid) if form.invalid?
26
27
 
27
- ParticipatoryProcess.transaction do
28
- copy_participatory_process
29
- copy_participatory_process_attachments
30
- copy_participatory_process_steps if @form.copy_steps?
31
- copy_participatory_process_categories if @form.copy_categories?
32
- copy_participatory_process_components if @form.copy_components?
28
+ Decidim.traceability.perform_action!("duplicate", @participatory_process, @current_user) do
29
+ ParticipatoryProcess.transaction do
30
+ copy_participatory_process
31
+ copy_participatory_process_attachments
32
+ copy_participatory_process_steps if @form.copy_steps?
33
+ copy_participatory_process_categories if @form.copy_categories?
34
+ copy_participatory_process_components if @form.copy_components?
35
+ end
33
36
  end
34
37
 
35
38
  broadcast(:ok, @copied_process)
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process in the system.
8
- class CreateParticipatoryProcess < Rectify::Command
8
+ class CreateParticipatoryProcess < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -89,6 +89,7 @@ module Decidim
89
89
  start_date: form.start_date,
90
90
  end_date: form.end_date,
91
91
  participatory_process_group: form.participatory_process_group,
92
+ participatory_process_type: form.participatory_process_type,
92
93
  show_metrics: form.show_metrics,
93
94
  show_statistics: form.show_statistics,
94
95
  announcement: form.announcement
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process group in the system.
8
- class CreateParticipatoryProcessGroup < Rectify::Command
8
+ class CreateParticipatoryProcessGroup < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when creating a new participatory
7
7
  # process in the system.
8
- class CreateParticipatoryProcessStep < Rectify::Command
8
+ class CreateParticipatoryProcessStep < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # form - A form object with the params.
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # A command with all the business logic when creating a new participatory
7
+ # process type in the system.
8
+ class CreateParticipatoryProcessType < Decidim::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # form - A form object with the params.
12
+ def initialize(form)
13
+ @form = form
14
+ end
15
+
16
+ # Executes the command. Broadcasts these events:
17
+ #
18
+ # - :ok when everything is valid.
19
+ # - :invalid if the form wasn't valid and we couldn't proceed.
20
+ #
21
+ # Returns nothing.
22
+ def call
23
+ return broadcast(:invalid) if form.invalid?
24
+
25
+ create_participatory_process_type!
26
+
27
+ broadcast(:ok)
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :form
33
+
34
+ def create_participatory_process_type!
35
+ transaction do
36
+ Decidim.traceability.create!(
37
+ Decidim::ParticipatoryProcessType,
38
+ form.current_user,
39
+ organization: form.current_organization,
40
+ title: form.title
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -5,7 +5,7 @@ module Decidim
5
5
  module Admin
6
6
  # A command with all the business logic when destroying a participatory
7
7
  # process admin in the system.
8
- class DestroyParticipatoryProcessAdmin < Rectify::Command
8
+ class DestroyParticipatoryProcessAdmin < Decidim::Command
9
9
  # Public: Initializes the command.
10
10
  #
11
11
  # role - the ParticipatoryProcessUserRole to destroy
@@ -23,7 +23,6 @@ module Decidim
23
23
  # Returns nothing.
24
24
  def call
25
25
  destroy_role!
26
- dispatch_system_event
27
26
  broadcast(:ok)
28
27
  end
29
28
 
@@ -31,10 +30,6 @@ module Decidim
31
30
 
32
31
  attr_reader :role, :current_user
33
32
 
34
- def dispatch_system_event
35
- ActiveSupport::Notifications.publish("decidim.system.participatory_space.admin.destroyed", role.class.name, role.id)
36
- end
37
-
38
33
  def destroy_role!
39
34
  extra_info = {
40
35
  resource: {
@@ -4,7 +4,7 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module Admin
6
6
  # A command with all the business logic when deleting a ParticipatoryProcessGroup.
7
- class DestroyParticipatoryProcessGroup < Rectify::Command
7
+ class DestroyParticipatoryProcessGroup < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # participatory_process_group - the ParticipatoryProcessGroup to delete.
@@ -4,7 +4,7 @@ module Decidim
4
4
  module ParticipatoryProcesses
5
5
  module Admin
6
6
  # A command that sets all steps in a participatory process as inactive
7
- class DestroyParticipatoryProcessStep < Rectify::Command
7
+ class DestroyParticipatoryProcessStep < Decidim::Command
8
8
  # Public: Initializes the command.
9
9
  #
10
10
  # step - A ParticipatoryProcessStep that will be deactivated
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module ParticipatoryProcesses
5
+ module Admin
6
+ # A command with all the business logic when destroying a participatory
7
+ # process type in the system.
8
+ class DestroyParticipatoryProcessType < Decidim::Command
9
+ # Public: Initializes the command.
10
+ #
11
+ # participatory_process_type - A participatory_process_type object to
12
+ # destroy
13
+ # current_user - the user performing the action
14
+ def initialize(participatory_process_type, current_user)
15
+ @participatory_process_type = participatory_process_type
16
+ @current_user = current_user
17
+ end
18
+
19
+ # Executes the command. Broadcasts these events:
20
+ #
21
+ # - :ok when everything is valid.
22
+ # - :invalid if the form wasn't valid and we couldn't proceed.
23
+ #
24
+ # Returns nothing.
25
+ def call
26
+ destroy_participatory_process_type!
27
+
28
+ broadcast(:ok)
29
+ end
30
+
31
+ private
32
+
33
+ attr_reader :current_user
34
+
35
+ def destroy_participatory_process_type!
36
+ transaction do
37
+ Decidim.traceability.perform_action!(
38
+ "delete",
39
+ @participatory_process_type,
40
+ current_user
41
+ ) do
42
+ @participatory_process_type.destroy!
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end