feat: project colors, timeline filters, sidebar fix, GitLooper agent, and misc improvements

- Fix sidebar double-highlight on /vacations/my (Gitea #6): add isNavItemActive() helper
- Add project color picker (schema + API + modal + timeline rendering)
- Add ProjectCombobox/ResourceCombobox to timeline toolbar
- Show PENDING vacations on timeline with dashed/dimmed style
- Add "show demand projects" preference with localStorage persistence
- Add ProjectAssignmentsTable with total hours/cost columns
- Extend vacation API to accept status arrays
- Add GitLooper formal YAML agent configuration
- Extend user admin with permission overrides UI
- Add delete-assignment use case tests
- Add status-styles.ts shared badge constants
- Centralize formatMoney/formatCents in format.ts

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
2026-03-17 10:22:52 +01:00
parent b0e55786c3
commit eb283147d1
34 changed files with 1545 additions and 255 deletions
@@ -2,16 +2,21 @@ import { describe, expect, it, vi } from "vitest";
import { deleteAssignment } from "../index.js";
describe("deleteAssignment", () => {
it("deletes an explicit assignment row", async () => {
it("deletes an assignment without demand link", async () => {
const db = {
assignment: {
findUnique: vi.fn().mockResolvedValue({
id: "assignment_1",
projectId: "project_1",
resourceId: "resource_1",
demandRequirementId: null,
}),
delete: vi.fn().mockResolvedValue({}),
},
demandRequirement: {
findUnique: vi.fn(),
update: vi.fn(),
},
};
const result = await deleteAssignment(db as never, "assignment_1");
@@ -20,9 +25,76 @@ describe("deleteAssignment", () => {
deletedId: "assignment_1",
projectId: "project_1",
resourceId: "resource_1",
reopenedDemandId: null,
});
expect(db.assignment.delete).toHaveBeenCalledWith({
where: { id: "assignment_1" },
});
expect(db.demandRequirement.findUnique).not.toHaveBeenCalled();
});
it("re-opens a COMPLETED demand when its assignment is deleted", async () => {
const db = {
assignment: {
findUnique: vi.fn().mockResolvedValue({
id: "assignment_1",
projectId: "project_1",
resourceId: "resource_1",
demandRequirementId: "demand_1",
}),
delete: vi.fn().mockResolvedValue({}),
},
demandRequirement: {
findUnique: vi.fn().mockResolvedValue({
id: "demand_1",
headcount: 0,
status: "COMPLETED",
}),
update: vi.fn().mockResolvedValue({}),
},
};
const result = await deleteAssignment(db as never, "assignment_1");
expect(result).toEqual({
deletedId: "assignment_1",
projectId: "project_1",
resourceId: "resource_1",
reopenedDemandId: "demand_1",
});
expect(db.demandRequirement.update).toHaveBeenCalledWith({
where: { id: "demand_1" },
data: { headcount: 1, status: "ACTIVE" },
});
});
it("increments headcount on an ACTIVE demand when its assignment is deleted", async () => {
const db = {
assignment: {
findUnique: vi.fn().mockResolvedValue({
id: "assignment_1",
projectId: "project_1",
resourceId: "resource_1",
demandRequirementId: "demand_2",
}),
delete: vi.fn().mockResolvedValue({}),
},
demandRequirement: {
findUnique: vi.fn().mockResolvedValue({
id: "demand_2",
headcount: 2,
status: "ACTIVE",
}),
update: vi.fn().mockResolvedValue({}),
},
};
const result = await deleteAssignment(db as never, "assignment_2");
expect(result.reopenedDemandId).toBe("demand_2");
expect(db.demandRequirement.update).toHaveBeenCalledWith({
where: { id: "demand_2" },
data: { headcount: 3, status: "ACTIVE" },
});
});
});
@@ -1,13 +1,15 @@
import type { Prisma, PrismaClient } from "@planarchy/db";
import { AllocationStatus } from "@planarchy/shared";
type DbClient =
| Pick<PrismaClient, "assignment">
| Pick<Prisma.TransactionClient, "assignment">;
| Pick<PrismaClient, "assignment" | "demandRequirement">
| Pick<Prisma.TransactionClient, "assignment" | "demandRequirement">;
export interface DeleteAssignmentResult {
deletedId: string;
projectId: string;
resourceId: string;
reopenedDemandId: string | null;
}
export async function deleteAssignment(
@@ -20,6 +22,7 @@ export async function deleteAssignment(
id: true,
projectId: true,
resourceId: true,
demandRequirementId: true,
},
});
@@ -31,9 +34,31 @@ export async function deleteAssignment(
where: { id: assignment.id },
});
// Reverse demand fill progress: re-open the demand if the assignment was linked
let reopenedDemandId: string | null = null;
if (assignment.demandRequirementId) {
const demand = await db.demandRequirement.findUnique({
where: { id: assignment.demandRequirementId },
select: { id: true, headcount: true, status: true },
});
if (demand) {
const wasCompleted = demand.status === AllocationStatus.COMPLETED;
await db.demandRequirement.update({
where: { id: demand.id },
data: {
headcount: wasCompleted ? 1 : demand.headcount + 1,
status: AllocationStatus.ACTIVE,
},
});
reopenedDemandId = demand.id;
}
}
return {
deletedId: assignment.id,
projectId: assignment.projectId,
resourceId: assignment.resourceId,
reopenedDemandId,
};
}