From 5199551350d05a24c439b4c6dc5946f12eafaa30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Mart=C3=ADnez?= Date: Thu, 8 Apr 2021 10:30:32 +0200 Subject: [PATCH] Participatory process groups content blocks (#12) * Upgrade Decidim version to 0.23 * Fix rubocop offenses * Validate blueprints image file size using upload_maximum_file_size setting for organization * Add migration to add a reference in blueprints table to content blocks * Add association with content blocks to Blueprint model and factory * Allow passing the content block to SaveBlueprints command from form * Include content_block in BluePrintForm * Manage blueprints belonging to content block * Register navigation map content block for participatory process groups homepage * Include content block in tests for blueprints * Add test for ContentBlockBlueprints query * Add tests to check that blueprints association with content blocks * Use different classes and title for navigation block in groups landing page * Fix title display in navigation_map cell * Include content block association in seeds file * Remove console insertion in cell * Add test for groups_navigation_map cell --- .../groups_navigation_map/title.erb | 3 ++ .../groups_navigation_map_cell.rb | 21 ++++++++++ .../content_blocks/navigation_map/show.erb | 6 +-- .../content_blocks/navigation_map_cell.rb | 20 ++++++++++ .../navigation_map_settings_form/show.erb | 1 + .../navigation_map_settings_form_cell.rb | 2 +- .../navigation_maps/save_blueprints.rb | 8 +++- .../admin/blueprints_controller.rb | 4 +- .../decidim/navigation_maps/blueprint_form.rb | 1 + .../navigation_maps/blueprint_forms.rb | 1 + .../decidim/navigation_maps/blueprint.rb | 1 + .../content_block_blueprints.rb | 20 ++++++++++ ...ce_to_content_block_to_blueprints_table.rb | 12 ++++++ db/seeds.rb | 3 +- lib/decidim/navigation_maps/engine.rb | 10 +++++ .../navigation_map_cell_helpers.rb | 8 ++-- lib/decidim/navigation_maps/test/factories.rb | 1 + spec/commands/save_blueprints_spec.rb | 9 ++++- .../groups_navigation_map_cell_spec.rb | 38 +++++++++++++++++++ .../navigation_map_cell_spec.rb | 2 +- .../navigation_map_settings_form_cell_spec.rb | 2 +- spec/forms/blueprint_forms_spec.rb | 4 +- spec/lib/navigation_map_cell_helpers_spec.rb | 17 ++++++--- spec/models/blueprint_spec.rb | 7 +++- spec/queries/content_block_blueprints_spec.rb | 29 ++++++++++++++ 25 files changed, 207 insertions(+), 23 deletions(-) create mode 100644 app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map/title.erb create mode 100644 app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map_cell.rb create mode 100644 app/queries/decidim/navigation_maps/content_block_blueprints.rb create mode 100644 db/migrate/20201105130724_add_reference_to_content_block_to_blueprints_table.rb create mode 100644 spec/content_blocks/groups_navigation_map_cell_spec.rb create mode 100644 spec/queries/content_block_blueprints_spec.rb diff --git a/app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map/title.erb b/app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map/title.erb new file mode 100644 index 0000000..d0dad6f --- /dev/null +++ b/app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map/title.erb @@ -0,0 +1,3 @@ +<% if translated_title.present? %> +

<%= decidim_sanitize translated_title %>

+<% end %> diff --git a/app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map_cell.rb b/app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map_cell.rb new file mode 100644 index 0000000..6ff446c --- /dev/null +++ b/app/cells/decidim/navigation_maps/content_blocks/groups_navigation_map_cell.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Decidim + module NavigationMaps + module ContentBlocks + class GroupsNavigationMapCell < NavigationMapCell + def section_classes + "section home-section" + end + + def wrapper_classes + nil + end + + def row_classes + "row column" + end + end + end + end +end diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map/show.erb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map/show.erb index 66d0ccb..db335ce 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map/show.erb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map/show.erb @@ -1,9 +1,9 @@ <%= stylesheet_link_tag "decidim/navigation_maps/navigation_maps" %> <%= render partial: "styles", locals: { blueprints: valid_blueprints } %> -
-
-
+> + > + > <% if translated_title.present? %>

<%= decidim_sanitize translated_title %>

diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_cell.rb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_cell.rb index fa11af0..6654306 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_cell.rb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_cell.rb @@ -7,6 +7,8 @@ class NavigationMapCell < Decidim::ViewModel include NavigationMaps::NavigationMapCellHelpers include Decidim::SanitizeHelper + alias content_block model + view_paths << "#{Decidim::NavigationMaps::Engine.root}/app/cells/decidim/navigation_maps/content_blocks/navigation_map" def show @@ -16,6 +18,24 @@ def show def translated_title translated_attribute(model.settings.title) end + + def section_classes + "extended home-section" + end + + def wrapper_classes + "wrapper-home" + end + + def row_classes + "row column text-center" + end + + def class_tag(class_string) + return if class_string.blank? + + " class=\"#{class_string}\"" + end end end end diff --git a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb index f69d45f..feb98ab 100644 --- a/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb +++ b/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form/show.erb @@ -6,6 +6,7 @@ <%= hidden_field_tag :_method, "post" %> <%= hidden_field_tag :action, blueprints_path %> +<%= hidden_field_tag :content_block_id, content_block.id %>