From bd1f67d3bdcd17fcec53d30fef7628c37042d6cb Mon Sep 17 00:00:00 2001 From: Robin Steiner Date: Tue, 19 Mar 2024 13:52:59 +0100 Subject: [PATCH 1/3] Revert participatory process grouping --- .../process_filters/filter_tabs.erb | 15 --------- .../process_filters_cell.rb | 32 ------------------- ...icipatory_processes_controller_override.rb | 23 ------------- ...ay_process_groups_override.html.erb.deface | 19 ----------- .../participatory_processes/index.js.erb | 10 ------ .../decidim_zuerich_customization.rb | 1 - 6 files changed, 100 deletions(-) delete mode 100644 app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb delete mode 100644 app/cells/decidim_zuerich/participatory_processes/process_filters_cell.rb delete mode 100644 app/overrides/controllers/decidim/participatory_processes/participatory_processes_controller_override.rb delete mode 100644 app/overrides/decidim/participatory_processes/participatory_processes/index/display_process_groups_override.html.erb.deface diff --git a/app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb b/app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb deleted file mode 100644 index 70bde2c9..00000000 --- a/app/cells/decidim/participatory_processes/process_filters/filter_tabs.erb +++ /dev/null @@ -1,15 +0,0 @@ - - <% if should_show_tabs? %> - <%= explanation %> - <%= t("decidim.participatory_processes.participatory_processes.filters.see") %> - <% other_filters_with_value.each do |filter| %> - <%= link_to filter_link(filter), class: "order-by__tab" do %> - - <%= filter_name(filter) %> -  (<%= process_count_by_filter[filter] %>) - <% end %> - <% end %> - <% else %> - <%= explanation %> - <% end %> - diff --git a/app/cells/decidim_zuerich/participatory_processes/process_filters_cell.rb b/app/cells/decidim_zuerich/participatory_processes/process_filters_cell.rb deleted file mode 100644 index dcc5def0..00000000 --- a/app/cells/decidim_zuerich/participatory_processes/process_filters_cell.rb +++ /dev/null @@ -1,32 +0,0 @@ -# frozen_string_literal: true - -# Override last checked at: 31.07.2023 -# TODO: @cbeltrame, check for 0.27.4 upgrade - -module DecidimZuerich - module ParticipatoryProcesses - module ProcessFiltersCell - def other_filters_with_value - [current_filter] + super - end - - def title - # Remove the title text explaining how many processes are displayed. - # This wouldn't be accurate because we are grouping processes by process groups. - '' - end - - # Replace the implementation of this method, because we don't want process groups to - def process_count_by_filter - return @process_count_by_filter if @process_count_by_filter - - @process_count_by_filter = %w(active upcoming past).inject({}) do |collection_by_filter, filter_name| - filtered_processes = filtered_processes(filter_name) - collection_by_filter.merge(filter_name => filtered_processes.count) - end - @process_count_by_filter["all"] = @process_count_by_filter.values.sum - @process_count_by_filter - end - end - end -end diff --git a/app/overrides/controllers/decidim/participatory_processes/participatory_processes_controller_override.rb b/app/overrides/controllers/decidim/participatory_processes/participatory_processes_controller_override.rb deleted file mode 100644 index 784e5f69..00000000 --- a/app/overrides/controllers/decidim/participatory_processes/participatory_processes_controller_override.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -# Override last checked at: 31.07.2023 -Decidim::ParticipatoryProcesses::ParticipatoryProcessesController.class_eval do - helper_method :participatory_process_groups, - :filtered_processes, - :participatory_processes, - :has_landing_page - - private - - def collection - # Don't include process groups in this list - @collection ||= participatory_processes - end - - def has_landing_page(process_group) - Decidim::ContentBlock - .published - .for_scope(:participatory_process_group_homepage, organization: current_organization) - .exists?(scoped_resource_id: process_group.id) - end -end diff --git a/app/overrides/decidim/participatory_processes/participatory_processes/index/display_process_groups_override.html.erb.deface b/app/overrides/decidim/participatory_processes/participatory_processes/index/display_process_groups_override.html.erb.deface deleted file mode 100644 index 4e6ac4ca..00000000 --- a/app/overrides/decidim/participatory_processes/participatory_processes/index/display_process_groups_override.html.erb.deface +++ /dev/null @@ -1,19 +0,0 @@ - - <%# Overridden view from decidim, for displaying process groups specially, issue #246 %> -
- <%= render partial: "order_by_processes" %> -
- <%= render partial: "decidim/shared/participatory_space_filters/show" %> - -
- <%= render partial: "process_groups" %> -
- -
-

<%= t(".loading") %>

