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:
@@ -0,0 +1,19 @@
|
||||
<%= 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 %>
|
||||
@@ -0,0 +1,14 @@
|
||||
class Admin::SiteCustomization::ContentBlocks::FormContentBlockComponent < ApplicationComponent
|
||||
attr_reader :content_block
|
||||
use_helpers :valid_blocks
|
||||
|
||||
def initialize(content_block)
|
||||
@content_block = content_block
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def selected_content_block
|
||||
content_block.name
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
<%= 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 %>
|
||||
@@ -0,0 +1,14 @@
|
||||
class Admin::SiteCustomization::ContentBlocks::FormHeadingContentBlockComponent < ApplicationComponent
|
||||
attr_reader :content_block
|
||||
use_helpers :valid_blocks
|
||||
|
||||
def initialize(content_block)
|
||||
@content_block = content_block
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def selected_content_block
|
||||
"hcb_#{content_block.heading_id}"
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user