스케쥴 추가 기능 구현

This commit is contained in:
2025-04-19 00:07:28 +09:00
parent eb3bc33509
commit 32d0ac69c9
13 changed files with 141 additions and 63 deletions

View File

@@ -31,11 +31,11 @@
<div class="w-full h-full">
<% if flash[:notice] %>
<div class="m-4 rounded px-4 py-2 bg-accept text-white">
<%= flash[:notice] %>
<%= raw flash[:notice] %>
</div>
<% elsif flash[:alert] %>
<div class="m-4 rounded px-4 py-2 bg-danger text-white">
<%= flash[:alert] %>
<%= raw flash[:alert] %>
</div>
<% end %>
<%= yield %>

View File

@@ -1 +1,39 @@
스케쥴 추가
<%= form_with model: @schedule, method: :post, data: { turbo: false }, class: 'flex flex-col h-full divide-y divide-border-table-border' do |form| %>
<div class="flex-1 p-4">
<table class="base-table">
<thead>
<tr>
<th>시간</th>
<th>분</th>
<th>사용여부</th>
<th>온도</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<%= form.select :hour,
options_for_select((0..23).map { |h| [h.to_s.rjust(2, '0'), h] }, @schedule.hour),
{},
class: "input-style" %>
</td>
<td>
<%= form.number_field :minute,
min: 0, max: 59, step: 1, inputmode: "decimal", class: "input-style" %>
</td>
<td>
<%= check_box_tag "schedule[is_active]", "1", true %>
</td>
<td>
<%= form.number_field :temperature,
step: "0.1", inputmode: "decimal", class: "input-style" %>
</td>
</tr>
</tbody>
</table>
</div>
<div class="flex p-4">
<%= submit_tag "추가", class: "btn bg-primary" %>
</div>
<% end %>

View File

@@ -37,6 +37,6 @@
</div>
</div>
<div class="flex p-4">
<%= link_to "수정", "/modbus/schedule_edit", class: "btn bg-default-slate" %>
<%= link_to "수정", schedule_edit_schedules_path, class: "btn bg-default-slate" %>
</div>
</div>

View File

@@ -1,4 +1,4 @@
<%= form_with url: schedule_edit_update_modbus_index_path, method: :post, class: 'flex flex-col h-full divide-y divide-border-table-border' do %>
<%= form_with url: schedule_edit_update_schedules_path, method: :post, class: 'flex flex-col h-full divide-y divide-border-table-border' do %>
<div class="flex-1 p-4">
<table class="base-table">
<thead>
@@ -22,7 +22,7 @@
<td><%= check_box_tag "schedule[#{s.id}][is_active]", "1", s.is_active == true || s.is_active == 1 %></td>
<td><%= number_field_tag "schedule[#{s.id}][temperature]", s.temperature, step: "0.1", inputmode: "decimal", class: "input-style" %></td>
<td>
<%= link_to "삭제", modbus_path(s),
<%= link_to "삭제", schedule_path(s),
data: {
turbo_method: :delete,
turbo_confirm: "정말 삭제하시겠습니까?"