Skip to content

Commit f9e9956

Browse files
committed
Allow the refresh of all rows after an interactions has been executed
This is necessary if an interaction on a row indirectly leads to a change on other rows.
1 parent 0fe87c8 commit f9e9956

File tree

7 files changed

+41
-18
lines changed

7 files changed

+41
-18
lines changed

ts/WoltLabSuite/Core/Component/GridView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ export class GridView {
9494
}
9595

9696
#initEventListeners(): void {
97+
this.#table.addEventListener("interaction:refresh-all", () => {
98+
void this.#loadRows(StateChangeCause.Change);
99+
});
100+
97101
this.#table.addEventListener("refresh", (event) => {
98102
void this.#refreshRow(event.target as HTMLElement);
99103
});

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import { show as showNotification } from "WoltLabSuite/Core/Ui/Notification";
1313
import { ConfirmationType, handleConfirmation } from "./Confirmation";
1414

1515
async function handleRpcInteraction(
16+
container: HTMLElement,
1617
element: HTMLElement,
1718
objectName: string,
1819
endpoint: string,
1920
confirmationType: ConfirmationType,
2021
customConfirmationMessage: string = "",
22+
refreshAll = false,
2123
): Promise<void> {
2224
const confirmationResult = await handleConfirmation(objectName, confirmationType, customConfirmationMessage);
2325
if (!confirmationResult.result) {
@@ -49,11 +51,15 @@ async function handleRpcInteraction(
4951
);
5052
});
5153
} else {
52-
element.dispatchEvent(
53-
new CustomEvent("refresh", {
54-
bubbles: true,
55-
}),
56-
);
54+
if (refreshAll) {
55+
container.dispatchEvent(new CustomEvent("interaction:refresh-all"));
56+
} else {
57+
element.dispatchEvent(
58+
new CustomEvent("refresh", {
59+
bubbles: true,
60+
}),
61+
);
62+
}
5763

5864
// TODO: This shows a generic success message and should be replaced with a more specific message.
5965
showNotification();
@@ -64,11 +70,13 @@ export function setup(identifier: string, container: HTMLElement): void {
6470
container.addEventListener("interaction", (event: CustomEvent) => {
6571
if (event.detail.interaction === identifier) {
6672
void handleRpcInteraction(
73+
container,
6774
event.target as HTMLElement,
6875
event.detail.objectName,
6976
event.detail.endpoint,
7077
event.detail.confirmationType,
7178
event.detail.confirmationMessage,
79+
event.detail.refreshAll,
7280
);
7381
}
7482
});

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/Rpc.js

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

wcfsetup/install/files/lib/system/interaction/RpcInteraction.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public function __construct(
2626
protected readonly string|\Closure $languageItem,
2727
protected readonly InteractionConfirmationType $confirmationType = InteractionConfirmationType::None,
2828
protected readonly string|\Closure $confirmationMessage = '',
29-
?\Closure $isAvailableCallback = null
29+
?\Closure $isAvailableCallback = null,
30+
protected readonly bool $refreshAll = false,
3031
) {
3132
parent::__construct($identifier, $isAvailableCallback);
3233
}
@@ -75,6 +76,7 @@ public function render(DatabaseObject $object): string
7576
data-endpoint="{$endpoint}"
7677
data-confirmation-type="{$this->confirmationType->toString()}"
7778
data-confirmation-message="{$confirmationMessage}"
79+
data-refresh-all={$this->refreshAll}
7880
>
7981
{$label}
8082
</button>

wcfsetup/install/files/lib/system/interaction/admin/LanguageInteractions.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public function __construct()
2929
"setAsDefault",
3030
"core/languages/%s/default",
3131
"wcf.acp.language.setAsDefault",
32-
isAvailableCallback: static function (Language $language) {
33-
return !$language->isDefault;
34-
}
32+
isAvailableCallback: static fn(Language $language) => !$language->isDefault,
33+
refreshAll: true
3534
),
36-
new DeleteInteraction("core/languages/%s", static function (Language $language) {
37-
return $language->isDeletable();
38-
})
35+
new DeleteInteraction(
36+
"core/languages/%s",
37+
static fn(Language $language) => $language->isDeletable()
38+
)
3939
]);
4040

4141
EventHandler::getInstance()->fire(

wcfsetup/install/files/lib/system/interaction/admin/StyleInteractions.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public function __construct()
2727
'set-as-default',
2828
'core/styles/%s/set-as-default',
2929
'wcf.acp.style.button.setAsDefault',
30-
isAvailableCallback: static fn(Style $object) => !$object->isDefault
30+
isAvailableCallback: static fn(Style $object) => !$object->isDefault,
31+
refreshAll: true
3132
),
3233
]);
3334

0 commit comments

Comments
 (0)