ツール管理へ戻る

v3 → v4 の差分

--- v3
+++ v4
@@ -23,7 +23,7 @@
     }
 
     main {
-      width: min(100%, 960px);
+      width: min(100%, 1100px);
       margin: 0 auto;
       padding: 28px;
       background: #fff;
@@ -51,7 +51,7 @@
 
     table {
       width: 100%;
-      min-width: 680px;
+      min-width: 900px;
       border-collapse: collapse;
       table-layout: fixed;
     }
@@ -70,10 +70,6 @@
       border-right: 0;
     }
 
-    tbody tr:last-child td {
-      border-bottom: 1px solid #cbd5e1;
-    }
-
     thead th {
       background: #eff6ff;
       color: #1e3a8a;
@@ -93,8 +89,12 @@
     }
 
     .column-number {
-      width: 72px;
+      width: 60px;
       text-align: center;
+    }
+
+    .column-name {
+      width: 190px;
     }
 
     .column-count {
@@ -102,11 +102,11 @@
     }
 
     .column-time {
+      width: 235px;
+    }
+
+    .column-subtotal {
       width: 190px;
-    }
-
-    .column-subtotal {
-      width: 200px;
     }
 
     .column-action {
@@ -116,7 +116,7 @@
 
     input {
       width: 100%;
-      min-width: 80px;
+      min-width: 0;
       padding: 9px;
       border: 1px solid #9ca3af;
       border-radius: 6px;
@@ -129,11 +129,19 @@
       border-color: #2563eb;
     }
 
+    .time-input-row {
+      display: flex;
+      align-items: center;
+      gap: 8px;
+    }
+
+    .time-input-row input {
+      flex: 1 1 auto;
+    }
+
     .unit {
-      display: block;
-      margin-top: 4px;
+      flex: 0 0 auto;
       color: #526071;
-      font-size: 0.85rem;
     }
 
     .subtotal {
@@ -222,13 +230,14 @@
   <main>
     <h1>総作業時間計算</h1>
     <p class="description">
-      作業ごとに件数と1件あたりの時間を入力してください。小計と合計は入力に合わせて更新されます。
+      作業名、件数、1件あたりの時間を入力してください。小計と合計は入力に合わせて更新されます。
     </p>
 
     <div class="table-wrap">
       <table aria-label="作業時間一覧">
         <colgroup>
           <col class="column-number">
+          <col class="column-name">
           <col class="column-count">
           <col class="column-time">
           <col class="column-subtotal">
@@ -237,6 +246,7 @@
         <thead>
           <tr>
             <th scope="col" class="column-number">No.</th>
+            <th scope="col">作業名</th>
             <th scope="col">作業件数</th>
             <th scope="col">1件あたりの時間</th>
             <th scope="col">小計</th>
@@ -246,7 +256,7 @@
         <tbody id="work-list"></tbody>
         <tfoot>
           <tr>
-            <th scope="row" colspan="3">合計</th>
+            <th scope="row" colspan="4">合計</th>
             <td id="grand-total">0分</td>
             <td></td>
           </tr>
@@ -297,8 +307,7 @@
     }
 
     function setSubtotal(row, minutes) {
-      const subtotalCell = row.querySelector(".subtotal");
-      subtotalCell.textContent = formatDuration(minutes);
+      row.querySelector(".subtotal").textContent = formatDuration(minutes);
     }
 
     function updateTotals() {
@@ -328,6 +337,12 @@
         }
 
         const subtotal = count * minutesPerItem;
+
+        if (!Number.isFinite(subtotal)) {
+          setSubtotal(row, 0);
+          continue;
+        }
+
         setSubtotal(row, subtotal);
         totalMinutes += subtotal;
       }
@@ -335,12 +350,27 @@
       grandTotalCell.textContent = formatDuration(totalMinutes);
     }
 
+    function renumberRows() {
+      for (const [index, row] of [...workList.querySelectorAll("tr")].entries()) {
+        row.querySelector(".row-number").textContent = String(index + 1);
+      }
+    }
+
     function addWorkRow() {
       const row = document.createElement("tr");
 
       const numberCell = document.createElement("th");
       numberCell.scope = "row";
-      numberCell.className = "column-number";
+      numberCell.className = "column-number row-number";
+
+      const nameCell = document.createElement("td");
+      const nameInput = document.createElement("input");
+      nameInput.type = "text";
+      nameInput.name = "workName";
+      nameInput.maxLength = 100;
+      nameInput.placeholder = "例:資料作成";
+      nameInput.setAttribute("aria-label", "作業名");
+      nameCell.append(nameInput);
 
       const countCell = document.createElement("td");
       const countInput = document.createElement("input");
@@ -355,6 +385,9 @@
       countCell.append(countInput);
 
       const timeCell = document.createElement("td");
+      const timeRow = document.createElement("div");
+      timeRow.className = "time-input-row";
+
       const timeInput = document.createElement("input");
       timeInput.type = "number";
       timeInput.name = "minutes";
@@ -368,7 +401,9 @@
       const timeUnit = document.createElement("span");
       timeUnit.className = "unit";
       timeUnit.textContent = "分";
-      timeCell.append(timeInput, timeUnit);
+
+      timeRow.append(timeInput, timeUnit);
+      timeCell.append(timeRow);
 
       const subtotalCell = document.createElement("td");
       subtotalCell.className = "subtotal";
@@ -391,21 +426,13 @@
       });
 
       actionCell.append(removeButton);
-      row.append(numberCell, countCell, timeCell, subtotalCell, actionCell);
+      row.append(numberCell, nameCell, countCell, timeCell, subtotalCell, actionCell);
       workList.append(row);
 
       renumberRows();
       message.textContent = "";
-      countInput.focus();
+      nameInput.focus();
       updateTotals();
-    }
-
-    function renumberRows() {
-      const rows = workList.querySelectorAll("tr");
-
-      rows.forEach((row, index) => {
-        row.querySelector("th").textContent = String(index + 1);
-      });
     }
 
     function calculateAndValidate() {