add report draft editing warn popup
All checks were successful
deploy / build-and-deploy (push) Successful in 30s
All checks were successful
deploy / build-and-deploy (push) Successful in 30s
This commit is contained in:
@@ -197,12 +197,13 @@ export const report = {
|
|||||||
if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId });
|
if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId });
|
||||||
|
|
||||||
await db.transaction(async (tx) => {
|
await db.transaction(async (tx) => {
|
||||||
|
if (reportCreatedAt) await tx.editReport({ id: input.reportId, createdAt: reportCreatedAt });
|
||||||
|
|
||||||
await tx.editReportStatus(input);
|
await tx.editReportStatus(input);
|
||||||
|
|
||||||
if (input.strikeReasonId) {
|
if (input.strikeReasonId) {
|
||||||
await db.editStrike({
|
await db.editStrike({
|
||||||
reportId: input.reportId,
|
reportId: input.reportId,
|
||||||
at: reportCreatedAt,
|
|
||||||
strikeReasonId: input.strikeReasonId
|
strikeReasonId: input.strikeReasonId
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -59,9 +59,15 @@
|
|||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
async function onSaveButtonClick() {
|
async function onSaveButtonClick() {
|
||||||
|
let popupMessage;
|
||||||
|
if (report!.createdAt) popupMessage = 'Sollen die Änderungen am Report gespeichert werden?';
|
||||||
|
else
|
||||||
|
popupMessage = `Der Report ist aktuell noch ein Entwurf. Mit den Änderungen wird der Report kein Entwurf mehr sein, und der Ersteller kann ihn nicht mehr bearbeiten.\n
|
||||||
|
Sollen die Änderungen am Report trotzdem gespeichert werden?`;
|
||||||
|
|
||||||
$confirmPopupState = {
|
$confirmPopupState = {
|
||||||
title: 'Änderungen speichern?',
|
title: 'Änderungen speichern?',
|
||||||
message: 'Sollen die Änderungen am Report gespeichert werden?',
|
message: popupMessage,
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
if (reportedUser?.id != report?.reported?.id) {
|
if (reportedUser?.id != report?.reported?.id) {
|
||||||
report!.reported = reportedUser;
|
report!.reported = reportedUser;
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ export type AddReportReq = {
|
|||||||
|
|
||||||
export type EditReportReq = {
|
export type EditReportReq = {
|
||||||
id: number;
|
id: number;
|
||||||
reportedId: number | null;
|
reportedId?: number | null;
|
||||||
|
createdAt?: Date | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SubmitReportReq = {
|
export type SubmitReportReq = {
|
||||||
@@ -76,7 +77,8 @@ export async function editReport(db: Database, values: EditReportReq) {
|
|||||||
return db
|
return db
|
||||||
.update(report)
|
.update(report)
|
||||||
.set({
|
.set({
|
||||||
reportedId: values.reportedId
|
reportedId: values.reportedId,
|
||||||
|
createdAt: values.createdAt ?? undefined
|
||||||
})
|
})
|
||||||
.where(eq(report.id, values.id));
|
.where(eq(report.id, values.id));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user