diff --git a/app/controllers/spina/admin/layout_controller.rb b/app/controllers/spina/admin/layout_controller.rb
index 33ed3b113..d107b7a8e 100644
--- a/app/controllers/spina/admin/layout_controller.rb
+++ b/app/controllers/spina/admin/layout_controller.rb
@@ -3,6 +3,7 @@ class LayoutController < AdminController
before_action :set_account
before_action :set_locale
before_action :set_breadcrumb
+ before_action :get_layout_parts
admin_section :content
@@ -24,6 +25,11 @@ def update
def layout_params
params.require(:account).permit!
end
+
+ def get_layout_parts
+ @layout_parts = Spina::Current.theme.layout_parts
+ @layout_parts = {parts: @layout_parts} if @layout_parts.is_a?(Array)
+ end
def set_breadcrumb
add_breadcrumb t("spina.layout.layout")
diff --git a/app/views/spina/admin/layout/edit.html.erb b/app/views/spina/admin/layout/edit.html.erb
index 9f5b1f165..c602b240f 100644
--- a/app/views/spina/admin/layout/edit.html.erb
+++ b/app/views/spina/admin/layout/edit.html.erb
@@ -1,36 +1,45 @@
-<%= render Spina::UserInterface::HeaderComponent.new do |header| %>
- <% header.with_actions do %>
- <%= render Spina::UserInterface::TranslationsComponent.new(@account, label: @locale.upcase) %>
-
- <% if Spina::Current.theme.layout_parts.any? %>
+
+ <%= render Spina::UserInterface::HeaderComponent.new do |header| %>
+ <% header.with_actions do %>
+ <%= render Spina::UserInterface::TranslationsComponent.new(@account, label: @locale.upcase) %>
+
<%= button_tag type: :submit, form: dom_id(@account), class: 'btn btn-primary', data: {controller: "button hotkeys", hotkeys: "command+s, ctrl+s", hotkeys_target: "button", action: "button#loading", loading_message: t('spina.ui.saving')} do %>
<%= heroicon('check', style: :mini, class: 'w-5 h-5 -ml-1 mr-1') %>
<%=t 'spina.layout.save' %>
<% end %>
<% end %>
+
+ <% header.with_navigation do %>
+
+ <% end %>
<% end %>
-<% end %>
-
-<%= form_with model: @account, url: spina.admin_layout_path, id: dom_id(@account) do |f| %>
- <%= hidden_field_tag :locale, @locale %>
-
-
- <% if Spina::Current.theme.layout_parts.any? %>
-
-
- <%= f.fields_for "#{@locale}_content".to_sym, build_parts(f.object, Spina::Current.theme.layout_parts) do |ff| %>
- <%= ff.hidden_field :type, value: ff.object.class %>
- <%= ff.hidden_field :name %>
- <%= ff.hidden_field :title %>
+
+ <%= form_with model: @account, url: spina.admin_layout_path, id: dom_id(@account) do |f| %>
+ <%= hidden_field_tag :locale, @locale %>
+
+
+ <% @layout_parts.keys.each.with_index do |key, index| %>
+
+
+ <%= f.fields_for "#{@locale}_content".to_sym, build_parts(f.object, @layout_parts[key]) do |ff| %>
+ <%= ff.hidden_field :type, value: ff.object.class %>
+ <%= ff.hidden_field :name %>
+ <%= ff.hidden_field :title %>
+
+ <%= render "spina/admin/parts/#{parts_partial_namespace(ff.object.class.to_s)}/form", f: ff %>
+ <% end %>
+
+
+ <% end %>
+
- <%= render "spina/admin/parts/#{parts_partial_namespace(ff.object.class.to_s)}/form", f: ff %>
- <% end %>
-
- <% else %>
-
- <%=t 'spina.layout.no_layout_parts' %>
-
- <% end %>
-
-
-<% end %>
\ No newline at end of file
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/spina/admin/shared/_navigation.html.erb b/app/views/spina/admin/shared/_navigation.html.erb
index 6b25a1b31..94e26b331 100644
--- a/app/views/spina/admin/shared/_navigation.html.erb
+++ b/app/views/spina/admin/shared/_navigation.html.erb
@@ -17,8 +17,10 @@
<%= render Spina::MainNavigation::LinkComponent.new t('spina.website.pages'), spina.admin_pages_path, active: controller_name.in?(%w(pages resources)) %>
<%= render Spina::MainNavigation::LinkComponent.new t('spina.navigations.navigations'), spina.admin_navigations_path, active: controller_name == "navigations" %>
-
- <%= render Spina::MainNavigation::LinkComponent.new t('spina.layout.layout'), spina.edit_admin_layout_path, active: controller_name == "layout" %>
+
+ <% if Spina::Current.theme.layout_parts.present? %>
+ <%= render Spina::MainNavigation::LinkComponent.new t('spina.layout.layout'), spina.edit_admin_layout_path, active: controller_name == "layout" %>
+ <% end %>
<%= render Spina::MainNavigation::LinkComponent.new t('spina.website.media_library'), spina.admin_images_path, active: controller_name.in?(%w(images media_folders attachments)) %>