Add Stimulus toast controller

This commit is contained in:
Andreas Nedbal 2023-02-11 06:16:42 +01:00 committed by Andreas Nedbal
parent b38a048e92
commit 4c0948c6d1
2 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,17 @@
import { Controller } from '@hotwired/stimulus';
import { showNotification } from "utilities/notifications";
export default class extends Controller<HTMLElement> {
static values = {
message: String,
success: Boolean
};
declare readonly messageValue: string;
declare readonly successValue: boolean;
connect(): void {
showNotification(this.messageValue, this.successValue);
this.element.remove();
}
}

View File

@ -9,6 +9,7 @@ import ThemeController from "retrospring/controllers/theme_controller";
import CapabilitiesController from "retrospring/controllers/capabilities_controller";
import CropperController from "retrospring/controllers/cropper_controller";
import InboxSharingController from "retrospring/controllers/inbox_sharing_controller";
import ToastController from "retrospring/controllers/toast_controller";
/**
* This module sets up Stimulus and our controllers
@ -29,4 +30,5 @@ export default function (): void {
window['Stimulus'].register('format-popup', FormatPopupController);
window['Stimulus'].register('inbox-sharing', InboxSharingController);
window['Stimulus'].register('theme', ThemeController);
window['Stimulus'].register('toast', ToastController);
}