mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
sprintId can now be updated on Issue
This commit is contained in:
@@ -45,7 +45,13 @@ export async function deleteIssue(id: number) {
|
|||||||
|
|
||||||
export async function updateIssue(
|
export async function updateIssue(
|
||||||
id: number,
|
id: number,
|
||||||
updates: { title?: string; description?: string; assigneeId?: number | null; status?: string },
|
updates: {
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
sprintId?: number | null;
|
||||||
|
assigneeId?: number | null;
|
||||||
|
status?: string;
|
||||||
|
},
|
||||||
) {
|
) {
|
||||||
return await db.update(Issue).set(updates).where(eq(Issue.id, id)).returning();
|
return await db.update(Issue).set(updates).where(eq(Issue.id, id)).returning();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,18 @@ export default async function issueUpdate(req: BunRequest) {
|
|||||||
|
|
||||||
const title = url.searchParams.get("title") || undefined;
|
const title = url.searchParams.get("title") || undefined;
|
||||||
const description = url.searchParams.get("description") || undefined;
|
const description = url.searchParams.get("description") || undefined;
|
||||||
|
const sprintIdParam = url.searchParams.get("sprintId");
|
||||||
const assigneeIdParam = url.searchParams.get("assigneeId");
|
const assigneeIdParam = url.searchParams.get("assigneeId");
|
||||||
const status = url.searchParams.get("status") || undefined;
|
const status = url.searchParams.get("status") || undefined;
|
||||||
|
|
||||||
// Parse assigneeId: "null" means unassign, number means assign, undefined means no change
|
// parse sprintId: "null" means unassign, number means assign, undefined means no change
|
||||||
|
let sprintId: number | null | undefined;
|
||||||
|
if (sprintIdParam === "null") {
|
||||||
|
sprintId = null;
|
||||||
|
} else if (sprintIdParam) {
|
||||||
|
sprintId = Number(sprintIdParam);
|
||||||
|
}
|
||||||
|
// same for assigneeId
|
||||||
let assigneeId: number | null | undefined;
|
let assigneeId: number | null | undefined;
|
||||||
if (assigneeIdParam === "null") {
|
if (assigneeIdParam === "null") {
|
||||||
assigneeId = null;
|
assigneeId = null;
|
||||||
@@ -23,13 +31,14 @@ export default async function issueUpdate(req: BunRequest) {
|
|||||||
assigneeId = Number(assigneeIdParam);
|
assigneeId = Number(assigneeIdParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!title && !description && assigneeId === undefined && !status) {
|
if (!title && !description && sprintId === undefined && assigneeId === undefined && !status) {
|
||||||
return new Response("no updates provided", { status: 400 });
|
return new Response("no updates provided", { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
const issue = await updateIssue(Number(id), {
|
const issue = await updateIssue(Number(id), {
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
sprintId,
|
||||||
assigneeId,
|
assigneeId,
|
||||||
status,
|
status,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export async function update({
|
|||||||
issueId,
|
issueId,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
|
sprintId,
|
||||||
assigneeId,
|
assigneeId,
|
||||||
status,
|
status,
|
||||||
onSuccess,
|
onSuccess,
|
||||||
@@ -13,6 +14,7 @@ export async function update({
|
|||||||
issueId: number;
|
issueId: number;
|
||||||
title?: string;
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
sprintId?: number | null;
|
||||||
assigneeId?: number | null;
|
assigneeId?: number | null;
|
||||||
status?: string;
|
status?: string;
|
||||||
} & ServerQueryInput) {
|
} & ServerQueryInput) {
|
||||||
@@ -20,6 +22,9 @@ export async function update({
|
|||||||
url.searchParams.set("id", `${issueId}`);
|
url.searchParams.set("id", `${issueId}`);
|
||||||
if (title !== undefined) url.searchParams.set("title", title);
|
if (title !== undefined) url.searchParams.set("title", title);
|
||||||
if (description !== undefined) url.searchParams.set("description", description);
|
if (description !== undefined) url.searchParams.set("description", description);
|
||||||
|
if (sprintId !== undefined) {
|
||||||
|
url.searchParams.set("sprintId", sprintId === null ? "null" : `${sprintId}`);
|
||||||
|
}
|
||||||
if (assigneeId !== undefined) {
|
if (assigneeId !== undefined) {
|
||||||
url.searchParams.set("assigneeId", assigneeId === null ? "null" : `${assigneeId}`);
|
url.searchParams.set("assigneeId", assigneeId === null ? "null" : `${assigneeId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user