added move to top button for task presets
This commit is contained in:
@@ -70,22 +70,28 @@ function buildTaskCard(task) {
|
||||
|
||||
const actions = document.createElement("div");
|
||||
actions.className = "task-actions";
|
||||
const moveTopBtn = document.createElement("button");
|
||||
moveTopBtn.type = "button";
|
||||
moveTopBtn.className = "ghost move-top";
|
||||
moveTopBtn.textContent = "Top";
|
||||
moveTopBtn.setAttribute("aria-label", "Move task to top");
|
||||
moveTopBtn.setAttribute("title", "Move to top");
|
||||
const moveUpBtn = document.createElement("button");
|
||||
moveUpBtn.type = "button";
|
||||
moveUpBtn.className = "ghost icon-btn move-up";
|
||||
moveUpBtn.textContent = "↑";
|
||||
moveUpBtn.className = "ghost move-up";
|
||||
moveUpBtn.textContent = "Up";
|
||||
moveUpBtn.setAttribute("aria-label", "Move task up");
|
||||
moveUpBtn.setAttribute("title", "Move up");
|
||||
const moveDownBtn = document.createElement("button");
|
||||
moveDownBtn.type = "button";
|
||||
moveDownBtn.className = "ghost icon-btn move-down";
|
||||
moveDownBtn.textContent = "↓";
|
||||
moveDownBtn.className = "ghost move-down";
|
||||
moveDownBtn.textContent = "Down";
|
||||
moveDownBtn.setAttribute("aria-label", "Move task down");
|
||||
moveDownBtn.setAttribute("title", "Move down");
|
||||
const addBelowBtn = document.createElement("button");
|
||||
addBelowBtn.type = "button";
|
||||
addBelowBtn.className = "ghost icon-btn add-below";
|
||||
addBelowBtn.textContent = "+";
|
||||
addBelowBtn.className = "ghost add-below";
|
||||
addBelowBtn.textContent = "Add";
|
||||
addBelowBtn.setAttribute("aria-label", "Add task below");
|
||||
addBelowBtn.setAttribute("title", "Add below");
|
||||
const duplicateBtn = document.createElement("button");
|
||||
@@ -96,11 +102,18 @@ function buildTaskCard(task) {
|
||||
duplicateBtn.setAttribute("title", "Duplicate");
|
||||
const deleteBtn = document.createElement("button");
|
||||
deleteBtn.type = "button";
|
||||
deleteBtn.className = "ghost icon-btn delete";
|
||||
deleteBtn.textContent = "🗑";
|
||||
deleteBtn.className = "ghost delete";
|
||||
deleteBtn.textContent = "Delete";
|
||||
deleteBtn.setAttribute("aria-label", "Delete task");
|
||||
deleteBtn.setAttribute("title", "Delete");
|
||||
|
||||
moveTopBtn.addEventListener("click", () => {
|
||||
const first = tasksContainer.firstElementChild;
|
||||
if (!first || first === card) return;
|
||||
tasksContainer.insertBefore(card, first);
|
||||
updateTaskControls();
|
||||
});
|
||||
|
||||
moveUpBtn.addEventListener("click", () => {
|
||||
const previous = card.previousElementSibling;
|
||||
if (!previous) return;
|
||||
@@ -137,6 +150,7 @@ function buildTaskCard(task) {
|
||||
updateTaskControls();
|
||||
});
|
||||
|
||||
actions.appendChild(moveTopBtn);
|
||||
actions.appendChild(moveUpBtn);
|
||||
actions.appendChild(moveDownBtn);
|
||||
actions.appendChild(addBelowBtn);
|
||||
@@ -153,8 +167,10 @@ function buildTaskCard(task) {
|
||||
function updateTaskControls() {
|
||||
const cards = [...tasksContainer.querySelectorAll(".task-card")];
|
||||
cards.forEach((card, index) => {
|
||||
const moveTopBtn = card.querySelector(".move-top");
|
||||
const moveUpBtn = card.querySelector(".move-up");
|
||||
const moveDownBtn = card.querySelector(".move-down");
|
||||
if (moveTopBtn) moveTopBtn.disabled = index === 0;
|
||||
if (moveUpBtn) moveUpBtn.disabled = index === 0;
|
||||
if (moveDownBtn) moveDownBtn.disabled = index === cards.length - 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user