Skip to content

Commit 999c94b

Browse files
committed
Check the table contents after a bulk action has completed
This avoids issues where the current page is empty but a bulk interaction is still taking place which would remove any remaining items. See https://www.woltlab.com/community/thread/316255/
1 parent 37b7fc0 commit 999c94b

4 files changed

Lines changed: 19 additions & 8 deletions

File tree

ts/WoltLabSuite/Core/Component/GridView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ export class GridView {
124124
this.#table.addEventListener("interaction:reset-selection", () => {
125125
this.#state.resetSelection();
126126
});
127+
128+
this.#table.addEventListener("interaction:bulk-completed", () => {
129+
this.#checkEmptyTable();
130+
});
127131
}
128132

129133
#setupState(

ts/WoltLabSuite/Core/Component/Interaction/Bulk/Rpc.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ async function handleRpcInteraction(
2525
return;
2626
}
2727

28-
const snackbar = showProgressSnackbar(label, objectIds.length);
28+
const length = objectIds.length;
29+
const snackbar = showProgressSnackbar(label, length);
2930

30-
for (let i = 0; i < objectIds.length; i++) {
31-
if (confirmationType == ConfirmationType.Delete) {
31+
for (let i = 0; i < length; i++) {
32+
if (confirmationType === ConfirmationType.Delete) {
3233
await deleteObject(endpoint.replace(/%s/, objectIds[i].toString()));
3334
} else {
3435
await postObject(
@@ -44,7 +45,7 @@ async function handleRpcInteraction(
4445
continue;
4546
}
4647

47-
if (confirmationType == ConfirmationType.Delete) {
48+
if (confirmationType === ConfirmationType.Delete) {
4849
element.dispatchEvent(
4950
new CustomEvent("interaction:remove", {
5051
bubbles: true,
@@ -61,6 +62,7 @@ async function handleRpcInteraction(
6162

6263
snackbar.markAsDone();
6364
container.dispatchEvent(new CustomEvent("interaction:reset-selection"));
65+
container.dispatchEvent(new CustomEvent("interaction:bulk-completed"));
6466
}
6567

6668
export function setup(identifier: string, container: HTMLElement): void {

wcfsetup/install/files/js/WoltLabSuite/Core/Component/GridView.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wcfsetup/install/files/js/WoltLabSuite/Core/Component/Interaction/Bulk/Rpc.js

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)