Move legislation process form partial to a component
This will make it easier to write tests for it.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<%= render "shared/globalize_locales", resource: @process %>
|
||||
<%= render "shared/globalize_locales", resource: process %>
|
||||
|
||||
<%= translatable_form_for [:admin, @process], html: { class: "legislation-process-form" } do |f| %>
|
||||
<%= translatable_form_for [:admin, process], html: { class: "legislation-process-form" } do |f| %>
|
||||
|
||||
<%= render "shared/errors", resource: @process %>
|
||||
<%= render "shared/errors", resource: process %>
|
||||
|
||||
<fieldset>
|
||||
<legend class="small-12 medium-4 column">
|
||||
@@ -18,7 +18,7 @@
|
||||
<%= f.date_field :draft_end_date, id: "draft_end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :draft_phase_enabled, checked: @process.draft_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :draft_phase_enabled, checked: process.draft_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<%= f.date_field :end_date, id: "end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :published, checked: @process.published?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :published, checked: process.published?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<%= f.date_field :debate_end_date, id: "debate_end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :debate_phase_enabled, checked: @process.debate_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :debate_phase_enabled, checked: process.debate_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<%= f.date_field :proposals_phase_end_date, id: "proposals_phase_end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :proposals_phase_enabled, checked: @process.proposals_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :proposals_phase_enabled, checked: process.proposals_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
<%= f.date_field :allegations_end_date, id: "allegations_end_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :allegations_phase_enabled, checked: @process.allegations_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :allegations_phase_enabled, checked: process.allegations_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<%= f.date_field :draft_publication_date, id: "draft_publication_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :draft_publication_enabled, checked: @process.draft_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :draft_publication_enabled, checked: process.draft_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
<%= f.date_field :result_publication_date, id: "result_publication_date" %>
|
||||
</div>
|
||||
<div class="small-12 medium-2 column margin-top">
|
||||
<%= f.check_box :result_publication_enabled, checked: @process.result_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
<%= f.check_box :result_publication_enabled, checked: process.result_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-3 column clear end">
|
||||
<%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %>
|
||||
<%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(process)}.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
11
app/components/admin/legislation/processes/form_component.rb
Normal file
11
app/components/admin/legislation/processes/form_component.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Admin::Legislation::Processes::FormComponent < ApplicationComponent
|
||||
include TranslatableFormHelper
|
||||
include GlobalizeHelper
|
||||
|
||||
attr_reader :process
|
||||
use_helpers :admin_submit_action
|
||||
|
||||
def initialize(process)
|
||||
@process = process
|
||||
end
|
||||
end
|
||||
@@ -9,5 +9,5 @@
|
||||
|
||||
<%= render "subnav", process: @process, active: "info" %>
|
||||
|
||||
<%= render "form" %>
|
||||
<%= render Admin::Legislation::Processes::FormComponent.new(@process) %>
|
||||
</div>
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
|
||||
<h2><%= t("admin.legislation.processes.new.title") %></h2>
|
||||
|
||||
<%= render "form" %>
|
||||
<%= render Admin::Legislation::Processes::FormComponent.new(@process) %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user