Extract setting text form to a component
This commit is contained in:
committed by
Javi Martín
parent
c9e3b8903d
commit
65c6189183
@@ -19,11 +19,7 @@
|
||||
<% if setting.content_type? %>
|
||||
<%= render Admin::Settings::ContentTypesFormComponent.new(setting) %>
|
||||
<% else %>
|
||||
<% if defined?(tab) %>
|
||||
<%= render "admin/settings/settings_form", setting: setting, tab: tab %>
|
||||
<% else %>
|
||||
<%= render "admin/settings/settings_form", setting: setting %>
|
||||
<% end %>
|
||||
<%= render Admin::Settings::TextFormComponent.new(setting, tab: tab) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
13
app/components/admin/settings/text_form_component.html.erb
Normal file
13
app/components/admin/settings/text_form_component.html.erb
Normal file
@@ -0,0 +1,13 @@
|
||||
<%= form_for([:admin, setting]) do |f| %>
|
||||
<%= f.hidden_field :tab, id: dom_id(setting, :tab), value: tab if tab %>
|
||||
<div class="small-12 medium-6 large-8 column">
|
||||
<%= f.text_area :value,
|
||||
label: false,
|
||||
id: dom_id(setting, :value),
|
||||
"aria-label": strip_tags(t("settings.#{setting.key}")),
|
||||
"aria-describedby": dom_id(setting, :description) %>
|
||||
</div>
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= f.submit(t("admin.settings.index.update_setting"), class: "button hollow expanded") %>
|
||||
</div>
|
||||
<% end %>
|
||||
9
app/components/admin/settings/text_form_component.rb
Normal file
9
app/components/admin/settings/text_form_component.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Admin::Settings::TextFormComponent < ApplicationComponent
|
||||
attr_reader :setting, :tab
|
||||
delegate :dom_id, to: :helpers
|
||||
|
||||
def initialize(setting, tab: nil)
|
||||
@setting = setting
|
||||
@tab = tab
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user