Move featured settings form partial to a component

This commit is contained in:
Javi Martín
2021-08-20 21:33:48 +02:00
parent 34fcfa706f
commit e6127decac
3 changed files with 10 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<%= form_for(feature, url: admin_setting_path(feature), html: { id: "edit_#{dom_id(feature)}" }) do |f| %>
<%= f.hidden_field :tab, value: tab if defined?(tab) %>
<%= f.hidden_field :tab, value: tab if tab %>
<%= f.hidden_field :value, id: dom_id(feature), value: (feature.enabled? ? "" : "active") %>
<%= f.submit(t("admin.settings.index.features.#{feature.enabled? ? "disable" : "enable"}"),
class: "button expanded #{feature.enabled? ? "hollow alert" : "success"}",

View File

@@ -0,0 +1,8 @@
class Admin::Settings::FeaturedSettingsFormComponent < ApplicationComponent
attr_reader :feature, :tab
def initialize(feature, tab: nil)
@feature = feature
@tab = tab
end
end

View File

@@ -32,7 +32,7 @@
</td>
<td class="text-right">
<%= render "admin/settings/featured_settings_form", feature: feature, tab: tab %>
<%= render Admin::Settings::FeaturedSettingsFormComponent.new(feature, tab: tab) %>
</td>
</tr>
<% end %>