Move content blocks forms partials to components

This way we can simplify the controller a little bit, and it'll be
easier to write tests for them when we change the code.
This commit is contained in:
Javi Martín
2024-05-23 19:30:26 +02:00
parent 1898bdec56
commit 2a5edbb5dd
6 changed files with 38 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
<% if @is_heading_content_block %>
<%= render "form_heading_content_block" %>
<%= render Admin::SiteCustomization::ContentBlocks::FormHeadingContentBlockComponent.new(@content_block) %>
<% else %>
<%= render "form_content_block" %>
<%= render Admin::SiteCustomization::ContentBlocks::FormContentBlockComponent.new(@content_block) %>
<% end %>

View File

@@ -1,19 +0,0 @@
<%= form_for [:admin, @content_block], html: { class: "edit_page" } do |f| %>
<%= render "shared/errors", resource: @content_block %>
<div class="small-12 medium-6 column">
<%= f.select :name, options_for_select(valid_blocks, @selected_content_block) %>
</div>
<div class="small-12 medium-6 column">
<%= f.select :locale, I18n.available_locales %>
</div>
<div class="small-12 column">
<%= f.text_area :body, rows: 10 %>
<div class="small-12 medium-6 large-3">
<%= f.submit class: "button success expanded" %>
</div>
</div>
<% end %>

View File

@@ -1,19 +0,0 @@
<%= form_tag(admin_site_customization_update_heading_content_block_path(@content_block.id), method: "put") do %>
<%= render "shared/errors", resource: @content_block %>
<div class="small-12 medium-6 column">
<%= label_tag :name %>
<%= select_tag :name, options_for_select(valid_blocks, @selected_content_block) %>
</div>
<div class="small-12 medium-6 column">
<%= label_tag :locale %>
<%= select_tag :locale, options_for_select(I18n.available_locales, @content_block.locale.to_sym) %>
</div>
<div class="small-12 column">
<%= label_tag :body %>
<%= text_area_tag :body, @content_block.body, rows: 10 %>
<div class="small-12 medium-6 large-3">
<%= button_tag t("admin.menu.site_customization.buttons.content_block.update"), class: "button success expanded" %>
</div>
</div>
<% end %>