Add Notification.js in order to load messages in vue 3 (composition api)

pull/3927/head
Julio Montoya 3 years ago
parent 8e29cdebfe
commit 8bc7fda92c
  1. 43
      assets/vue/components/Notification.js
  2. 7
      assets/vue/views/message/Show.vue

@ -0,0 +1,43 @@
import { useQuasar } from 'quasar';
/**
* Use this when using Vue 3 composition api (setup)
*/
export default function () {
const $q = useQuasar();
function showNotification (message, type = 'success') {
let color = 'primary';
let icon = 'info';
switch (type) {
case 'info':
break;
case 'success':
color = 'green';
break;
case 'error':
case 'danger':
color = 'red';
break;
case 'warning':
color = 'yellow';
break;
}
if ('danger' === type) {
type = 'error';
}
$q.notify({
position: 'top',
timeout: 10000,
message: message,
color: color,
html: true,
multiLine: true,
});
}
return {showNotification};
}

@ -92,6 +92,7 @@ import {ENTRYPOINT} from "../../config/entrypoint";
import useVuelidate from "@vuelidate/core";
import {useRoute, useRouter} from "vue-router";
import NotificationMixin from "../../mixins/NotificationMixin";
import useNotification from '../../components/Notification.js';
const servicePrefix = 'Message';
@ -111,6 +112,7 @@ export default {
const find = store.getters["message/find"];
const route = useRoute();
const router = useRouter();
const {showNotification} = useNotification();
let id = route.params.id;
if (isEmpty(id)) {
@ -148,8 +150,7 @@ export default {
tag: newTag,
}).then(response => {
addTagToMessage(response.data);
//this.showMessage('Added');
item.tags.push(response.data);
myReceiver.value.tags.push(response.data);
console.log(response);
isLoadingSelect.value = false;
}).catch(function (error) {
@ -170,7 +171,7 @@ export default {
axios.put(myReceiver.value['@id'], {
tags: tagsToUpdate,
}).then(response => {
//this.showMessage('Added');
showNotification('Tag added');
console.log(response);
isLoadingSelect.value = false;
}).catch(function (error) {

Loading…
Cancel
Save