Skip to content

Commit

Permalink
add title
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Dec 3, 2019
1 parent e0d6112 commit 57e6caa
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
<%= render partial: "styles", locals: { blueprints: valid_blueprints } %>

<section class="extended home-section">
<div class="row">
<div class="columns small-centered">
<div class="wrapper-home">
<div class="row column text-center">

<% if translated_title.present? %>
<h3 class="heading3"><%= decidim_sanitize translated_title %></h3>
<% end %>

<div class="navigation_maps">
<%= render partial: "tabs", locals: { tabs: valid_blueprints } %>
<%= render partial: "tabs_content", locals: { tabs: valid_blueprints } %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ module NavigationMaps
module ContentBlocks
class NavigationMapCell < Decidim::ViewModel
include NavigationMaps::NavigationMapCellHelpers
include Decidim::SanitizeHelper

view_paths << "#{Decidim::NavigationMaps::Engine.root}/app/cells/decidim/navigation_maps/content_blocks/navigation_map"

def show
render if valid_blueprints?
end

def translated_title
translated_attribute(model.settings.title)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!-- Original settings -->
<% form.fields_for :settings, form.object.settings do |settings_fields| %>
<%= settings_fields.translated :text_field, :title %>
<% end %>

<!-- Override rails default patch (using post via ajax) -->
<%= hidden_field_tag :_method, "post" %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module NavigationMaps
module ContentBlocks
class NavigationMapSettingsFormCell < Decidim::ViewModel
include NavigationMaps::NavigationMapCellHelpers
alias form model

view_paths << "#{Decidim::NavigationMaps::Engine.root}/app/cells/decidim/navigation_maps/content_blocks/navigation_map_settings_form"

Expand All @@ -17,6 +18,14 @@ def blueprint_form(blueprint = nil)
def blueprints_path
"/admin/navigation_maps/blueprints"
end

def content_block
options[:content_block]
end

def label
I18n.t("decidim.content_blocks.html.html_content")
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def show
end

def create
save_settings
parse_blueprints
@form = form(BlueprintForms).from_params(params).with_context(current_organization: current_organization)
SaveBlueprints.call(@form) do
Expand All @@ -32,6 +33,20 @@ def create

private

# Manually save original settings if the settings array is present
def save_settings
return unless params[:content_block]
return unless params[:content_block][:settings]

@form = form(Decidim::Admin::ContentBlockForm).from_params(params)
Decidim::Admin::UpdateContentBlock.call(@form, content_block, :homepage)
end

def content_block
@content_block ||= Decidim::ContentBlock.for_scope(:homepage, organization: current_organization).find_by(manifest_name: :navigation_map)
end

# Convert blueprint data to an object
def parse_blueprints
return unless params[:blueprints]

Expand Down
11 changes: 2 additions & 9 deletions lib/decidim/navigation_maps/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ module NavigationMaps
class Engine < ::Rails::Engine
isolate_namespace Decidim::NavigationMaps

routes do
# Add engine routes here
# resources :navigation_maps
# root to: "navigation_maps#index"
end

initializer "decidim_navigation_maps.assets" do |app|
app.config.assets.precompile += %w(decidim_navigation_maps_manifest.js decidim_navigation_maps_manifest.css)
end
Expand All @@ -24,10 +18,9 @@ class Engine < ::Rails::Engine
content_block.cell = "decidim/navigation_maps/content_blocks/navigation_map"
content_block.public_name_key = "decidim.navigation_maps.content_blocks.name"
content_block.settings_form_cell = "decidim/navigation_maps/content_blocks/navigation_map_settings_form"
# Todo find a way to show settings

content_block.settings do |settings|
settings.attribute :dummy_variable,
type: :integer
settings.attribute :title, type: :text, translated: true
end
end
end
Expand Down

0 comments on commit 57e6caa

Please sign in to comment.