Move dashboard actions partial to a component
Note that, in order to be consistent with most form components, we're also moving the `form_for` part of the code to the component.
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<div class="dashboard-action-form">
|
||||
<%= form_for dashboard_action, url: { action: url_action } do |f| %>
|
||||
<%= render "shared/errors" %>
|
||||
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :action_type %>
|
||||
<% ::Dashboard::Action.action_types.keys.each do |action_type_value| %>
|
||||
<span class="margin-right">
|
||||
<%= f.radio_button :action_type, action_type_value %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column margin-top">
|
||||
<%= f.check_box :active %>
|
||||
</div>
|
||||
|
||||
<div id="request_to_administrators" class="small-12 column margin-bottom">
|
||||
<%= f.check_box :request_to_administrators %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row expanded">
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :title %>
|
||||
|
||||
<div id="short_description">
|
||||
<%= f.text_field :short_description %>
|
||||
</div>
|
||||
|
||||
<%= f.text_area :description, class: "html-area" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row expanded margin-top">
|
||||
<div class="small-12 column">
|
||||
<%= f.check_box :published_proposal %>
|
||||
<p class="help-text"><%= t("admin.dashboard.actions.form.published_proposal_help_text") %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row expanded margin-top">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.number_field :day_offset, step: 1,
|
||||
min: 0,
|
||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.number_field :required_supports, step: 1,
|
||||
min: 0,
|
||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.number_field :order, step: 1,
|
||||
min: 0,
|
||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if feature?(:allow_attached_documents) %>
|
||||
<div class="small-12 column">
|
||||
<%= render Documents::NestedComponent.new(f) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="links small-12 column">
|
||||
<%= render "links/nested_links", linkable: dashboard_action, f: f %>
|
||||
</div>
|
||||
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= f.submit(class: "button expanded", value: t("admin.dashboard.actions.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
8
app/components/admin/dashboard/actions/form_component.rb
Normal file
8
app/components/admin/dashboard/actions/form_component.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class Admin::Dashboard::Actions::FormComponent < ApplicationComponent
|
||||
attr_reader :dashboard_action, :url_action
|
||||
|
||||
def initialize(dashboard_action, url_action:)
|
||||
@dashboard_action = dashboard_action
|
||||
@url_action = url_action
|
||||
end
|
||||
end
|
||||
@@ -1,76 +0,0 @@
|
||||
<%= render "shared/errors" %>
|
||||
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.label :action_type %>
|
||||
<% ::Dashboard::Action.action_types.keys.each do |action_type_value| %>
|
||||
<span class="margin-right">
|
||||
<%= f.radio_button :action_type, action_type_value %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column margin-top">
|
||||
<%= f.check_box :active %>
|
||||
</div>
|
||||
|
||||
<div id="request_to_administrators" class="small-12 column margin-bottom">
|
||||
<%= f.check_box :request_to_administrators %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row expanded">
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :title %>
|
||||
|
||||
<div id="short_description">
|
||||
<%= f.text_field :short_description %>
|
||||
</div>
|
||||
|
||||
<%= f.text_area :description, class: "html-area" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row expanded margin-top">
|
||||
<div class="small-12 column">
|
||||
<%= f.check_box :published_proposal %>
|
||||
<p class="help-text"><%= t("admin.dashboard.actions.form.published_proposal_help_text") %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row expanded margin-top">
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.number_field :day_offset, step: 1,
|
||||
min: 0,
|
||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.number_field :required_supports, step: 1,
|
||||
min: 0,
|
||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-4 column">
|
||||
<%= f.number_field :order, step: 1,
|
||||
min: 0,
|
||||
hint: t("admin.dashboard.actions.form.help_text") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if feature?(:allow_attached_documents) %>
|
||||
<div class="small-12 column">
|
||||
<%= render Documents::NestedComponent.new(f) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="links small-12 column">
|
||||
<%= render "links/nested_links", linkable: dashboard_action, f: f %>
|
||||
</div>
|
||||
|
||||
<div class="row expanded">
|
||||
<div class="small-12 medium-6 large-4 column">
|
||||
<%= f.submit(class: "button expanded", value: t("admin.dashboard.actions.form.submit_button")) %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -3,8 +3,4 @@
|
||||
<h2><%= t("admin.dashboard.actions.edit.editing") %></h2>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-action-form ">
|
||||
<%= form_for dashboard_action, url: { action: "update" } do |f| %>
|
||||
<%= render "form", f: f %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render Admin::Dashboard::Actions::FormComponent.new(dashboard_action, url_action: "update") %>
|
||||
|
||||
@@ -3,8 +3,4 @@
|
||||
<h2><%= t("admin.dashboard.actions.new.creating") %></h2>
|
||||
</div>
|
||||
|
||||
<div class="dashboard-action-form ">
|
||||
<%= form_for dashboard_action, url: { action: "create" } do |f| %>
|
||||
<%= render "form", f: f %>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render Admin::Dashboard::Actions::FormComponent.new(dashboard_action, url_action: "create") %>
|
||||
|
||||
Reference in New Issue
Block a user