Skip to content

Commit

Permalink
UPD: импрувит часть вьюшек, заменяет часть кода на паршиалы
Browse files Browse the repository at this point in the history
  • Loading branch information
owlscatcher committed Feb 16, 2024
1 parent 9be41dd commit 52ff532
Show file tree
Hide file tree
Showing 14 changed files with 402 additions and 415 deletions.
79 changes: 39 additions & 40 deletions app/views/admin/building/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,46 @@
</div>
<%= render 'shared/modal_button_add', path: new_admin_building_path, classes: "btn btn-primary w-100", text: t("b_add") %>
</div>
<div class="col-10 my-4 shadow rounded">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col"><%= t('activerecord.attributes.building.id') %></th>
<th scope="col"><%= t('activerecord.attributes.building.name') %></th>
<th scope="col"><%= t('activerecord.attributes.building.organization') %></th>
<th scope="col"><%= t('activerecord.attributes.building.description') %></th>
<th scope="col" style="width: 10%"><%= t('action') %></th>
</tr>
</thead>
<tbody>
<% @buildings.each do |building| %>
<tr class="align-middle">
<td><%= building.id %></td>
<td><%= building.name %></td>
<% if building.organization.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= building.organization.name %></td>
<% end %>
<% if building.description.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= building.description %></td>
<% end %>
<td>
<div class="d-flex">
<%= link_to edit_admin_building_path(building.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %>
<i class="bi bi-pen"></i>
<% end %>
<%= button_to admin_building_path(building.id), method: :delete, class: "btn" do %>
<i class="bi bi-trash"></i>
<% end %>
</div>
</td>
<div class="col-10 my-4 p-0">
<div class="shadow rounded px-2">
<div class="table-responsive">
<table class="table table-hover">
<%= render 'shared/ui/table/caption/all_items',
count: Building.count %>
<thead>
<tr>
<th scope="col"><%= t('activerecord.attributes.building.id') %></th>
<th scope="col"><%= t('activerecord.attributes.building.name') %></th>
<th scope="col"><%= t('activerecord.attributes.building.organization') %></th>
<th scope="col"><%= t('activerecord.attributes.building.description') %></th>

<%= render 'shared/ui/table/header/action'%>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% @buildings.each do |building| %>
<tr class="align-middle">
<td><%= building.id %></td>
<td><%= building.name %></td>
<% if building.organization.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= building.organization.name %></td>
<% end %>
<% if building.description.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= building.description %></td>
<% end %>

<%= render 'shared/ui/table/cell/action',
edit_path: edit_admin_building_path(building.id),
destroy_path: admin_building_path(building.id) %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down
100 changes: 48 additions & 52 deletions app/views/admin/channel/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,60 +42,56 @@
</div>
<%= render 'shared/modal_button_add', path: new_admin_channel_path, classes: "btn btn-primary w-100", text: t("b_add") %>
</div>
<div class="col-10 my-4 shadow rounded">
<div class="table-responsive">
<table class="table table-hover">
<thead class="text-nowrap">
<tr>
<th scope="col"><%= t('activerecord.attributes.channel.id') %></th>
<th scope="col"><%= t('activerecord.attributes.channel.channel_id')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.server')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.control_point.name')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.location_description')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.self_background')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.pre_emergency_limit')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.emergency_limit')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.consumption')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.conversion_coefficient')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.service')%></th>

