Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

362832 - Create a Modele block on Server pages #313

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 36 additions & 26 deletions app/views/servers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@
<%= render FormErrorsComponent.new(@server) %>

<%= render CardComponent.new(extra_classes: "bg-body-tertiary") do |card| %>
<% card.with_header do %>
<%= Modele.model_name.human %>
<% end %>

<div class="row g-3">
<fieldset class="col-md-6 col-12">
<%= f.label :modele_id, class: "form-label" %>
<%= f.collection_select(:modele_id,
Modele.all_sorted,
:id,
:name_with_brand,
{ prompt: true, include_blank: false },
{ class: "form-select", data: { controller: "select" } }) %>
</fieldset>

<fieldset class="col-md-6 col-12">
<%= f.label :network_types, class: "form-label" %>
<%= f.select :network_types,
Modele::Network::TYPES.map { |type| [Modele.human_attribute_name("network_types.#{type}"), type] },
{ prompt: true, include_blank: true },
{
class: "form-select",
data: { controller: "select" },
multiple: true,
placeholder: Modele.human_attribute_name("network_types.blank")
}
%>
<div id="networkTypesHelp" class="form-text fst-italic">
<i class="bi bi-info-circle me-1"></i>
<%= Modele.human_attribute_name("network_types.help") %>
</div>
</fieldset>
</div>
<% end %>

<%= render CardComponent.new(extra_classes: "bg-body-tertiary mt-4") do |card| %>
<div class="row g-3">
<fieldset class="col-md-6 col-12">
<%= f.label :name, class: "form-label" %>
Expand Down Expand Up @@ -43,32 +79,6 @@
{ class: "form-select", data: { controller: "select" } }) %>
</fieldset>

<fieldset class="col-md-6 col-12 mt-4">
<%= f.label :modele_id, class: "form-label" %>
<%= f.collection_select(:modele_id, Modele.all_sorted, :id,
:name_with_brand,
{ prompt: true, include_blank: false },
{ class: "form-select", data: { controller: "select" } }) %>
</fieldset>

<fieldset class="col-md-6 col-12 mt-4">
<%= f.label :network_types, class: "form-label" %>
<%= f.select :network_types,
Modele::Network::TYPES.map { |type| [Modele.human_attribute_name("network_types.#{type}"), type] },
{ prompt: true, include_blank: true },
{
class: "form-select",
data: { controller: "select" },
multiple: true,
placeholder: Modele.human_attribute_name("network_types.blank")
}
%>
<div id="networkTypesHelp" class="form-text fst-italic">
<i class="bi bi-info-circle me-1"></i>
<%= Modele.human_attribute_name("network_types.help") %>
</div>
</fieldset>

<fieldset class="col-md-6 col-12 mt-4">
<%= f.label :stack_id, class: "form-label" %>
<%= f.collection_select(:stack_id, Stack.order(:id), :id, :name, { prompt: true, include_blank: true },
Expand Down
52 changes: 23 additions & 29 deletions app/views/servers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,18 @@
<div class="row row-cols-1 row-cols-lg-2 row-gap-4">
<div class="col">
<%= render CardComponent.new do |card| %>
<dl class="show-page_dl d-grid row-gap-2 mb-0">
<dt class="pb-2"><%= Category.model_name.human %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.modele.try(:category) %></dd>

<dt class="pb-2"><%= Modele.human_attribute_name(:nb_elts) %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.modele.try(:nb_elts) %></dd>
<% card.with_header do %>
<%= Modele.model_name.human %>
<% end %>

<dt class="pb-2"><%= Architecture.model_name.human %></dt>
<dl class="show-page_dl d-grid row-gap-2 mb-0">
<dt class="pb-2"><%= Modele.model_name.human %></dt>
<dd class="mb-0 pb-2 ps-3">
<%= link_to @server.modele.try(:architecture), architecture_path(@server.modele.try(:architecture)) %>
<%= link_to @server.modele, modele_path(@server.modele) if @server.modele.try(:name) %>
</dd>

<dt class="pb-2"><%= t(".nb_u") %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.modele.try(:u) %></dd>
<dt class="pb-2"><%= Category.model_name.human %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.modele.try(:category) %></dd>

<dt class="pb-2"><%= Manufacturer.model_name.human %></dt>
<dd class="mb-0 pb-2 ps-3">
Expand All @@ -112,11 +110,24 @@
<% end %>
</dd>

<dt class="pb-2"><%= Modele.model_name.human %></dt>
<dt class="pb-2"><%= Modele.human_attribute_name(:nb_elts) %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.modele.try(:nb_elts) %></dd>

<dt class="pb-2"><%= Architecture.model_name.human %></dt>
<dd class="mb-0 pb-2 ps-3">
<%= link_to @server.modele, modele_path(@server.modele) if @server.modele.try(:name) %>
<%= link_to @server.modele.try(:architecture), architecture_path(@server.modele.try(:architecture)) %>
</dd>

<dt class="pb-2"><%= t(".nb_u") %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.modele.try(:u) %></dd>

<dt class="pb-2"><%= Server.human_attribute_name(:network_types) %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.decorated.network_types_to_human %></dd>
</dl>
<% end %>

<%= render CardComponent.new(extra_classes: "mt-4") do |card| %>
<dl class="show-page_dl d-grid row-gap-2 mb-0">
<dt class="pb-2"><%= Server.human_attribute_name(:numero) %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.try(:numero) %></dd>

Expand Down Expand Up @@ -160,23 +171,6 @@
<% end %>
<% end if @server.modele.present? %>
</dd>

<dt class="pb-2"><%= Disk.model_name.human.pluralize %></dt>
<dd class="mb-0 pb-2 ps-3">
<% @server.disks.each do |disk| %>
<div><%= disk %></div>
<% end %>
</dd>

<dt class="pb-2"><%= MemoryComponent.model_name.human %></dt>
<dd class="mb-0 pb-2 ps-3">
<% @server.memory_components.each do |memory_component| %>
<span><%= memory_component %></span>
<% end %>
</dd>

<dt class="pb-2"><%= Server.human_attribute_name(:network_types) %></dt>
<dd class="mb-0 pb-2 ps-3"><%= @server.decorated.network_types_to_human %></dd>
</dl>
<% end %>

Expand Down
Loading