ツール管理へ戻るv5 → v6 の差分
--- v5
+++ v6
@@ -23,7 +23,7 @@
}
main {
- width: min(100%, 1200px);
+ width: min(100%, 1250px);
margin: 0 auto;
padding: 28px;
background: #fff;
@@ -51,7 +51,7 @@
table {
width: 100%;
- min-width: 960px;
+ min-width: 1040px;
border-collapse: collapse;
table-layout: fixed;
}
@@ -107,23 +107,23 @@
}
.column-name {
- width: 190px;
+ width: 180px;
}
.column-count {
- width: 150px;
+ width: 140px;
}
.column-time {
- width: 235px;
+ width: 220px;
}
.column-subtotal {
- width: 190px;
+ width: 180px;
}
.column-action {
- width: 100px;
+ width: 206px;
text-align: center;
}
@@ -186,18 +186,39 @@
white-space: nowrap;
}
- .remove-button {
- padding: 7px 10px;
- border: 1px solid #b42318;
+ .action-buttons {
+ display: flex;
+ justify-content: center;
+ flex-wrap: wrap;
+ gap: 6px;
+ }
+
+ .remove-button,
+ .duplicate-button {
+ padding: 7px 9px;
border-radius: 6px;
background: #fff;
- color: #b42318;
font: inherit;
cursor: pointer;
+ white-space: nowrap;
+ }
+
+ .remove-button {
+ border: 1px solid #b42318;
+ color: #b42318;
}
.remove-button:hover {
background: #fef3f2;
+ }
+
+ .duplicate-button {
+ border: 1px solid #1d4ed8;
+ color: #1d4ed8;
+ }
+
+ .duplicate-button:hover {
+ background: #eff6ff;
}
.actions {
@@ -279,7 +300,7 @@
<main>
<h1>総作業時間計算</h1>
<p class="description">
- 作業名、件数、1件あたりの時間を入力してください。左端の「↕」をドラッグすると、作業の順序を変更できます。
+ 作業名、件数、1件あたりの時間を入力してください。左端の「↕」をドラッグすると順序を変更できます。「複製」で作業を直下にコピーできます。
</p>
<div class="table-wrap">
@@ -412,21 +433,22 @@
const number = index + 1;
row.querySelector(".row-number").textContent = String(number);
- const nameInput = row.querySelector('input[name="workName"]');
- const countInput = row.querySelector('input[name="count"]');
- const timeInput = row.querySelector('input[name="minutes"]');
- const dragHandle = row.querySelector(".drag-handle");
- const removeButton = row.querySelector(".remove-button");
-
- nameInput.setAttribute("aria-label", `作業 ${number} の作業名`);
- countInput.setAttribute("aria-label", `作業 ${number} の作業件数`);
- timeInput.setAttribute("aria-label", `作業 ${number} の1件あたりの時間`);
- dragHandle.setAttribute("aria-label", `作業 ${number} をドラッグして並べ替え`);
- removeButton.setAttribute("aria-label", `作業 ${number} を削除`);
+ row.querySelector('input[name="workName"]')
+ .setAttribute("aria-label", `作業 ${number} の作業名`);
+ row.querySelector('input[name="count"]')
+ .setAttribute("aria-label", `作業 ${number} の作業件数`);
+ row.querySelector('input[name="minutes"]')
+ .setAttribute("aria-label", `作業 ${number} の1件あたりの時間`);
+ row.querySelector(".drag-handle")
+ .setAttribute("aria-label", `作業 ${number} をドラッグして並べ替え`);
+ row.querySelector(".remove-button")
+ .setAttribute("aria-label", `作業 ${number} を削除`);
+ row.querySelector(".duplicate-button")
+ .setAttribute("aria-label", `作業 ${number} を複製`);
});
}
- function addWorkRow() {
+ function createWorkRow(values = {}) {
const row = document.createElement("tr");
row.draggable = false;
@@ -452,6 +474,7 @@
nameInput.maxLength = 100;
nameInput.placeholder = "例:資料作成";
nameInput.setAttribute("aria-label", "作業名");
+ nameInput.value = values.name ?? "";
nameCell.append(nameInput);
const countCell = document.createElement("td");
@@ -464,6 +487,7 @@
countInput.placeholder = "例:8";
countInput.setAttribute("aria-label", "作業件数");
countInput.required = true;
+ countInput.value = values.count ?? "";
countCell.append(countInput);
const timeCell = document.createElement("td");
@@ -479,6 +503,7 @@
timeInput.placeholder = "例:15";
timeInput.setAttribute("aria-label", "1件あたりの時間");
timeInput.required = true;
+ timeInput.value = values.minutes ?? "";
const timeUnit = document.createElement("span");
timeUnit.className = "unit";
@@ -493,6 +518,9 @@
const actionCell = document.createElement("td");
actionCell.className = "column-action";
+
+ const actionButtons = document.createElement("div");
+ actionButtons.className = "action-buttons";
const removeButton = document.createElement("button");
removeButton.type = "button";
@@ -507,7 +535,30 @@
updateTotals();
});
- actionCell.append(removeButton);
+ const duplicateButton = document.createElement("button");
+ duplicateButton.type = "button";
+ duplicateButton.className = "duplicate-button";
+ duplicateButton.textContent = "複製";
+ duplicateButton.setAttribute("aria-label", "この作業を複製");
+
+ duplicateButton.addEventListener("click", () => {
+ const duplicateValues = {
+ name: nameInput.value,
+ count: countInput.value,
+ minutes: timeInput.value
+ };
+
+ const duplicateRow = createWorkRow(duplicateValues);
+ workList.insertBefore(duplicateRow, row.nextSibling);
+ renumberRows();
+ updateTotals();
+ duplicateRow.querySelector('input[name="workName"]').focus();
+ reorderStatus.textContent = "作業を複製して直下に追加しました。";
+ });
+
+ actionButtons.append(removeButton, duplicateButton);
+ actionCell.append(actionButtons);
+
row.append(
dragCell,
numberCell,
@@ -517,11 +568,16 @@
subtotalCell,
actionCell
);
+
+ return row;
+ }
+
+ function addWorkRow() {
+ const row = createWorkRow();
workList.append(row);
-
renumberRows();
message.textContent = "";
- nameInput.focus();
+ row.querySelector('input[name="workName"]').focus();
updateTotals();
}
@@ -565,6 +621,7 @@
targetRow.classList.add("drop-target");
const position = getDropPosition(targetRow, event.clientY);
+
if (position === "before") {
workList.insertBefore(draggedRow, targetRow);
} else {
@@ -593,6 +650,7 @@
});
addWorkButton.addEventListener("click", addWorkRow);
+
calculateButton.addEventListener("click", () => {
message.textContent = "";
const rows = workList.querySelectorAll("tr");