notification: fix widget toggle read status

This commit is contained in:
Julien Fastré 2021-12-29 23:09:26 +01:00
parent 9ddfd194be
commit 1576507f7e
2 changed files with 24 additions and 29 deletions

View File

@ -1,6 +1,10 @@
import {createApp} from "vue";
import NotificationReadToggle from "ChillMainAssets/vuejs/_components/Notification/NotificationReadToggle.vue";
window.addEventListener('DOMContentLoaded', function (e) {
document.querySelectorAll('.notification_toggle_read_status')
.forEach(function (el) {
console.log('app', el);
const App = {
template: '<notification-read-toggle ' +
':notificationId="notificationId" ' +
@ -10,29 +14,22 @@ const App = {
components: {
NotificationReadToggle,
},
methods: {
onMarkRead() {
this.isRead = true;
},
onMarkUnread() {
this.isRead = false;
},
}
}
window.addEventListener('DOMContentLoaded', function (e) {
document.querySelectorAll('.notification_toggle_read_status')
.forEach(function (app) {
console.log('app', app);
const myApp = Object.assign(App, {
data() {
return {
notificationId: +app.dataset.notificationId,
isRead: 1 === +app.dataset.notificationCurrentIsRead,
notificationId: +el.dataset.notificationId,
isRead: 1 === +el.dataset.notificationCurrentIsRead,
}
},
methods: {
onMarkRead() {
this.isRead = false;
},
onMarkUnread() {
this.isRead = true;
},
}
}
})
createApp(myApp).mount(app);
createApp(App).mount(el);
});
})

View File

@ -23,14 +23,12 @@ export default {
methods: {
markAsUnread() {
makeFetch('POST', `/api/1.0/main/notification/${this.notificationId}/mark/unread`, []).then(response => {
console.log('marked as unread', this.notificationId);
this.$emit('markRead', { notificationId: this.notificationId });
})
},
markAsRead() {
makeFetch('POST', `/api/1.0/main/notification/${this.notificationId}/mark/read`, []).then(response => {
console.log('marked as read', this.notificationId);
this.$emit('markRead', { notificationId: this.notificationId });
this.$emit('markUnread', { notificationId: this.notificationId });
})
},
},