toast: add remove method to clear a single message (#4101)

Co-authored-by: Clément Bernard <cbernard@groupeisagri.com>
This commit is contained in:
Clément 2023-10-05 14:54:37 +02:00 committed by GitHub
parent 4bcb9bd14f
commit cee96884f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 0 deletions

View file

@ -43,6 +43,7 @@ export default {
styleElement: null,
mounted() {
ToastEventBus.on('add', this.onAdd);
ToastEventBus.on('remove', this.onRemove);
ToastEventBus.on('remove-group', this.onRemoveGroup);
ToastEventBus.on('remove-all-groups', this.onRemoveAllGroups);
@ -58,6 +59,7 @@ export default {
}
ToastEventBus.off('add', this.onAdd);
ToastEventBus.off('remove', this.onRemove);
ToastEventBus.off('remove-group', this.onRemoveGroup);
ToastEventBus.off('remove-all-groups', this.onRemoveAllGroups);
},
@ -87,6 +89,9 @@ export default {
this.add(message);
}
},
onRemove(message) {
this.remove({ message, type: 'close' });
},
onRemoveGroup(group) {
if (this.group === group) {
this.messages = [];