Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/assets/vue/mixins/NotificationMixin.js

59 lines
1.5 KiB

import { mapFields } from "vuex-map-fields"
import { useNotification } from "../composables/notification"
export default {
setup() {
const notification = useNotification()
const showError = (error) => {
notification.showErrorNotification(error)
}
const showMessage = (message, type = "success") => {
switch (type) {
case "info":
notification.showInfoNotification(message)
break
case "success":
notification.showSuccessNotification(message)
break
case "error":
case "danger":
notification.showErrorNotification(message)
break
case "warning":
notification.showWarningNotification(message)
break
}
}
return {
showError,
showMessage,
}
},
methods: {
showError(error) {
this.showMessage(error, "error") // Use 'error' for PrimeVue
},
showMessage(message, type = "success") {
// Convert message type to PrimeVue's severity
let severity = type
if (type === "danger") {
severity = "error" // PrimeVue uses 'error' instead of 'danger'
}
// Use PrimeVue's ToastService
this.$toast.add({
severity: severity,
summary: message,
detail: "",
life: 5000, // Message duration in milliseconds
closable: true, // Whether the message can be closed manually
})
},
},
computed: {
...mapFields("notifications", ["color", "show", "subText", "text", "timeout"]),
},
}