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? %>
|
<% if setting.content_type? %>
|
||||||
<%= render Admin::Settings::ContentTypesFormComponent.new(setting) %>
|
<%= render Admin::Settings::ContentTypesFormComponent.new(setting) %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if defined?(tab) %>
|
<%= render Admin::Settings::TextFormComponent.new(setting, tab: tab) %>
|
||||||
<%= render "admin/settings/settings_form", setting: setting, tab: tab %>
|
|
||||||
<% else %>
|
|
||||||
<%= render "admin/settings/settings_form", setting: setting %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<%= form_for([:admin, setting]) do |f| %>
|
<%= form_for([:admin, setting]) do |f| %>
|
||||||
<%= f.hidden_field :tab, id: dom_id(setting, :tab), value: tab if defined?(tab) %>
|
<%= f.hidden_field :tab, id: dom_id(setting, :tab), value: tab if tab %>
|
||||||
<div class="small-12 medium-6 large-8 column">
|
<div class="small-12 medium-6 large-8 column">
|
||||||
<%= f.text_area :value,
|
<%= f.text_area :value,
|
||||||
label: false,
|
label: false,
|
||||||
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