2022-08-26 16:08:58 +02:00
|
|
|
import SnackbarComponent from "@/components/core/CustomSnackbar.vue";
|
2022-07-12 10:55:28 +02:00
|
|
|
import { App } from "vue";
|
|
|
|
|
|
|
|
export class Snackbar {
|
|
|
|
private app: App;
|
|
|
|
|
|
|
|
constructor(app: App) {
|
|
|
|
this.app = app;
|
|
|
|
}
|
|
|
|
|
|
|
|
open({
|
|
|
|
message,
|
|
|
|
variant,
|
|
|
|
position,
|
|
|
|
actionText,
|
|
|
|
cancelText,
|
|
|
|
onAction,
|
|
|
|
}: {
|
|
|
|
message?: string;
|
|
|
|
queue?: boolean;
|
|
|
|
indefinite?: boolean;
|
|
|
|
variant?: string;
|
|
|
|
position?: string;
|
|
|
|
actionText?: string;
|
|
|
|
cancelText?: string;
|
|
|
|
onAction?: () => any;
|
|
|
|
}) {
|
|
|
|
this.app.config.globalProperties.$oruga.notification.open({
|
|
|
|
component: SnackbarComponent,
|
|
|
|
props: {
|
|
|
|
message,
|
|
|
|
// queue,
|
|
|
|
// indefinite,
|
|
|
|
actionText,
|
|
|
|
cancelText,
|
|
|
|
onAction,
|
|
|
|
position: position ?? "bottom-right",
|
|
|
|
variant: variant ?? "dark",
|
|
|
|
},
|
|
|
|
position: position ?? "bottom-right",
|
|
|
|
variant: variant ?? "dark",
|
|
|
|
duration: 5000000,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const snackbarPlugin = {
|
|
|
|
install(app: App) {
|
|
|
|
const snackbar = new Snackbar(app);
|
|
|
|
app.config.globalProperties.$snackbar = snackbar;
|
|
|
|
app.provide("snackbar", snackbar);
|
|
|
|
},
|
|
|
|
};
|