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

275817 - Use i18n bay resource #80

Merged
merged 16 commits into from
Jan 31, 2024
Merged
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
6 changes: 3 additions & 3 deletions app/controllers/bays_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create

respond_to do |format|
if @bay.save
format.html { redirect_to bays_path, notice: 'la baie a été ajoutée.' }
format.html { redirect_to bays_path, notice: t(".flashes.created") }
format.json { render :show, status: :created, location: @bay }
else
format.html { render :new }
Expand All @@ -64,7 +64,7 @@ def create
def update
respond_to do |format|
if @bay.update(bay_params)
format.html { redirect_to bays_path, notice: 'La baie a été mise à jour.' }
format.html { redirect_to bays_path, notice: t(".flashes.updated") }
format.json { render :show, status: :ok, location: @bay }
else
format.html { render :edit }
Expand All @@ -76,7 +76,7 @@ def update
def destroy
if @bay.destroy
respond_to do |format|
format.html { redirect_to bays_url, notice: 'Bay a bien été supprimé.' }
format.html { redirect_to bays_url, notice: t(".flashes.destroyed") }
format.json { head :no_content }
end
else
Expand Down
18 changes: 9 additions & 9 deletions app/views/bays/_export_button.html.erb
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Exports <span class="caret"></span>
<%= t("export_button.label") %> <span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">

<li class="dropdown-submenu pull-left">
<%= link_to bay_path(bay, format: 'pdf', view: 'front', bg: ''), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Export PDF
<%= t("export_button.exports.pdf") %>
<% end %>
<ul class="dropdown-menu dropdown-menu-left">
<li>
<%= link_to bay_path(bay, format: 'pdf', view: 'front', bg: ''), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Face avant
<%= t("export_button.faces.front") %>
<% end %>
</li>
<li>
<%= link_to bay_path(bay, format: 'pdf', view: 'back', bg: ''), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Face arrière
<%= t("export_button.faces.back") %>
<% end %>
</li>
<li>
<%= link_to bay_path(bay, format: 'pdf', view: 'front', bg: 'cablage'), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Cablage - Face avant
<%= t("export_button.faces.front_wiring") %>
<% end %>
</li>
<li>
<%= link_to bay_path(bay, format: 'pdf', view: 'back', bg: 'cablage'), target: :_blank do %>
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
Cablage - Face arrière
<%= t("export_button.faces.back_wiring") %>
<% end %>
</li>
</ul>
</li>

<li><%= link_to bay_path(bay, format: 'txt', view: '', bg: '') do %>
<span class="glyphicon glyphicon-text-background" aria-hidden="true"></span>
Export Txt
<%= t("export_button.exports.txt") %>
<% end %>
</li>

<li><%= link_to bay_path(bay, format: 'pdf', view: 'front', bg: '', debug: '1'), target: :_blank do %>
<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
Impression
<%= t("export_button.exports.print") %>
<% end %>
</li>

<li role="separator" class="divider"></li>

<li><%= link_to ports_path(room_id: bay.islet.room_id, bay_id: bay.id) do %>
<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>
Liste des ports
<%= t("export_button.port_list") %>
<% end %>
</li>

Expand Down
6 changes: 3 additions & 3 deletions app/views/bays/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<%= render FormErrorsComponent.new(@bay) %>

<div class="form-group">
<%= f.label 'Salle et Ilot', class: "col-sm-2 control-label" %>
<%= f.label :islet_id, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.select :islet_id, options_from_collection_for_select(Islet.includes(:room).all, :id, :name_with_room, @bay.islet_id), class: "form-control" %>
</div>
</div>

<div class="form-group">
<%= f.label 'Ligne', class: "col-sm-2 control-label" %>
<%= f.label :lane, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :lane, class: "form-control" %>
</div>
Expand All @@ -23,7 +23,7 @@
</div>

<div class="form-group">
<%= f.label 'Type de baie', class: "col-sm-2 control-label" %>
<%= f.label :bay_type_id, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.select :bay_type_id, options_from_collection_for_select(BayType.all, :id, :to_s, @bay.bay_type_id), class: "form-control" %>
</div>
Expand Down
10 changes: 6 additions & 4 deletions app/views/bays/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("inventories") => modeles_url,
'Baies et doubles-baies' => bays_path,
Bay.model_name.human.pluralize => bays_path,
@bay.frames.map(&:name).join(' - ') => ''}
%>

<div class="container">
<div class="page-header">
<%= link_to bays_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<%= link_to @bay, class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-info-sign"></span>
Voir
<%= t("action.show") %>
<% end %>
<h1>Modifier la baie <%= @bay.bay_type_id == 2 ? 'double' : 'simple' %> <%= @bay.frames.map(&:name).join(' / ') %> </h1>
<h1>
<%= t(".title", type: @bay.bay_type&.name, frames: @bay.frames.map(&:name).join(' / ')) %>
</h1>
</div>

<%= render 'form' %>
Expand Down
63 changes: 39 additions & 24 deletions app/views/bays/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: {t("inventories") => modeles_url, 'Baies et doubles-baies' => ''} %>
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
t("inventories") => modeles_url,
Bay.model_name.human.pluralize => "" }
%>

<div class="container-fluid">

Expand All @@ -13,21 +16,35 @@
<div class="page-header">
<%= link_to new_bay_path, class: 'btn btn-primary btn-disabled' do %>
<span class="glyphicon glyphicon-plus"></span>
Ajouter une baie ou un couple de baies
<%= t('.new') %>
<% end %>
<h1>Baies et doubles-baies</h1>
<h1>
<%= t('.title') %>
</h1>
</div>

<div class="table-responsive">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Salle</th>
<th>Ilot</th>
<th>Baies</th>
<th>Ligne</th>
<th>Position</th>
<th>Nombre de serveurs</th>
<th>
<%= Room.model_name.human %>
</th>
<th>
<%= Islet.model_name.human %>
</th>
<th>
<%= Frame.model_name.human.pluralize %>
</th>
<th>
<%= Bay.human_attribute_name(:lane) %>
</th>
<th>
<%= Bay.human_attribute_name(:position) %>
</th>
<th>
<%= Server.model_name.human.pluralize %>
</th>
<th></th>
</tr>
</thead>
Expand All @@ -41,28 +58,26 @@
<td>
<%= link_to bay.islet, islet_path(bay.islet) %>
</td>

<td>
<%=
bay.frames.map do |frame|
link_to(frame.name, frame_path(frame))
end.join(' / ').html_safe
%>
</td>

<td><%= bay.lane %> </td>
<td><%= bay.position %> </td>

<td><%= pluralize(bay.materials.count, 'serveur', 'serveurs') %> </td>

<td class="text-right">
<%= render partial: "bays/export_button", locals: { bay: bay } %>
<%= link_to 'Modifier', edit_bay_path(bay), class: 'btn btn-primary' %>
<%= link_to 'Supprimer',
bay,
method: :delete,
data: { confirm: 'Cette baie ne pourra pas être supprimée tant qu\'elle est associée à au moins un chassis. Voulez-vous continuer ?' },
class: 'btn btn-danger' %>
<td><%= bay.lane %></td>
<td><%= bay.position %></td>
<td><%= Bay.human_attribute_name(:materials_count, count: bay.materials.count) %> </td>
<td>
<div class="btn-group btn-group-sm btn-group-vertical" role="group" aria-label="...">
<%= render partial: "bays/export_button", locals: { bay: bay } %>
<%= link_to t("action.edit"), edit_bay_path(bay), class: 'btn btn-primary' %>
<%= link_to t("action.delete"),
bay,
method: :delete,
data: { confirm: t(".delete_confirmation") },
class: 'btn btn-danger' %>
</div>
</td>
</tr>
<% end %>
Expand Down
14 changes: 8 additions & 6 deletions app/views/bays/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<%= render 'layouts/breadcrumb', breadcrumb_variables: {
<%= render "layouts/breadcrumb", breadcrumb_variables: {
t("inventories") => modeles_url,
'Baies et doubles-baies' => bays_path,
'Nouvelle baie' => ''}
%>
Bay.model_name.human.pluralize => bays_path,
t(".title") => ""
}%>

<div class="container">
<div class="page-header">
<%= link_to bays_path, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-list-alt"></span>
Retour
<%= t("action.back") %>
<% end %>
<h1>Ajouter une baie</h1>
<h1>
<%= t(".title") %>
</h1>
</div>

<%= render 'form' %>
Expand Down
16 changes: 8 additions & 8 deletions app/views/bays/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<% provide :title, "Double baie #{@bay}" %>
<% provide :title, t(".title", bay: @bay, bay_type: @bay.bay_type&.name) %>
<%
breadcrumb_variables = { t("visualization") => overview_rooms_path, @bay.room.name => room_path(@bay.room, view: params[:view]) }
if @bay.islet.name.present?
breadcrumb_variables["Ilot #{@bay.islet.name}"] = room_path(@bay.room, islet: @bay.islet.name, view: params[:view])
breadcrumb_variables["#{Islet.model_name.human} #{@bay.islet.name}"] = room_path(@bay.room, islet: @bay.islet.name, view: params[:view])
elsif params[:islet].present?
breadcrumb_variables["Ilot #{params[:islet]}"] = ''
breadcrumb_variables["#{Islet.model_name.human} #{params[:islet]}"] = ''
end
breadcrumb_variables["Double baie #{@bay}"] = ''
breadcrumb_variables[t(".title", bay: @bay, bay_type: @bay.bay_type&.name)] = ''
%>
<%= render 'layouts/breadcrumb', breadcrumb_variables: breadcrumb_variables %>

<div class="container-fluid" id="bay-container">
<%= render partial: 'servers/room', locals: {
room: @bay.room,
islets: @servers_per_frames[@bay.islet.room_id],
title: @bay.frames.size > 1 ? "Double baie #{@bay}" : @bay,
view_side: params[:view],
room: @bay.room,
islets: @servers_per_frames[@bay.islet.room_id],
title: Bay.human_attribute_name(:bay_frames, count: @bay.frames.size, bay: @bay),
view_side: params[:view],
} %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion app/views/bays/show.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $('.couple .overviewed_frame[data-bay-id=<%= @bay.id %>]').addClass('selected')
$('#bay-container').html("<%= escape_javascript(render partial: 'servers/room', locals: {
room: @bay.room,
islets: @servers_per_frames[@bay.islet.room_id],
title: @bay.frames.size > 1 ? "Double baie #{@bay}" : @bay,
title: Bay.human_attribute_name(:bay_frames, count: @bay.frames.count, bay: @bay),
view_side: params[:view]}) %>")

var searchParams = new URLSearchParams(window.location.search)
Expand Down
Loading
Loading