Move budget headings form partial to a component
This way it'll be easier to test it.
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="small-12 medium-6">
|
<div class="small-12 medium-6">
|
||||||
<% if @budget.show_money? %>
|
<% if budget.show_money? %>
|
||||||
<%= f.text_field :price, maxlength: 8 %>
|
<%= f.text_field :price, maxlength: 8 %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= f.hidden_field :price, value: 0 %>
|
<%= f.hidden_field :price, value: 0 %>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<% if respond_to?(:single_heading?) && single_heading? %>
|
<% if single_heading? %>
|
||||||
<%= f.submit t("admin.budgets_wizard.headings.continue"), class: "button success" %>
|
<%= f.submit t("admin.budgets_wizard.headings.continue"), class: "button success" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= f.submit t("admin.budget_headings.form.#{action}"), class: "button hollow" %>
|
<%= f.submit t("admin.budget_headings.form.#{action}"), class: "button hollow" %>
|
||||||
21
app/components/admin/budget_headings/form_component.rb
Normal file
21
app/components/admin/budget_headings/form_component.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
class Admin::BudgetHeadings::FormComponent < ApplicationComponent
|
||||||
|
include TranslatableFormHelper
|
||||||
|
include GlobalizeHelper
|
||||||
|
attr_reader :heading, :path, :action
|
||||||
|
|
||||||
|
def initialize(heading, path:, action:)
|
||||||
|
@heading = heading
|
||||||
|
@path = path
|
||||||
|
@action = action
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def budget
|
||||||
|
heading.budget
|
||||||
|
end
|
||||||
|
|
||||||
|
def single_heading?
|
||||||
|
helpers.respond_to?(:single_heading?) && helpers.single_heading?
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<%= render Admin::BudgetsWizard::CreationStepComponent.new(heading, next_step_path) do %>
|
<%= render Admin::BudgetsWizard::CreationStepComponent.new(heading, next_step_path) do %>
|
||||||
<%= render "/admin/budget_headings/form", heading: heading, path: form_path, action: "create" %>
|
<%= render Admin::BudgetHeadings::FormComponent.new(heading, path: form_path, action: "create") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
<%= render Admin::BudgetsWizard::CreationTimelineComponent.new("headings") %>
|
<%= render Admin::BudgetsWizard::CreationTimelineComponent.new("headings") %>
|
||||||
|
|
||||||
<%= render "/admin/budget_headings/form", heading: heading, path: form_path, action: "submit" %>
|
<%= render Admin::BudgetHeadings::FormComponent.new(heading, path: form_path, action: "submit") %>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
<%= render "header", action: "edit" %>
|
<%= render "header", action: "edit" %>
|
||||||
|
|
||||||
<%= render "form", heading: @heading, path: admin_budget_group_heading_path(@budget, @group, @heading), action: "submit" %>
|
<%= render Admin::BudgetHeadings::FormComponent.new(
|
||||||
|
@heading,
|
||||||
|
path: admin_budget_group_heading_path(@budget, @group, @heading),
|
||||||
|
action: "submit"
|
||||||
|
) %>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
<%= render "header", action: "create" %>
|
<%= render "header", action: "create" %>
|
||||||
|
|
||||||
<%= render "form", heading: @heading, path: admin_budget_group_headings_path(@budget, @group), action: "create" %>
|
<%= render Admin::BudgetHeadings::FormComponent.new(
|
||||||
|
@heading,
|
||||||
|
path: admin_budget_group_headings_path(@budget, @group),
|
||||||
|
action: "create"
|
||||||
|
) %>
|
||||||
|
|||||||
Reference in New Issue
Block a user