-
- <%= render(collection) %> -
-
\ No newline at end of file diff --git a/app/views/decidim/participatory_processes/participatory_processes/index.js.erb b/app/views/decidim/participatory_processes/participatory_processes/index.js.erb index b337a454..e69de29b 100644 --- a/app/views/decidim/participatory_processes/participatory_processes/index.js.erb +++ b/app/views/decidim/participatory_processes/participatory_processes/index.js.erb @@ -1,10 +0,0 @@ -var $order_by_filters = $('#processes-grid-order-by'); -var $process_groups = $('#process-groups'); -var $grid = $('#processes-grid'); -var $loading = $grid.find('.loading'); - -$order_by_filters.html('<%= j(render(partial: "decidim/participatory_processes/participatory_processes/order_by_processes", locals: { include_filter: true })).strip.html_safe %>'); -$process_groups.html('<%= j(render(partial: "decidim/participatory_processes/participatory_processes/process_groups")) %>') -$grid.find('.card-grid').html('<%= j(render(collection)).strip.html_safe %>'); -$order_by_filters.foundation(); -$loading.hide(); diff --git a/config/initializers/decidim_zuerich_customization.rb b/config/initializers/decidim_zuerich_customization.rb index 1990a34b..c7ebf627 100644 --- a/config/initializers/decidim_zuerich_customization.rb +++ b/config/initializers/decidim_zuerich_customization.rb @@ -23,7 +23,6 @@ [Decidim::ParticipatoryProcesses::Permissions, DecidimZuerich::ParticipatoryProcesses::Permissions], [Decidim::Proposals::DiffRenderer, DecidimZuerich::Proposals::DiffRenderer], [Decidim::Proposals::MapHelper, DecidimZuerich::Proposals::MapHelper], - [Decidim::ParticipatoryProcesses::ProcessFiltersCell, DecidimZuerich::ParticipatoryProcesses::ProcessFiltersCell], [Decidim::ResourceLocatorPresenter, DecidimZuerich::ResourceLocatorPresenter], [Decidim::ParticipatoryProcesses::ParticipatoryProcessHelper, DecidimZuerich::ParticipatoryProcesses::ParticipatoryProcessHelper], [Decidim::System::RegisterOrganization, DecidimZuerich::System::RegisterOrganization], From b834916112740793120c102d654b391671e4083c Mon Sep 17 00:00:00 2001 From: Robin Steiner Date: Fri, 22 Mar 2024 10:06:19 +0100 Subject: [PATCH 2/3] Delete unused files, in turn fixing filters --- .../_process_groups.html.erb | 18 ------------------ .../participatory_processes/index.js.erb | 0 2 files changed, 18 deletions(-) delete mode 100644 app/views/decidim/participatory_processes/participatory_processes/_process_groups.html.erb delete mode 100644 app/views/decidim/participatory_processes/participatory_processes/index.js.erb diff --git a/app/views/decidim/participatory_processes/participatory_processes/_process_groups.html.erb b/app/views/decidim/participatory_processes/participatory_processes/_process_groups.html.erb deleted file mode 100644 index 2aca2ff9..00000000 --- a/app/views/decidim/participatory_processes/participatory_processes/_process_groups.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% participatory_process_groups.each do |process_group| %> -

- <% if has_landing_page(process_group) %> - <%= link_to translated_attribute(process_group.title), participatory_process_group_path(process_group) %> - <% else %> - <%= translated_attribute(process_group.title) %> - <% end %> -

-
- <%= render(process_group.participatory_processes.where(id: filtered_processes)) %> -
- <% if has_landing_page(process_group) %> -
- <%= link_to t("decidim.participatory_processes.index.participatory_process_group.more_info"), participatory_process_group_path(process_group), class: 'button button--sc pull-right' %> -
- <% end %> -
-<% end %> \ No newline at end of file diff --git a/app/views/decidim/participatory_processes/participatory_processes/index.js.erb b/app/views/decidim/participatory_processes/participatory_processes/index.js.erb deleted file mode 100644 index e69de29b..00000000 From bec5f59391ccf4d3b98a680686a1eeb685955e71 Mon Sep 17 00:00:00 2001 From: Robin Steiner Date: Tue, 26 Mar 2024 16:10:50 +0100 Subject: [PATCH 3/3] Fix selected pill with an override --- .../process_filters_cell_override.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/overrides/cells/decidim/participatory_processes/process_filters_cell_override.rb diff --git a/app/overrides/cells/decidim/participatory_processes/process_filters_cell_override.rb b/app/overrides/cells/decidim/participatory_processes/process_filters_cell_override.rb new file mode 100644 index 00000000..4566a070 --- /dev/null +++ b/app/overrides/cells/decidim/participatory_processes/process_filters_cell_override.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +# We would love to do a prepend instead of what is happening here +# For whatever reason though the prepend never properly works +# Even if we include the module it doesn't get loaded +# Must be some crazy loading shenanigans +# Pry-ing into the customization class and using the following commands might be useful for future debugging: +# $ -a Decidim::ParticipatoryProcesses::ProcessFiltersCell +# $ -a DecidimZuerich::ParticipatoryProcesses::ProcessFiltersCell +Decidim::ParticipatoryProcesses::ProcessFiltersCell.class_eval do + def other_filters_with_value + @other_filters_with_value ||= [current_filter] + other_filters.select do |filter| + process_count_by_filter[filter].positive? + end + end +end \ No newline at end of file