diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/notification/toggle_read.js b/src/Bundle/ChillMainBundle/Resources/public/module/notification/toggle_read.js new file mode 100644 index 000000000..6d1637494 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/module/notification/toggle_read.js @@ -0,0 +1,38 @@ +import {createApp} from "vue"; +import NotificationReadToggle from "ChillMainAssets/vuejs/_components/Notification/NotificationReadToggle.vue"; + +const App = { + template: '', + 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, + } + } + }) + + createApp(myApp).mount(app); + }); +}) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Notification/NotificationReadToggle.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Notification/NotificationReadToggle.vue new file mode 100644 index 000000000..d88c9916c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Notification/NotificationReadToggle.vue @@ -0,0 +1,42 @@ + + + + + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig index 064adcee1..915f42c25 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/list.html.twig @@ -2,6 +2,16 @@ {% block title 'notification.List'|trans %} +{% block js %} + {{ parent() }} + {{ encore_entry_script_tags('mod_notification_toggle_read_status') }} +{% endblock %} + +{% block css %} + {{ parent() }} + {{ encore_entry_link_tags('mod_notification_toggle_read_status') }} +{% endblock %} + {% block content %}
@@ -66,6 +76,9 @@
diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index 07b7970d8..a123ce405 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -106,6 +106,6 @@ }); - {% block js%}{% endblock %} + {% block js %}{% endblock %} diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index dfa113206..adc4ba3c8 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -61,10 +61,10 @@ module.exports = function(encore, entries) encore.addEntry('mod_ckeditor5', __dirname + '/Resources/public/module/ckeditor5/index.js'); encore.addEntry('mod_disablebuttons', __dirname + '/Resources/public/module/disable-buttons/index.js'); encore.addEntry('mod_blur', __dirname + '/Resources/public/module/blur/index.js'); - encore.addEntry('mod_input_address', __dirname + '/Resources/public/vuejs/Address/mod_input_address_index.js'); + encore.addEntry('mod_notification_toggle_read_status', __dirname + '/Resources/public/module/notification/toggle_read.js'); + // Vue entrypoints encore.addEntry('vue_address', __dirname + '/Resources/public/vuejs/Address/index.js'); encore.addEntry('vue_onthefly', __dirname + '/Resources/public/vuejs/OnTheFly/index.js'); - };