// Kanban: one lane per label of a status column; drag cards between lanes. import { html, useState } from '../vendor/preact-htm.mjs'; import { api } from './api.js'; import { navigate, boardPath, mutateBoard } from './store.js'; import { Icon, AvatarStack, textOn, fmtDate, fmtRange, Empty } from './ui.js'; import { labelOf, Cell } from './cells.js'; import * as A from './actions.js'; export function KanbanView({ board, view, items, hidden }) { const boardId = board.board.id; const statusCols = board.columns.filter((c) => c.type === 'status'); const col = statusCols.find((c) => c.id === view.settings?.column) || statusCols[0]; const [drag, setDrag] = useState(null); const [over, setOver] = useState(null); const [adding, setAdding] = useState(null); if (!col) return html`<${Empty} icon="kanban" title="Kanban needs a status column"> />`; const lanes = [...(col.settings.labels || []), { id: null, name: 'Empty', color: '#c4c4c4' }]; const people = board.columns.find((c) => c.type === 'people'); const date = board.columns.find((c) => c.type === 'date' || c.type === 'timeline'); const extra = board.columns.filter((c) => !hidden.includes(c.id) && c !== col && c !== people && c !== date && ['text', 'number', 'dropdown', 'tags'].includes(c.type)).slice(0, 3); const setCol = (id) => { mutateBoard(boardId, () => { view.settings = { ...view.settings, column: id }; }); api.patch(`/api/views/${view.id}`, { settings: { ...view.settings, column: id } }); }; return html`