diff --git a/app/components/admin/dashboard/actions/form_component.html.erb b/app/components/admin/dashboard/actions/form_component.html.erb new file mode 100644 index 000000000..9f0abfa14 --- /dev/null +++ b/app/components/admin/dashboard/actions/form_component.html.erb @@ -0,0 +1,80 @@ +
+ <%= form_for dashboard_action, url: { action: url_action } do |f| %> + <%= render "shared/errors" %> + +
+
+ <%= f.label :action_type %> + <% ::Dashboard::Action.action_types.keys.each do |action_type_value| %> + + <%= f.radio_button :action_type, action_type_value %> + + <% end %> +
+ +
+ <%= f.check_box :active %> +
+ +
+ <%= f.check_box :request_to_administrators %> +
+ +
+ +
+
+ <%= f.text_field :title %> + +
+ <%= f.text_field :short_description %> +
+ + <%= f.text_area :description, class: "html-area" %> +
+
+ +
+
+ <%= f.check_box :published_proposal %> +

<%= t("admin.dashboard.actions.form.published_proposal_help_text") %>

+
+
+ +
+
+ <%= f.number_field :day_offset, step: 1, + min: 0, + hint: t("admin.dashboard.actions.form.help_text") %> +
+ +
+ <%= f.number_field :required_supports, step: 1, + min: 0, + hint: t("admin.dashboard.actions.form.help_text") %> +
+ +
+ <%= f.number_field :order, step: 1, + min: 0, + hint: t("admin.dashboard.actions.form.help_text") %> +
+
+ + <% if feature?(:allow_attached_documents) %> +
+ <%= render Documents::NestedComponent.new(f) %> +
+ <% end %> + + + +
+
+ <%= f.submit(class: "button expanded", value: t("admin.dashboard.actions.form.submit_button")) %> +
+
+ <% end %> +
diff --git a/app/components/admin/dashboard/actions/form_component.rb b/app/components/admin/dashboard/actions/form_component.rb new file mode 100644 index 000000000..c64d511b3 --- /dev/null +++ b/app/components/admin/dashboard/actions/form_component.rb @@ -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 diff --git a/app/views/admin/dashboard/actions/_form.html.erb b/app/views/admin/dashboard/actions/_form.html.erb deleted file mode 100644 index a3a4301ea..000000000 --- a/app/views/admin/dashboard/actions/_form.html.erb +++ /dev/null @@ -1,76 +0,0 @@ -<%= render "shared/errors" %> - -
-
- <%= f.label :action_type %> - <% ::Dashboard::Action.action_types.keys.each do |action_type_value| %> - - <%= f.radio_button :action_type, action_type_value %> - - <% end %> -
- -
- <%= f.check_box :active %> -
- -
- <%= f.check_box :request_to_administrators %> -
- -
- -
-
- <%= f.text_field :title %> - -
- <%= f.text_field :short_description %> -
- - <%= f.text_area :description, class: "html-area" %> -
-
- -
-
- <%= f.check_box :published_proposal %> -

<%= t("admin.dashboard.actions.form.published_proposal_help_text") %>

-
-
- -
-
- <%= f.number_field :day_offset, step: 1, - min: 0, - hint: t("admin.dashboard.actions.form.help_text") %> -
- -
- <%= f.number_field :required_supports, step: 1, - min: 0, - hint: t("admin.dashboard.actions.form.help_text") %> -
- -
- <%= f.number_field :order, step: 1, - min: 0, - hint: t("admin.dashboard.actions.form.help_text") %> -
-
- -<% if feature?(:allow_attached_documents) %> -
- <%= render Documents::NestedComponent.new(f) %> -
-<% end %> - - - -
-
- <%= f.submit(class: "button expanded", value: t("admin.dashboard.actions.form.submit_button")) %> -
-
diff --git a/app/views/admin/dashboard/actions/edit.html.erb b/app/views/admin/dashboard/actions/edit.html.erb index 9ab97a45d..bb10835b5 100644 --- a/app/views/admin/dashboard/actions/edit.html.erb +++ b/app/views/admin/dashboard/actions/edit.html.erb @@ -3,8 +3,4 @@

<%= t("admin.dashboard.actions.edit.editing") %>

-
- <%= form_for dashboard_action, url: { action: "update" } do |f| %> - <%= render "form", f: f %> - <% end %> -
+<%= render Admin::Dashboard::Actions::FormComponent.new(dashboard_action, url_action: "update") %> diff --git a/app/views/admin/dashboard/actions/new.html.erb b/app/views/admin/dashboard/actions/new.html.erb index 67e8e54ad..e8b158f2c 100644 --- a/app/views/admin/dashboard/actions/new.html.erb +++ b/app/views/admin/dashboard/actions/new.html.erb @@ -3,8 +3,4 @@

<%= t("admin.dashboard.actions.new.creating") %>

-
- <%= form_for dashboard_action, url: { action: "create" } do |f| %> - <%= render "form", f: f %> - <% end %> -
+<%= render Admin::Dashboard::Actions::FormComponent.new(dashboard_action, url_action: "create") %>