Add progress bar polymorphic views

This commit is contained in:
Javi Martín
2019-01-04 15:05:15 +01:00
committed by decabeza
parent eaea95ccfb
commit 4f25581636
12 changed files with 327 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
<%= render "admin/shared/globalize_locales", resource: @progress_bar %>
<%= translatable_form_for [:admin, *resource_hierarchy_for(@progress_bar)] do |f| %>
<%= f.enum_select :kind %>
<%= f.translatable_fields do |translations_form| %>
<%= translations_form.text_field :title %>
<% end %>
<% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %>
<%= f.text_field :percentage, { type: :range, id: "percentage_range" }.merge(progress_options) %>
<%= f.text_field :percentage, { type: :number, label: false }.merge(progress_options) %>
<%= f.submit nil, class: "button success" %>
<% end %>

View File

@@ -0,0 +1,49 @@
<h2><%= t("admin.progress_bars.index.title") %></h2>
<% if progressable.progress_bars.any? %>
<table>
<thead>
<tr>
<th><%= ProgressBar.human_attribute_name("id") %></th>
<th><%= ProgressBar.human_attribute_name("kind") %></th>
<th><%= ProgressBar.human_attribute_name("title") %></th>
<th><%= ProgressBar.human_attribute_name("percentage") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<tbody>
<% progressable.progress_bars.each do |progress_bar| %>
<tr id="<%= dom_id(progress_bar) %>" class="progress-bar">
<td>
<%= progress_bar.id %>
</td>
<td><%= ProgressBar.human_attribute_name("kind.#{progress_bar.kind}") %></td>
<td><%= progress_bar.title %></td>
<td>
<%= number_to_percentage(progress_bar.percentage, strip_insignificant_zeros: true) %>
</td>
<td>
<%= link_to t("admin.actions.edit"),
polymorphic_path([:admin, *resource_hierarchy_for(progress_bar)],
action: :edit),
class: "button hollow expanded" %>
<%= link_to t("admin.actions.delete"),
polymorphic_path([:admin, *resource_hierarchy_for(progress_bar)]),
method: :delete,
class: "button hollow alert expanded" %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p><%= t("admin.progress_bars.index.no_progress_bars") %></p>
<% end %>
<p>
<%= link_to t("admin.progress_bars.index.new_progress_bar"),
polymorphic_path([:admin, *resource_hierarchy_for(progressable.progress_bars.new)],
action: :new),
class: "button hollow" %>
</p>

View File

@@ -0,0 +1,15 @@
<% if @progress_bar.primary? %>
<% bar_title = t("admin.progress_bars.edit.title.primary") %>
<% else %>
<% bar_title = t("admin.progress_bars.edit.title.secondary", title: @progress_bar.title) %>
<% end %>
<% provide :title do %>
<%= "#{t("admin.header.title")} - #{bar_title}" %>
<% end %>
<%= back_link_to progress_bars_index %>
<h2><%= bar_title %></h2>
<%= render "form" %>

View File

@@ -0,0 +1,7 @@
<% provide :title do %>
<%= "#{t("admin.header.title")} - #{t("admin.progress_bars.index.title")}" %>
<% end %>
<%= back_link_to polymorphic_path([:admin, *resource_hierarchy_for(@progressable)]) %>
<%= render "admin/progress_bars/progress_bars", progressable: @progressable %>

View File

@@ -0,0 +1,9 @@
<% provide :title do %>
<%= "#{t("admin.header.title")} - #{t("admin.progress_bars.new.creating")}" %>
<% end %>
<%= back_link_to progress_bars_index %>
<h2><%= t("admin.progress_bars.new.creating") %></h2>
<%= render "form" %>