Fixed and finished the search function

This commit is contained in:
2025-12-31 17:57:57 +00:00
parent 53f1df5e86
commit 1f49db69c9
9 changed files with 360 additions and 214 deletions

View File

@@ -1,9 +1,9 @@
const STATES = [
{ key: "completed", label: "Completed" },
{ key: "manager_review", label: "Manager Review" },
{ key: "in_progress", label: "In Progress" },
{ key: "not_started", label: "Not Started" },
{ key: "comments", label: "Comments" }
{ key: "completed", label: "Completed" },
{ key: "manager_review", label: "Manager Review" },
{ key: "in_progress", label: "In Progress" },
{ key: "not_started", label: "Not Started" },
{ key: "comments", label: "Comments" },
];
function isMobile() {
@@ -20,9 +20,9 @@ function populateMobileControls(items) {
itemSelect.innerHTML = "<option value=''>Select competency</option>";
fromSelect.innerHTML = "<option value=''>From</option>";
toSelect.innerHTML = "<option value=''>To</option>";
toSelect.innerHTML = "<option value=''>To</option>";
items.forEach(item => {
items.forEach((item) => {
const opt = document.createElement("option");
opt.value = item.id;
opt.textContent = item.title;
@@ -30,7 +30,7 @@ function populateMobileControls(items) {
itemSelect.appendChild(opt);
});
STATES.forEach(s => {
STATES.forEach((s) => {
fromSelect.appendChild(new Option(s.label, s.key));
toSelect.appendChild(new Option(s.label, s.key));
});
@@ -46,8 +46,8 @@ function populateMobileControls(items) {
document.getElementById("move-confirm").addEventListener("click", async () => {
const itemId = document.getElementById("move-item").value;
const from = document.getElementById("move-from").value;
const to = document.getElementById("move-to").value;
const from = document.getElementById("move-from").value;
const to = document.getElementById("move-to").value;
if (!itemId || !to) {
alert("Select an item and target column");
@@ -62,7 +62,7 @@ document.getElementById("move-confirm").addEventListener("click", async () => {
const res = await fetch(`/api/competencies/items/${itemId}/state`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ state: to })
body: JSON.stringify({ state: to }),
});
if (res.ok) {
@@ -72,8 +72,6 @@ document.getElementById("move-confirm").addEventListener("click", async () => {
}
});
let draggedItemId = null;
function countByState(items) {
@@ -113,11 +111,11 @@ function createColumn(state, items, counts) {
<span class="kanban-title">${state.label}</span>
<span class="kanban-count">${counts[state.key] || 0}</span>
`;
const list = document.createElement("div");
list.className = "kanban-list";
list.addEventListener("dragover", e => e.preventDefault());
list.addEventListener("dragover", (e) => e.preventDefault());
list.addEventListener("drop", async () => {
if (!draggedItemId) return;
@@ -125,7 +123,7 @@ function createColumn(state, items, counts) {
const res = await fetch(`/api/competencies/items/${draggedItemId}/state`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ state: state.key })
body: JSON.stringify({ state: state.key }),
});
if (res.ok) {
@@ -136,8 +134,8 @@ function createColumn(state, items, counts) {
});
items
.filter(i => i.state === state.key)
.forEach(i => list.appendChild(createCard(i)));
.filter((i) => i.state === state.key)
.forEach((i) => list.appendChild(createCard(i)));
col.appendChild(header);
col.appendChild(list);
@@ -152,12 +150,11 @@ function renderBoard(items) {
const counts = countByState(items);
STATES.forEach(state => {
STATES.forEach((state) => {
board.appendChild(createColumn(state, items, counts));
});
}
async function loadBoard() {
const res = await fetch("/api/competencies/items");
const items = await res.json();
@@ -165,5 +162,4 @@ async function loadBoard() {
populateMobileControls(items);
}
loadBoard();