- Pull the status-management feature (drag reorder, add, delete with reassignment) out of ProjectConfigureView into its own StatusManager component. It fetches its own status list independently, so the view is left with just page chrome and the rename form (316 -> 106 lines). - Define ColumnChange once in lib/cardOrder.ts instead of duplicating the same type in AppSidebar.vue and ProjectView.vue. - Add composables/useDialog.ts for the Escape-to-close + focus-on-open behaviour shared by every confirm/reassign modal (and, without a focus target, plain dropdown menus). Used by ProjectManageMenu's delete-confirmation modal + its own menu, and StatusManager's reassignment modal.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { apiRequest } from './api'
|
|
import type { Card } from '../types'
|
|
|
|
/** A vuedraggable @change payload -- shared by every column that can be a
|
|
* drag source/target (a project's kanban columns, the sidebar's inbox). */
|
|
export type ColumnChange = {
|
|
added?: { element: Card; newIndex: number }
|
|
removed?: { element: Card; oldIndex: number }
|
|
moved?: { element: Card; oldIndex: number; newIndex: number }
|
|
}
|
|
|
|
/**
|
|
* Set the contents and order of one column -- the inbox (both null) or a
|
|
* project's status (both set). Shared by the sidebar's inbox list and a
|
|
* project's kanban columns, since either can be a drag source or target for
|
|
* the other (dragging a card in re-parents it; its old column is re-packed
|
|
* server-side).
|
|
*/
|
|
export async function reorderColumn(
|
|
projectId: number | null,
|
|
statusId: number | null,
|
|
cardIds: number[],
|
|
): Promise<{ cards: Card[] }> {
|
|
return apiRequest<{ cards: Card[] }>('/cards/order', {
|
|
method: 'PUT',
|
|
auth: true,
|
|
body: { project_id: projectId, status_id: statusId, card_ids: cardIds },
|
|
})
|
|
}
|