<th scope="col" style="position: sticky; right: 0; background: white; z-index: 1;" style="width: 10%"><%= t('action') %></th>
</tr>
</thead>
<tbody class="text-nowrap">
<% @channels.each do |channel| %>
<tr class="align-middle">
<td><%= channel.id %></td>
<td><%= channel.channel_id %></td>
<td><%= channel.server.name %></td>
<% if channel.control_point.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= channel.control_point.name %>
<% end %>
<td><%= channel.location_description %></td>
<td><%= channel.self_background %></td>
<td><%= channel.pre_emergency_limit %></td>
<td><%= channel.emergency_limit %></td>
<td><%= channel.consumption %></td>
<td><%= channel.conversion_coefficient %></td>
<td><%= channel.service.name %></td>
<div class="col-10 my-4 p-0">
<div class="shadow rounded px-2">
<div class="table-responsive">
<table class="table table-hover">
<%= render 'shared/ui/table/caption/all_items',
count: Channel.count %>
<thead class="text-nowrap">
<tr>
<th scope="col"><%= t('activerecord.attributes.channel.id') %></th>
<th scope="col"><%= t('activerecord.attributes.channel.channel_id')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.server')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.control_point.name')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.location_description')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.self_background')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.pre_emergency_limit')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.emergency_limit')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.consumption')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.conversion_coefficient')%></th>
<th scope="col"><%= t('activerecord.attributes.channel.service')%></th>

<%= render 'shared/ui/table/header/action'%>
</tr>
</thead>
<tbody class="text-nowrap">
<% @channels.each do |channel| %>
<tr class="align-middle">
<td><%= channel.id %></td>
<td><%= channel.channel_id %></td>
<td><%= channel.server.name %></td>
<% if channel.control_point.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= channel.control_point.name %>
<% end %>
<td><%= channel.location_description %></td>
<td><%= channel.self_background %></td>
<td><%= channel.pre_emergency_limit %></td>
<td><%= channel.emergency_limit %></td>
<td><%= channel.consumption %></td>
<td><%= channel.conversion_coefficient %></td>
<td><%= channel.service.name %></td>

