Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions ts/WoltLabSuite/Core/Component/Attachment/Entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
trackUploadProgress,
updateFileInformation,
} from "WoltLabSuite/Core/Component/File/Helper";
import { confirmationFactory } from "../Confirmation";

export type FileProcessorData = {
attachmentID: number;
Expand Down Expand Up @@ -108,7 +109,9 @@ function fileInitializationCompleted(element: HTMLElement, file: WoltlabCoreFile
}

const listItem = document.createElement("li");
listItem.append(getDeleteAttachButton(fileId, (data as FileProcessorData).attachmentID, editor, element));
listItem.append(
getDeleteAttachButton(fileId, (data as FileProcessorData).attachmentID, editor, element, file.filename),
);
dropdownMenu.append(listItem);

const moreOptions = document.createElement("button");
Expand Down Expand Up @@ -137,21 +140,25 @@ function getDeleteAttachButton(
attachmentId: number,
editor: HTMLElement,
element: HTMLElement,
filename: string | undefined,
): HTMLButtonElement {
const button = document.createElement("button");
button.type = "button";
button.textContent = getPhrase("wcf.global.button.delete");

button.addEventListener("click", () => {
void deleteFile(fileId).then((result) => {
result.unwrap();
button.addEventListener("click", async () => {
const confirmationResult = await confirmationFactory().delete(filename);
if (!confirmationResult) {
return;
}

dispatchToCkeditor(editor).removeAttachment({
attachmentId,
});
(await deleteFile(fileId)).unwrap();

element.remove();
dispatchToCkeditor(editor).removeAttachment({
attachmentId,
});

element.remove();
});

return button;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading