Move progress bars form partial to a component

This way we can move some of the view logic to the Ruby class. It'll
also make it easier to write tests for it.
This commit is contained in:
Javi Martín
2024-10-11 22:39:08 +02:00
parent 9c057d5695
commit 233ba3c72f
4 changed files with 19 additions and 5 deletions

View File

@@ -1,42 +0,0 @@
<%= render "shared/globalize_locales", resource: @progress_bar %>
<%= translatable_form_for @progress_bar, url: admin_polymorphic_path(@progress_bar) do |f| %>
<div class="row">
<div class="small-12 medium-6 column">
<%= f.enum_select :kind %>
</div>
</div>
<div class="row">
<%= f.translatable_fields do |translations_form| %>
<div class="small-12 medium-6 column end">
<%= translations_form.text_field :title %>
</div>
<% end %>
</div>
<% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %>
<div class="row">
<div class="small-12 medium-6 large-2 column">
<%= f.label :percentage %>
<%= f.text_field :percentage, { type: :range,
id: "percentage_range",
label: false,
class: "column" }.merge(progress_options) %>
</div>
<div class="small-12 medium-6 large-2 column">
<div class="input-group">
<%= f.text_field :percentage, { type: :number,
label: false,
class: "input-group-field" }.merge(progress_options) %>
<span class="input-group-label">%</span>
</div>
</div>
<div class="column">
<%= f.submit nil, class: "button success" %>
</div>
</div>
<% end %>

View File

@@ -12,4 +12,4 @@
<h2><%= bar_title %></h2>
<%= render "form" %>
<%= render Admin::ProgressBars::FormComponent.new(@progress_bar) %>

View File

@@ -6,4 +6,4 @@
<h2><%= t("admin.progress_bars.new.creating") %></h2>
<%= render "form" %>
<%= render Admin::ProgressBars::FormComponent.new(@progress_bar) %>