diff --git a/Gemfile b/Gemfile
index e3809640..a0745ee0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -12,7 +12,7 @@ gem "decidim-templates", DECIDIM_VERSION
gem "decidim-home", path: "decidim-home"
gem "decidim-process-extended", path: "decidim-process-extended"
gem "decidim-recaptcha", path: "decidim-recaptcha"
-# gem "decidim-regulations", path: "decidim-regulations"
+gem "decidim-regulations", path: "decidim-regulations"
gem "decidim-top_comments", path: "decidim-top_comments"
gem "decidim-cdtb"
diff --git a/Gemfile.lock b/Gemfile.lock
index 3daf504c..60bb61ad 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -191,6 +191,12 @@ PATH
decidim-recaptcha (0.1.0)
decidim-core (= 0.28.2)
+PATH
+ remote: decidim-regulations
+ specs:
+ decidim-regulations (0.1.3)
+ rails (>= 5.2, < 7.0.x)
+
PATH
remote: decidim-top_comments
specs:
@@ -515,9 +521,10 @@ GEM
marcel (1.0.4)
matrix (0.4.2)
method_source (1.1.0)
- mime-types (3.5.2)
+ mime-types (3.6.0)
+ logger
mime-types-data (~> 3.2015)
- mime-types-data (3.2024.0903)
+ mime-types-data (3.2024.1001)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.25.1)
@@ -858,6 +865,7 @@ DEPENDENCIES
decidim-home!
decidim-process-extended!
decidim-recaptcha!
+ decidim-regulations!
decidim-templates!
decidim-top_comments!
deface
diff --git a/app/decorators/decidim/admin/newsletters_helper_decorator.rb b/app/decorators/decidim/admin/newsletters_helper_decorator.rb
index b2e90ff8..ab6d1577 100644
--- a/app/decorators/decidim/admin/newsletters_helper_decorator.rb
+++ b/app/decorators/decidim/admin/newsletters_helper_decorator.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-# rubocop:disable Metrics/CyclomaticComplexity
-# rubocop:disable Metrics/PerceivedComplexity
module Decidim::Admin::NewslettersHelperDecorator
def self.decorate
Decidim::Admin::NewslettersHelper.class_eval do
@@ -57,6 +55,3 @@ def filter_spaces_by_process_group(space_type)
end
::Decidim::Admin::NewslettersHelperDecorator.decorate
-
-# rubocop:enable Metrics/CyclomaticComplexity
-# rubocop:enable Metrics/PerceivedComplexity
diff --git a/config/initializers/decidim.rb b/config/initializers/decidim.rb
index 010d84df..0b584c53 100644
--- a/config/initializers/decidim.rb
+++ b/config/initializers/decidim.rb
@@ -67,7 +67,7 @@
config.expire_session_after= (ENV["EXPIRE_SESSION_AFTER"].presence || 0.5).to_f.hours
config.follow_http_x_forwarded_host = Rails.application.secrets.decidim[:follow_http_x_forwarded_host].present?
-
+
# Configure CSP for Algolia search for Decidim Finder
config.content_security_policies_extra = {
"connect-src" => %w(https://*.algolianet.com https://*.algolianet.net),
@@ -76,7 +76,7 @@
end
Decidim.menu :home_content_block_menu do |menu|
- menu.add_item :meetings, I18n.t("decidim.menu.meetings_static"), "/meetings", position: 13, active: :inclusive
+ menu.add_item :meetings, I18n.t("decidim.menu.meetings_static"), "/meetings", active: :inclusive
end
Rails.application.config.i18n.available_locales = Decidim.available_locales
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index 3ef50364..2637561f 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -3,9 +3,8 @@
Rails.application.config.to_prepare do
Decidim.menu :home_content_block_menu do |menu|
menu.add_item :decidims_finder,
- I18n.t("menu.decidims_finder", scope: "participagencat"),
- Rails.application.routes.url_helpers.decidims_finder_page_path,
- position: 14,
- active: :inclusive
+ I18n.t("menu.decidims_finder", scope: "participagencat"),
+ Rails.application.routes.url_helpers.decidims_finder_page_path,
+ active: :inclusive
end
end
diff --git a/decidim-process-extended/app/decorators/cells/decidim/content_blocks/participatory_space_metadata_cell_decorator.rb b/decidim-process-extended/app/decorators/cells/decidim/content_blocks/participatory_space_metadata_cell_decorator.rb
index b1ebaaa5..94c79260 100644
--- a/decidim-process-extended/app/decorators/cells/decidim/content_blocks/participatory_space_metadata_cell_decorator.rb
+++ b/decidim-process-extended/app/decorators/cells/decidim/content_blocks/participatory_space_metadata_cell_decorator.rb
@@ -23,7 +23,7 @@ def metadata_valued_items
{
title: t(item, scope: translations_scope),
- value:
+ value: value
}
end
end
diff --git a/decidim-process-extended/app/decorators/cells/decidim/participatory_processes/content_blocks/metadata_cell_decorator.rb b/decidim-process-extended/app/decorators/cells/decidim/participatory_processes/content_blocks/metadata_cell_decorator.rb
index 7079d26f..90eb43db 100644
--- a/decidim-process-extended/app/decorators/cells/decidim/participatory_processes/content_blocks/metadata_cell_decorator.rb
+++ b/decidim-process-extended/app/decorators/cells/decidim/participatory_processes/content_blocks/metadata_cell_decorator.rb
@@ -8,7 +8,7 @@ def self.decorate
def metadata_items
%w(participatory_scope target participatory_structure area_name meta_scope local_area developer_group
- promoting_unit facilitators cost has_summary_record email)
+ promoting_unit facilitators cost has_summary_record email)
end
end
end
diff --git a/decidim-regulations/app/cells/decidim/participatory_processes/process_filters_cell.rb b/decidim-regulations/app/cells/decidim/participatory_processes/process_filters_cell.rb
deleted file mode 100644
index c6148573..00000000
--- a/decidim-regulations/app/cells/decidim/participatory_processes/process_filters_cell.rb
+++ /dev/null
@@ -1,129 +0,0 @@
-# frozen_string_literal: true
-
-module Decidim
- module ParticipatoryProcesses
- class ProcessFiltersCell < Decidim::ViewModel
- ALL_FILTERS = %w(active past upcoming all).freeze
-
- def filter_link(date_filter, type_filter = nil)
- Decidim::ParticipatoryProcesses::Engine
- .routes
- .url_helpers
- .participatory_processes_path(**filter_params(date_filter, type_filter))
- end
-
- def current_filter
- get_filter_in(:with_date, ALL_FILTERS, model[:default_filter])
- end
-
- def current_type_filter_name
- participatory_process_types_for_select.find { |_, id| id == get_filter(:with_type) }&.first ||
- I18n.t("all_types", scope: "decidim.participatory_processes.participatory_processes.filters")
- end
-
- def get_filter(filter_name, default = nil)
- params&.dig(:filter, filter_name) || default
- end
-
- def get_filter_in(filter_name, options, default = nil)
- value = get_filter(filter_name)
- options.include?(value) ? value : default
- end
-
- def filter_params(date_filter, type_filter)
- {
- filter: {
- with_date: date_filter,
- with_any_scope: get_filter(:with_any_scope),
- with_area: get_filter(:with_area),
- with_type: type_filter || get_filter(:with_type)
- }
- }
- end
-
- def filtered_processes(date_filter, filter_with_type: true)
- query = ParticipatoryProcess.where(organization: current_organization).ransack(
- {
- with_date: date_filter,
- with_any_scope: get_filter(:with_any_scope),
- with_area: get_filter(:with_area),
- with_type: filter_with_type ? get_filter(:with_type) : nil
- },
- current_user: current_user
- ).result
-
- query.published.visible_for(current_user)
- end
-
- # This is customized because GENCAT don't Processes Groups on Index Page
- 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|
- processes = filtered_processes(filter_name).where(decidim_participatory_process_group_id: Rails.application.config.process)
- collection_by_filter.merge(filter_name.to_s => processes.count)
- end
- @process_count_by_filter["all"] = @process_count_by_filter.values.sum
- @process_count_by_filter
- end
- # This is customized because GENCAT don't Processes Groups on Index Page
-
- def other_filters
- @other_filters ||= ALL_FILTERS - [current_filter]
- end
-
- def other_filters_with_value
- @other_filters_with_value ||= other_filters.select do |filter|
- process_count_by_filter[filter].positive?
- end
- end
-
- def should_show_tabs?
- other_filters_with_value.any? && other_filters_with_value != ["all"]
- end
-
- def title
- I18n.t(current_filter, scope: "decidim.participatory_processes.participatory_processes.filters.counters", count: process_count_by_filter[current_filter])
- end
-
- def filter_type_label
- I18n.t("filter_by", scope: "decidim.participatory_processes.participatory_processes.filters")
- end
-
- def filter_name(filter)
- I18n.t(filter, scope: "decidim.participatory_processes.participatory_processes.filters.names")
- end
-
- def explanation
- return if process_count_by_filter["active"].positive?
-
- content_tag(
- :span,
- I18n.t(explanation_text, scope: "decidim.participatory_processes.participatory_processes.filters.explanations"),
- class: "muted mr-s ml-s"
- )
- end
-
- def explanation_text
- return "no_active" if process_count_by_filter["upcoming"].positive?
-
- "no_active_nor_upcoming"
- end
-
- def participatory_process_types
- @participatory_process_types ||= Decidim::ParticipatoryProcessType.joins(:processes).where(
- decidim_participatory_processes: { id: filtered_processes(current_filter, filter_with_type: false) }
- ).distinct
- end
-
- def participatory_process_types_for_select
- return if participatory_process_types.blank?
-
- [[I18n.t("all_types", scope: "decidim.participatory_processes.participatory_processes.filters"), ""]] +
- participatory_process_types.map do |type|
- [translated_attribute(type.title), type.id.to_s]
- end
- end
- end
- end
-end
diff --git a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/_all_processes.erb b/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/_all_processes.erb
deleted file mode 100644
index dcf55ef9..00000000
--- a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/_all_processes.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- <%= link_to t("see_all_processes", scope: i18n_scope),
- "regulations",
- class: "button expanded hollow button--sc home-section__cta",
- title: t("processes_button_title", scope: i18n_scope) %>
-
-
diff --git a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/show.erb b/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/show.erb
deleted file mode 100644
index 22e9fbb3..00000000
--- a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/show.erb
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
<%= t("active_processes", scope: i18n_scope) %>
-
-
- <% highlighted_regulations.each do |regulation| %>
-
-
- <%= link_to decidim_participatory_processes.participatory_process_path(regulation), class: "card__link" do %>
-
- <% end %>
-
- <%= link_to decidim_participatory_processes.participatory_process_path(regulation), class: "card__link" do %>
-
<%= translated_attribute regulation.title %>
- <% end %>
- <% if regulation.active_step %>
-
- <%= t(".active_step") %>
- <%= translated_attribute regulation.active_step.title %>
-
- <% end %>
-
-
-
- <% end %>
-
-
-
- <%= render "_all_processes" %>
-
diff --git a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/single_regulation.erb b/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/single_regulation.erb
deleted file mode 100644
index 4483823a..00000000
--- a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations/single_regulation.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<% regulation = highlighted_regulations.first %>
-
-
-
<%= t("active_processes", scope: i18n_scope) %>
-
- <% if regulation.is_a? Decidim::ParticipatoryProcessGroup %>
- <%= render partial: "decidim/participatory_processes/participatory_processes/promoted_process_group.html", locals: { promoted_process_group: regulation } %>
- <% else %>
-
-
-
-
- <%= link_to decidim_participatory_processes.participatory_process_path(regulation), class: "card__link" do %>
-
<%= translated_attribute regulation.title %>
- <% end %>
- <%= decidim_sanitize_editor translated_attribute(regulation.short_description) %>
- <%= link_to decidim_participatory_processes.participatory_process_path(regulation), class: "button small hollow" do %>
- <%= decidim_html_escape(translated_attribute(regulation.title)) %>
- <%= t("more_information", scope: i18n_scope) %>
- <% end %>
-
-
-
-
-
-
- <%= link_to decidim_participatory_processes.participatory_process_path(regulation), class: "button expanded button--sc" do %>
- <%= t("participate_in", resource_name: translated_attribute(regulation.title), scope: i18n_scope) %>
- <%= t("participate", scope: i18n_scope) %>
- <% if regulation.active_step %>
-
- <%= t("active_step", scope: i18n_scope) %>
- <%= translated_attribute regulation.active_step.title %>
-
- <% end %>
- <% end %>
-
-
-
-
-
-
- <% end %>
-
-
- <%= render "_all_processes" %>
-
diff --git a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations_cell.rb b/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations_cell.rb
index 19eac39d..5571a69e 100644
--- a/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations_cell.rb
+++ b/decidim-regulations/app/cells/decidim/regulations/content_blocks/highlighted_regulations_cell.rb
@@ -3,22 +3,31 @@
module Decidim
module Regulations
module ContentBlocks
- class HighlightedRegulationsCell < Decidim::ViewModel
- include Decidim::SanitizeHelper
-
- delegate :current_organization, to: :controller
+ class HighlightedRegulationsCell < Decidim::ContentBlocks::HighlightedParticipatorySpacesCell
delegate :current_user, to: :controller
- def show
- if single_regulation?
- render "single_regulation"
- elsif highlighted_regulations.any?
- render
- end
+ def highlighted_spaces
+ @highlighted_spaces ||= highlighted_regulations
end
- def single_regulation?
- highlighted_regulations.to_a.length == 1
+ alias limited_highlighted_spaces highlighted_spaces
+
+ def i18n_scope
+ "decidim.regulations.pages.home.highlighted_regulations"
+ end
+
+ def all_path
+ Decidim::ParticipatoryProcesses::Engine.routes.url_helpers.participatory_processes_path
+ end
+
+ def max_results
+ model.settings.max_results
+ end
+
+ private
+
+ def block_id
+ "highlighted-regulations"
end
def highlighted_regulations
@@ -29,14 +38,6 @@ def highlighted_regulations
.order(published_at: :desc)
.limit(8)
end
-
- def i18n_scope
- "decidim.regulations.pages.home.highlighted_regulations"
- end
-
- def decidim_participatory_processes
- Decidim::ParticipatoryProcesses::Engine.routes.url_helpers
- end
end
end
end
diff --git a/decidim-regulations/app/cells/decidim/regulations/regulation_filters/filter_tabs.erb b/decidim-regulations/app/cells/decidim/regulations/regulation_filters/filter_tabs.erb
deleted file mode 100644
index 272b385e..00000000
--- a/decidim-regulations/app/cells/decidim/regulations/regulation_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), remote: true, class: "order-by__tab" do %>
-
- <%= filter_name(filter) %>
- (<%= process_count_by_filter[filter] %>)
- <% end %>
- <% end %>
- <% else %>
- <%= explanation %>
- <% end %>
-
diff --git a/decidim-regulations/app/cells/decidim/regulations/regulation_filters/show.erb b/decidim-regulations/app/cells/decidim/regulations/regulation_filters/show.erb
index 91915616..1c53308e 100644
--- a/decidim-regulations/app/cells/decidim/regulations/regulation_filters/show.erb
+++ b/decidim-regulations/app/cells/decidim/regulations/regulation_filters/show.erb
@@ -1,13 +1,16 @@
-
-
- <%= title %>
- <%= render :filter_tabs %>
-
-
-<% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
-
-
<%= t("decidim.participatory_processes.participatory_processes.filters.explanations.no_active_nor_upcoming_callout") %>
+
+
+ <%= title %>
+ <%= render :filter_tabs %>
+
+ <%= render :type_filter if regulation_types_for_select.present? %>
+
+<% if process_count_by_filter["active"] == 0 && process_count_by_filter["upcoming"] == 0 %>
+
+ <%= cell("decidim/announcement", t("decidim.participatory_processes.participatory_processes.filters.explanations.no_active_nor_upcoming_callout"), callout_class: "warning") %>
+
+
<% end %>
diff --git a/decidim-regulations/app/cells/decidim/regulations/regulation_filters/type_filter.erb b/decidim-regulations/app/cells/decidim/regulations/regulation_filters/type_filter.erb
new file mode 100644
index 00000000..84354fb7
--- /dev/null
+++ b/decidim-regulations/app/cells/decidim/regulations/regulation_filters/type_filter.erb
@@ -0,0 +1,17 @@
+
+
+
+ <% regulation_types_for_select.each do |title, id| %>
+ -
+ <%= link_to filter_link(current_filter, id), remote: true do %>
+ <%= title %>
+ <% end %>
+
+ <% end %>
+
+
+
+
diff --git a/decidim-regulations/app/cells/decidim/regulations/regulation_filters_cell.rb b/decidim-regulations/app/cells/decidim/regulations/regulation_filters_cell.rb
deleted file mode 100644
index 2d93e10f..00000000
--- a/decidim-regulations/app/cells/decidim/regulations/regulation_filters_cell.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-# frozen_string_literal: true
-
-module Decidim
- module Regulations
- class RegulationFiltersCell < Decidim::ViewModel
- ALL_FILTERS = %w(opened closed upcoming all).freeze
-
- def filter_link(date_filter, type_filter = nil)
- Decidim::Regulations::Engine
- .routes
- .url_helpers
- .regulation_index_path(**filter_params(date_filter, type_filter))
- end
-
- def current_filter
- get_filter_in(:with_date, ALL_FILTERS, model[:default_filter])
- end
-
- def current_type_filter_name
- types_for_select.find { |_, id| id == get_filter(:with_type) }&.first ||
- I18n.t("all_types", scope: "decidim.participatory_processes.participatory_processes.filters")
- end
-
- def get_filter(filter_name, default = nil)
- params&.dig(:filter, filter_name) || default
- end
-
- def get_filter_in(filter_name, options, default = nil)
- value = get_filter(filter_name)
- options.include?(value) ? value : default
- end
-
- def filtered_processes(date_filter, filter_with_type: true)
- query = ParticipatoryProcess.where(organization: current_organization).ransack(
- {
- with_date: date_filter,
- with_any_scope: get_filter(:with_any_scope),
- with_area: get_filter(:with_area),
- with_type: filter_with_type ? get_filter(:with_type) : nil
- },
- current_user: current_user
- ).result
-
- query.published.visible_for(current_user)
- end
-
- def filter_params(date_filter, type_filter)
- {
- filter: {
- with_date: date_filter,
- with_any_scope: get_filter(:with_any_scope),
- with_area: get_filter(:with_area),
- with_type: type_filter || get_filter(:with_type)
- }
- }
- end
-
- def process_count_by_filter
- return @process_count_by_filter if @process_count_by_filter
-
- @process_count_by_filter = %w(opened closed upcoming).inject({}) do |collection_by_filter, filter_name|
- filtered_processes = filtered_processes(filter_name)
- processes = filtered_processes
- collection_by_filter.merge(filter_name => processes.count)
- end
- @process_count_by_filter["all"] = @process_count_by_filter.values.sum
- @process_count_by_filter
- end
-
- def other_filters
- @other_filters ||= ALL_FILTERS - [current_filter]
- end
-
- def other_filters_with_value
- @other_filters_with_value ||= other_filters.select do |filter|
- process_count_by_filter[filter].positive?
- end
- end
-
- def should_show_tabs?
- other_filters_with_value.any? && other_filters_with_value != ["all"]
- end
-
- def title
- t(current_filter, scope: "decidim.regulations.regulation.filters.counters", count: process_count_by_filter[current_filter])
- end
-
- def filter_name(filter)
- t(filter, scope: "decidim.regulations.regulation.filters.names")
- end
-
- def explanation
- return if process_count_by_filter["opened"].positive?
-
- tag.span(t(explanation_text, scope: "decidim.regulations.regulation.filters.explanations"), class: "muted mr-s ml-s")
- end
-
- def explanation_text
- return "no_active" if process_count_by_filter["upcoming"].positive?
-
- "no_active_nor_upcoming"
- end
- end
- end
-end
diff --git a/decidim-regulations/app/controllers/decidim/regulations/regulation_controller.rb b/decidim-regulations/app/controllers/decidim/regulations/regulation_controller.rb
index cfbb31cd..d5026a39 100644
--- a/decidim-regulations/app/controllers/decidim/regulations/regulation_controller.rb
+++ b/decidim-regulations/app/controllers/decidim/regulations/regulation_controller.rb
@@ -6,9 +6,11 @@ module Regulations
# public layout.
class RegulationController < Decidim::ParticipatoryProcesses::ApplicationController
include ParticipatorySpaceContext
- include FilterResource
-
participatory_space_layout only: [:show, :all_metrics]
+ include FilterResource
+ include Paginable
+ include HasParticipatorySpaceContentBlocks
+ include RegulationHelper
helper_method :collection,
:promoted_collection,
@@ -18,7 +20,8 @@ class RegulationController < Decidim::ParticipatoryProcesses::ApplicationControl
:participatory_process_group,
:default_date_filter,
:related_processes,
- :linked_assemblies
+ :linked_assemblies,
+ :filter_sections_regulations
def index
raise ActionController::RoutingError, "Not Found" if published_processes.none?
@@ -49,8 +52,9 @@ def search_collection
def default_filter_params
{
with_any_scope: nil,
- with_type: nil,
- with_date: default_date_filter
+ with_any_area: nil,
+ with_date: default_date_filter,
+ with_any_type: nil
}
end
@@ -69,6 +73,19 @@ def current_participatory_space
).first!
end
+ def active_content_blocks
+ @active_content_blocks ||= if current_participatory_space.present?
+ Decidim::ContentBlock.published.for_scope(
+ :participatory_process_homepage,
+ organization: current_organization
+ ).where(
+ scoped_resource_id: current_participatory_space.id
+ )
+ else
+ Decidim::ContentBlock.none
+ end
+ end
+
def published_processes
@published_processes ||= Decidim::ParticipatoryProcesses::OrganizationPublishedParticipatoryProcesses
.new(current_organization, current_user)
@@ -92,7 +109,7 @@ def promoted_collection
# This is customized because GENCAT don't Processes Groups on Index Page
def collection
- @collection ||= participatory_processes
+ @collection ||= paginate(Kaminari.paginate_array(participatory_processes))
end
# This is customized because GENCAT don't Processes Groups on Index Page
@@ -124,9 +141,8 @@ def participatory_process_group
end
def default_date_filter
- return "opened" if published_processes.any?(&:active?)
- return "closed" if published_processes.any?(&:past?)
- return "upcoming" if published_processes.any?(&:upcoming?)
+ return "active" if published_processes.any?(&:active?)
+ return "past" if published_processes.any?(&:past?)
"all"
end
diff --git a/decidim-regulations/app/helpers/decidim/regulations/regulation_helper.rb b/decidim-regulations/app/helpers/decidim/regulations/regulation_helper.rb
new file mode 100644
index 00000000..cc674b27
--- /dev/null
+++ b/decidim-regulations/app/helpers/decidim/regulations/regulation_helper.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Decidim
+ module Regulations
+ module RegulationHelper
+ def filter_sections
+ [
+ { method: :with_date, collection: filter_dates_values, label_scope: "decidim.participatory_processes.participatory_processes.filters", id: "date" },
+ { method: :with_any_scope, collection: filter_global_scopes_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "scope" },
+ { method: :with_any_area, collection: filter_areas_values, label_scope: "decidim.shared.participatory_space_filters.filters", id: "area" },
+ { method: :with_any_type, collection: filter_types_values, label_scope: "decidim.participatory_processes.participatory_processes.filters", id: "type" }
+ ].reject { |item| item[:collection].blank? }
+ end
+
+ def filter_dates_values
+ [
+ ["all", t("all", scope: "decidim.regulations.regulations.filters")],
+ ["active", t("opened", scope: "decidim.regulations.regulations.filters")],
+ ["past", t("closed", scope: "decidim.regulations.regulations.filters")]
+ ]
+ end
+ end
+ end
+end
diff --git a/decidim-regulations/app/views/decidim/regulations/regulation/_collection.html.erb b/decidim-regulations/app/views/decidim/regulations/regulation/_collection.html.erb
new file mode 100644
index 00000000..deb052a6
--- /dev/null
+++ b/decidim-regulations/app/views/decidim/regulations/regulation/_collection.html.erb
@@ -0,0 +1,8 @@
+<% date_filter_text = %w(active past all).include?(params.dig(:filter, :with_date)) ? params.dig(:filter, :with_date) : default_date_filter %>
+<%= t(date_filter_text, scope: "decidim.participatory_processes.participatory_processes.filters.counters", count: collection.total_count) %>
+
+
+ <%= render(collection) %>
+
+
+<%= decidim_paginate collection %>
diff --git a/decidim-regulations/app/views/decidim/regulations/regulation/_order_by_regulations.html.erb b/decidim-regulations/app/views/decidim/regulations/regulation/_order_by_regulations.html.erb
deleted file mode 100644
index 203e0583..00000000
--- a/decidim-regulations/app/views/decidim/regulations/regulation/_order_by_regulations.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= cell "decidim/regulations/regulation_filters", default_filter: default_date_filter %>
diff --git a/decidim-regulations/app/views/decidim/regulations/regulation/index.html.erb b/decidim-regulations/app/views/decidim/regulations/regulation/index.html.erb
index 516ad42a..79413fa0 100644
--- a/decidim-regulations/app/views/decidim/regulations/regulation/index.html.erb
+++ b/decidim-regulations/app/views/decidim/regulations/regulation/index.html.erb
@@ -8,28 +8,29 @@ edit_link(
)
%>
-
-
- <%= render partial: "decidim/shared/floating_help", locals: { content: t("regulations_info", scope: "layouts.decidim").html_safe, id: 1 } %>
-
- <% if promoted_collection.any? %>
-
- <%= t("participatory_processes.index.promoted_regulation", scope: "layouts.decidim") %>
+<%= append_stylesheet_pack_tag "decidim_participatory_processes", media: "all" %>
+<%= append_javascript_pack_tag "decidim_participatory_processes" %>
+
+<% content_for :aside do %>
+ <%= t("menu.regulations_static") %>
+
+ <%= render partial: "decidim/shared/filters", locals: { filter_sections:, skip_to_id: "regulations-grid" } %>
+<% end %>
+
+<%= render layout:"layouts/decidim/shared/layout_two_col" do %>
+ <%= render partial: "decidim/shared/floating_help", locals: { content: t("regulations_info", scope: "layouts.decidim").html_safe, id: 1 } %>
+
+ <% if promoted_collection.any? %>
+
+ <%= t("participatory_processes.index.promoted_regulation", scope: "layouts.decidim") %>
+
<% promoted_collection.each do |promoted_item| %>
- <%= render_highlighted_partial_for promoted_item %>
+ <%= card_for promoted_item, highlight: true, size: :g %>
<% end %>
<% end %>
-
-
- <%= render partial: "order_by_regulations" %>
-
- <%= render partial: "decidim/regulations/shared/participatory_space_filters/show" %>
- <%= t(".loading") %>
-
- <%= render(collection) %>
-
+
+ <%= render partial: "collection" %>
-
-<%= javascript_pack_tag "decidim_participatory_processes" %>
+<% end %>
diff --git a/decidim-regulations/app/views/decidim/regulations/regulation/index.js.erb b/decidim-regulations/app/views/decidim/regulations/regulation/index.js.erb
index 4fa7140a..96a98479 100644
--- a/decidim-regulations/app/views/decidim/regulations/regulation/index.js.erb
+++ b/decidim-regulations/app/views/decidim/regulations/regulation/index.js.erb
@@ -1,6 +1 @@
-var $grid = $('#processes-grid');
-var $loading = $grid.find('.loading');
-
-$grid.find('.card-grid').html('<%= j(render(collection)).strip.html_safe %>');
-$grid.find('.processes-grid-order-by').html('<%= j(render(partial: "decidim/regulations/regulation/order_by_regulations", locals: { include_filter: true })).strip.html_safe %>');
-$loading.hide();
+$('#regulations-grid').html('<%= j(render(partial: "collection")).strip.html_safe %>');
diff --git a/decidim-regulations/config/initializers/main_navigation.rb b/decidim-regulations/config/initializers/main_navigation.rb
index 45725fcb..655c3ed3 100644
--- a/decidim-regulations/config/initializers/main_navigation.rb
+++ b/decidim-regulations/config/initializers/main_navigation.rb
@@ -4,6 +4,5 @@
menu.add_item :regulations,
I18n.t("menu.regulations_static"),
"/regulations",
- position: 12,
active: :inclusive
end
diff --git a/decidim-regulations/config/locales/ca.yml b/decidim-regulations/config/locales/ca.yml
index 6dd12cfa..a52e79bd 100644
--- a/decidim-regulations/config/locales/ca.yml
+++ b/decidim-regulations/config/locales/ca.yml
@@ -28,12 +28,12 @@ ca:
pages:
home:
highlighted_regulations:
- active_processes: Participació en normativa
+ active_spaces: Participació en normativa
active_step: Pas actiu
more_information: Més informació
participate: Participa
processes_button_title: Enllaç a la pàgina de Participació en normativa mostrant totas las participacions
- see_all_processes: Veure totes les participacions
+ see_all_spaces: Veure totes les participacions
regulation:
filters:
counters:
@@ -65,6 +65,12 @@ ca:
show:
email: Bústia de suport
categories: Eixos de debat
+ regulations:
+ filters:
+ all: Tots
+ opened: Obertes
+ closed: Tancats
+ date: Data
scopes:
global: Tots els tipus
picker:
@@ -92,6 +98,18 @@ ca:
show:
email: Bústia de suport
categories: Eixos de debat
+ filters:
+ closed: Tancats
+ counters:
+ active:
+ one: Un procés obert
+ other: "%{count} processos obertes"
+ all:
+ one: Un procés
+ other: "%{count} processos"
+ past:
+ one: Un procés tancat
+ other: "%{count} processos tancats"
show:
theme: Tema
proposals:
diff --git a/decidim-regulations/config/locales/en.yml b/decidim-regulations/config/locales/en.yml
index 50234034..25ad1172 100644
--- a/decidim-regulations/config/locales/en.yml
+++ b/decidim-regulations/config/locales/en.yml
@@ -28,12 +28,12 @@ en:
pages:
home:
highlighted_regulations:
- active_processes: Participation in regulation
+ active_spaces: Participation in regulation
active_step: Active step
more_information: More information
participate: Participate
processes_button_title: Link to page of Participation in regulation showing all participations
- see_all_processes: See all participations
+ see_all_spaces: See all participations
regulation:
filters:
counters:
@@ -65,6 +65,12 @@ en:
categories: Debate axis
index:
loading: Loading
+ regulations:
+ filters:
+ all: All
+ opened: Opened
+ closed: Closed
+ date: Date
scopes:
global: All types
picker:
@@ -92,6 +98,18 @@ en:
show:
email: Support mailbox
categories: Debate axis
+ filters:
+ closed: Closed
+ counters:
+ active:
+ one: 1 open participation
+ other: "%{count} open participations"
+ all:
+ one: 1 participation in regulation
+ other: "%{count} participations in regulation"
+ past:
+ one: 1 closed participation
+ other: "%{count} closed participations"
show:
theme: Theme
proposals:
diff --git a/decidim-regulations/config/locales/es.yml b/decidim-regulations/config/locales/es.yml
index 6f4cdf2b..e6b3d76f 100644
--- a/decidim-regulations/config/locales/es.yml
+++ b/decidim-regulations/config/locales/es.yml
@@ -28,12 +28,12 @@ es:
pages:
home:
highlighted_regulations:
- active_processes: Participación en normativa
+ active_spaces: Participación en normativa
active_step: Paso activo
more_information: Más información
participate: Participa
processes_button_title: Enlace a la página de Participación en normativa mostrando todas las participaciones
- see_all_processes: Ver todas las participaciones
+ see_all_spaces: Ver todas las participaciones
regulation:
filters:
counters:
@@ -65,6 +65,12 @@ es:
categories: Ejes de debate
index:
loading: Cargando
+ regulations:
+ filters:
+ all: Todas
+ opened: Abiertas
+ closed: Cerradas
+ date: Data
scopes:
global: Todos los tipos
picker:
@@ -92,6 +98,18 @@ es:
show:
email: Buzón de soporte
categories: Ejes de debate
+ filters:
+ closed: Cerrados
+ counters:
+ all:
+ one: 1 participación en normativa
+ other: "%{count} participaciones"
+ past:
+ one: 1 participación cerrada
+ other: "%{count} participaciones cerradas"
+ active:
+ one: 1 participación abierta
+ other: "%{count} participaciones abiertas"
show:
theme: Tema
proposals: