parent
9633b45168
commit
dabfe7820b
@ -1,105 +1,28 @@ |
|||||||
import {mapFields} from 'vuex-map-fields'; |
import { mapFields } from 'vuex-map-fields'; |
||||||
import Snackbar from "../components/Snackbar.vue"; |
|
||||||
//import { useToast } from "vue-toastification";
|
|
||||||
// inside of a Vue file
|
|
||||||
|
|
||||||
//import { useQuasar } from 'quasar'
|
|
||||||
|
|
||||||
export default { |
export default { |
||||||
setup() { |
|
||||||
}, |
|
||||||
computed: { |
|
||||||
...mapFields('notifications', ['color', 'show', 'subText', 'text', 'timeout']) |
|
||||||
}, |
|
||||||
methods: { |
methods: { |
||||||
cleanState() { |
|
||||||
/*setTimeout(() => { |
|
||||||
this.show = false; |
|
||||||
}, this.timeout |
|
||||||
);*/ |
|
||||||
}, |
|
||||||
showError(error) { |
showError(error) { |
||||||
this.showMessage(error, 'danger'); |
this.showMessage(error, 'error'); // Use 'error' for PrimeVue
|
||||||
}, |
}, |
||||||
showMessage(message, type = 'success') { |
showMessage(message, type = 'success') { |
||||||
/*const content = { |
// Convert message type to PrimeVue's severity
|
||||||
// Your component or JSX template
|
let severity = type; |
||||||
component: Snackbar, |
if (type === 'danger') { |
||||||
// Props are just regular props, but these won't be reactive
|
severity = 'error'; // PrimeVue uses 'error' instead of 'danger'
|
||||||
props: { |
|
||||||
message: message |
|
||||||
}, |
|
||||||
// Listeners will listen to and execute on event emission
|
|
||||||
listeners: { |
|
||||||
//click: () => console.log("Clicked!"),
|
|
||||||
//myEvent: myEventHandler
|
|
||||||
} |
|
||||||
};*/ |
|
||||||
|
|
||||||
let color = 'primary'; |
|
||||||
let icon = 'info'; |
|
||||||
|
|
||||||
switch (type) { |
|
||||||
case 'info': |
|
||||||
break; |
|
||||||
case 'success': |
|
||||||
color = 'green'; |
|
||||||
break; |
|
||||||
case 'error': |
|
||||||
case 'danger': |
|
||||||
color = 'red'; |
|
||||||
icon: 'error'; |
|
||||||
break; |
|
||||||
case 'warning': |
|
||||||
color = 'yellow'; |
|
||||||
break; |
|
||||||
|
|
||||||
} |
} |
||||||
if ('danger' === type) { |
|
||||||
type = 'error'; |
|
||||||
} |
|
||||||
|
|
||||||
this.$q.notify({ |
|
||||||
position: 'top', |
|
||||||
timeout: 10000, |
|
||||||
message: message, |
|
||||||
color: color, |
|
||||||
html: true, |
|
||||||
multiLine: true, |
|
||||||
}) |
|
||||||
|
|
||||||
/*const toast = useToast(); |
|
||||||
console.log('toast'); |
|
||||||
console.log(message); |
|
||||||
console.log(content); |
|
||||||
|
|
||||||
toast(content, { |
// Use PrimeVue's ToastService
|
||||||
type: type, |
this.$toast.add({ |
||||||
position: 'top-center', |
severity: severity, |
||||||
timeout: 10000, // 10 seconds
|
summary: message, |
||||||
closeOnClick: false, |
detail: '', |
||||||
pauseOnFocusLoss: true, |
life: 5000, // Message duration in milliseconds
|
||||||
pauseOnHover: true, |
closable: true, // Whether the message can be closed manually
|
||||||
draggable: true, |
}); |
||||||
draggablePercent: 0.6, |
|
||||||
showCloseButtonOnHover: false, |
|
||||||
hideProgressBar: true, |
|
||||||
closeButton: "button", |
|
||||||
icon: true, |
|
||||||
rtl: false |
|
||||||
});*/ |
|
||||||
|
|
||||||
/*this.show = true; |
|
||||||
this.color = color; |
|
||||||
if (typeof message === 'string') { |
|
||||||
this.text = message; |
|
||||||
this.cleanState(); |
|
||||||
|
|
||||||
return; |
|
||||||
} |
|
||||||
this.text = message.message; |
|
||||||
if (message.response) this.subText = message.response.data.message; |
|
||||||
this.cleanState();*/ |
|
||||||
} |
|
||||||
} |
} |
||||||
|
}, |
||||||
|
computed: { |
||||||
|
...mapFields('notifications', ['color', 'show', 'subText', 'text', 'timeout']) |
||||||
|
}, |
||||||
}; |
}; |
||||||
|
|||||||
Loading…
Reference in new issue