<td style="position: sticky; right: 0; background: white; z-index: 1;">
<div class="d-flex">
<%= link_to edit_admin_channel_path(channel.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %>
<i class="bi bi-pen"></i>
<% end %>
<%= button_to admin_channel_path(channel.id), method: :delete, class: "btn" do %>
<i class="bi bi-trash"></i>
<% end %>
</div>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= render 'shared/ui/table/cell/action',
edit_path: edit_admin_channel_path(channel.id),
destroy_path: admin_channel_path(channel.id) %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down
90 changes: 44 additions & 46 deletions app/views/admin/control_point/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,53 +30,51 @@
</div>
<%= render 'shared/modal_button_add', path: new_admin_control_point_path, classes: "btn btn-primary w-100", text: t("b_add") %>
</div>
<div class="col-10 my-4 shadow rounded">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col"><%= t('activerecord.attributes.control_point.name') %></th>
<th scope="col"><%= t('activerecord.attributes.control_point.room') %></th>
<th scope="col"><%= t('activerecord.attributes.control_point.device') %></th>
<th scope="col"><%= t('activerecord.attributes.control_point.description') %></th>
<th scope="col" style="width: 10%"><%= t('action') %></th>
</tr>
</thead>
<tbody>
<% @control_points.each do |control_point| %>
<tr class="align-middle">
<td><%= control_point.name %></td>
<% if control_point.room.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= control_point.room.name %></td>
<% end %>
<% if control_point.device.nil? %>
<td><%= "——" %></td>
<% else %>
<td>
<%= button_to "(#{sprintf("%05d", control_point.device.tabel_id)}) #{control_point.device.device_model.name}", admin_device_path(control_point.device.id), method: :get, class: "btn btn-light btn-sm" %>
</td>
<% end %>
<% if control_point.description.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= control_point.description %></td>
<% end %>
<td>
<div class="d-flex">
<%= link_to edit_admin_control_point_path(control_point.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %>
<i class="bi bi-pen"></i>
<% end %>
<%= button_to admin_control_point_path(control_point.id), method: :delete, class: "btn" do %>
<i class="bi bi-trash"></i>
<% end %>
</div>
</td>
<div class="col-10 my-4 p-0">
<div class="shadow rounded px-2">
<div class="table-responsive">
<table class="table table-hover">
<%= render 'shared/ui/table/caption/all_items',
count: ControlPoint.count %>
<thead>
<tr>
<th scope="col"><%= t('activerecord.attributes.control_point.name') %></th>
<th scope="col"><%= t('activerecord.attributes.control_point.room') %></th>
<th scope="col"><%= t('activerecord.attributes.control_point.device') %></th>
<th scope="col"><%= t('activerecord.attributes.control_point.description') %></th>
<%= render 'shared/ui/table/header/action'%>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody>
<% @control_points.each do |control_point| %>
<tr class="align-middle">
<td><%= control_point.name %></td>
<% if control_point.room.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= control_point.room.name %></td>
<% end %>
<% if control_point.device.nil? %>
<td><%= "——" %></td>
<% else %>
<td>
<%= button_to "(#{sprintf("%05d", control_point.device.tabel_id)}) #{control_point.device.device_model.name}", admin_device_path(control_point.device.id), method: :get, class: "btn btn-light btn-sm" %>
</td>
<% end %>
<% if control_point.description.nil? %>
<td><%= "——" %></td>
<% else %>
<td><%= control_point.description %></td>
<% end %>

<%= render 'shared/ui/table/cell/action',
edit_path: edit_admin_control_point_path(control_point.id),
destroy_path: admin_control_point_path(control_point.id) %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down
82 changes: 40 additions & 42 deletions app/views/admin/device_component/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,49 +36,47 @@
</div>
<%= render 'shared/modal_button_add', path: new_admin_device_component_path, classes: "btn btn-primary w-100 mb-3", text: t("b_add") %>
</div>
<div class="col-10 my-4 shadow rounded"">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr class="text-nowrap">
<th scope="col"><%= t('activerecord.attributes.device_component.serial_id')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.name')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.supplementary_kit')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.measurement_min')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.measurement_max')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.measuring_unit')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.description')%></th>
<th scope="col" style="width: 10%"><%= t('action')%></th>
</tr>
</thead>
<tbody>
<% @device_components.each do |device_component| %>
<tr>
<td><%= device_component.serial_id %></td>
<td><%= device_component.name %></td>
<% if device_component.supplementary_kit.nil? %>
<td></td>
<% else %>
<td><%= device_component.supplementary_kit.name %></td>
<% end %>
<td><%= device_component.measurement_min %></td>
<td><%= device_component.measurement_max %></td>
<td><%= device_component.measuring_unit %></td>
<td><%= device_component.description %></td>
<td>
<div class="d-flex w-auto">
<%= link_to edit_admin_device_component_path(device_component.id), class: "btn", data: { action: "click->modal#open", turbo_stream: "" } do %>
<i class="bi bi-pen"></i>
<% end %>
<%= button_to admin_device_component_path(device_component.id), method: :delete, form: { data: { turbo_confirm: t('delete_confirm') } }, class: "btn" do %>
<i class="bi bi-trash"></i>
<% end %>
</div>
</td>
<div class="col-10 my-4 p-0">
<div class="shadow rounded px-2">
<div class="table-responsive">
<table class="table table-hover">
<%= render 'shared/ui/table/caption/all_items',
count: DeviceComponent.count %>
<thead>
<tr class="text-nowrap">
<th scope="col"><%= t('activerecord.attributes.device_component.serial_id')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.name')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.supplementary_kit')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.measurement_min')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.measurement_max')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.measuring_unit')%></th>
<th scope="col"><%= t('activerecord.attributes.device_component.description')%></th>
<%= render 'shared/ui/table/header/action'%>
</tr>
<% end %>
</tbody>
</table>
</thead>
<tbody class="text-nowrap">
<% @device_components.each do |device_component| %>
<tr>
<td><%= device_component.serial_id %></td>
<td><%= device_component.name %></td>
<% if device_component.supplementary_kit.nil? %>
<td></td>
<% else %>
<td><%= device_component.supplementary_kit.name %></td>
<% end %>
<td><%= device_component.measurement_min %></td>
<td><%= device_component.measurement_max %></td>
<td><%= device_component.measuring_unit %></td>
<td><%= device_component.description %></td>

<%= render 'shared/ui/table/cell/action',
edit_path: edit_admin_device_component_path(device_component.id),
destroy_path: admin_device_component_path(device_component.id) %>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 52ff532

Please sign in to comment.