-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathFormBuilderDialog.ts
More file actions
36 lines (30 loc) · 1.12 KB
/
FormBuilderDialog.ts
File metadata and controls
36 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Handles interactions that open a form builder dialog.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
import { show as showNotification } from "WoltLabSuite/Core/Ui/Notification";
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
async function handleFormBuilderDialogAction(element: HTMLElement, endpoint: string): Promise<void> {
const { ok } = await dialogFactory().usingFormBuilder().fromEndpoint(endpoint);
if (!ok) {
return;
}
element.dispatchEvent(
new CustomEvent("interaction:invalidate", {
bubbles: true,
}),
);
// TODO: This shows a generic success message and should be replaced with a more specific message.
showNotification();
}
export function setup(identifier: string, container: HTMLElement): void {
container.addEventListener("interaction:execute", (event: CustomEvent) => {
if (event.detail.interaction === identifier) {
void handleFormBuilderDialogAction(event.target as HTMLElement, event.detail.endpoint);
}
});
}