farmitry_hvac/app/views/nutrient/edit_mixa.html.erb

87 lines
5.0 KiB
Plaintext

<div class="flex flex-col h-full lg:rounded-lg">
<div class="flex flex-row items-center space-x-4 p-2">
<%= link_to environment_index_path(id: params[:id]), class: "flex items-center" do %>
<i class="fa-solid fa-angle-left text-2xl"></i>
<% end %>
<div class="text-2xl font-bold leading-10"><%= @controller.id %>동 온도 스케줄러</div>
</div>
<div class="space-y-4 overflow-y-hidden divide-y divide-base-border bg-base-content rounded-lg p-4">
<%= form_with url: edit_temp_environment_path, method: :post, class: 'flex flex-col h-full' do %>
<%= hidden_field_tag :controller_id, params[:id] %>
<div class="flex flex-col divide-y divide-base-border overflow-y-hidden flex-1 space-y-4">
<%= submit_tag "업데이트", class: "btn bg-primary w-fit" %>
<div class="overflow-y-auto flex-1 min-h-0 border border-base-border rounded-lg">
<ul class="divide-y divide-base-border whitespace-nowrap relative">
<% if @schedule.present? %>
<% @schedule.each do |s| %>
<li class="flex justify-between items-center px-4 py-2 space-x-4 h-full relative">
<div class="flex items-center space-x-4 basis-3/5 h-full">
<!-- 시간 -->
<div class="flex flex-col lg:flex-row h-full items-center space-x-0 space-y-2 lg:space-x-4 lg:space-y-0">
<div class=" text-left w-full lg:w-auto">시간</div>
<div class="text-xl flex items-center space-x-1 w-full h-full">
<%= select_tag "schedule[#{s.id}][hour]",
options_for_select((0..23).map { |h| [h.to_s.rjust(2, '0'), h] }, s.hour),
class: "select-style min-w-[60px]" %>
<div>:</div>
<%= number_field_tag "schedule[#{s.id}][minute]",
s.minute, min: 0, max: 59, step: 1, inputmode: "decimal",
class: "input-style min-w-[60px]" %>
</div>
</div>
<!-- 온도 -->
<div class="flex flex-col lg:flex-row h-full items-center space-x-0 space-y-2 lg:space-x-4 lg:space-y-0">
<div class=" text-left w-full lg:w-auto">온도 (°C)</div>
<div class="text-xl flex items-center">
<%= number_field_tag "schedule[#{s.id}][temperature]", s.temperature, min: -99, max: 99, step: "0.1", inputmode: "decimal", class: "input-style min-w-[68px]" %>
</div>
</div>
</div>
<div class="flex items-center space-x-4 basis-2/5 justify-end h-full">
<!-- 사용 여부 -->
<div class="flex flex-col lg:flex-row items-center space-x-0 space-y-2 lg:space-x-4 lg:space-y-0 h-full">
<div class="">ON/OFF</div>
<label class="relative inline-flex items-center cursor-pointer h-full">
<%= check_box_tag "schedule[#{s.id}][is_active]", "1", s.is_active == true || s.is_active == 1, class: "sr-only peer" %>
<div class="toggle_style"></div>
<div class="btn-toggle-round"></div>
</label>
</div>
<!-- 삭제 -->
<div class="flex flex-col lg:flex-row items-center space-x-0 space-y-2 lg:space-x-4 lg:space-y-0 h-full relative">
<div class="">&nbsp;</div>
<%= link_to schedule_path(s),
data: { turbo_method: :delete, turbo_confirm: "정말 삭제하시겠습니까?" },
class: "btn bg-danger text-sm flex items-center px-2 py-0 my-1.5 lg:px-4 lg:py-1.5 lg:my-0" do %>
<div class="hidden lg:block">삭제</div>
<div class="block lg:hidden"><i class="fa-solid fa-xmark"></i></div>
<% end %>
</div>
</div>
</li>
<% end %>
<% else %>
<li class="text-center p-4 w-full">저장된 스케줄이 없습니다.</li>
<% end %>
</ul>
</div>
<div class="flex space-x-4">
<%= button_to "초기화", reset_schedule_path(params[:id]),
method: :post,
data: { turbo_confirm: "정말 초기화하시겠습니까? 모든 스케줄 데이터가 삭제됩니다." },
class: "btn bg-danger" %>
<%= button_to "추가하기", open_modals_path(type: "add_schedule", id: params[:id]),
class: "btn bg-default-slate",
data: {
turbo_method: :post,
turbo_frame: "modals"
} %>
</div>
</div>
<% end %>
</div>
</div>