Use notification helpers instead of window reference everywhere
This commit is contained in:
parent
0770dbfc21
commit
2e5f500d24
|
@ -1,4 +1,5 @@
|
|||
import Rails from '@rails/ujs';
|
||||
import { showNotification, showErrorNotification } from 'utilities/notifications';
|
||||
import I18n from '../../../legacy/i18n';
|
||||
|
||||
export function createListHandler(event: Event): void {
|
||||
|
@ -17,11 +18,11 @@ export function createListHandler(event: Event): void {
|
|||
document.querySelector('#lists-list ul.list-group').insertAdjacentHTML('beforeend', data.render);
|
||||
}
|
||||
|
||||
window['showNotification'](data.message, data.success);
|
||||
showNotification(data.message, data.success);
|
||||
},
|
||||
error: (data, status, xhr) => {
|
||||
console.log(data, status, xhr);
|
||||
window['showNotification'](I18n.translate('frontend.error.message'), false);
|
||||
showErrorNotification(I18n.translate('frontend.error.message'));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Rails from '@rails/ujs';
|
||||
import swal from 'sweetalert';
|
||||
import { showNotification, showErrorNotification } from 'utilities/notifications';
|
||||
import I18n from '../../../legacy/i18n';
|
||||
|
||||
export function destroyListHandler(event: Event): void {
|
||||
|
@ -32,11 +33,11 @@ export function destroyListHandler(event: Event): void {
|
|||
}
|
||||
}
|
||||
|
||||
window['showNotification'](data.message, data.success);
|
||||
showNotification(data.message, data.success);
|
||||
},
|
||||
error: (data, status, xhr) => {
|
||||
console.log(data, status, xhr);
|
||||
window['showNotification'](I18n.translate('frontend.error.message'), false);
|
||||
showErrorNotification(I18n.translate('frontend.error.message'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Rails from '@rails/ujs';
|
||||
import { showNotification, showErrorNotification } from 'utilities/notifications';
|
||||
import I18n from '../../../legacy/i18n';
|
||||
|
||||
export function listMembershipHandler(event: Event): void {
|
||||
|
@ -24,11 +25,11 @@ export function listMembershipHandler(event: Event): void {
|
|||
document.querySelector(`span#${list}-members`).innerHTML = memberCount.toString();
|
||||
}
|
||||
|
||||
window['showNotification'](data.message, data.success);
|
||||
showNotification(data.message, data.success);
|
||||
},
|
||||
error: (data, status, xhr) => {
|
||||
console.log(data, status, xhr);
|
||||
window['showNotification'](I18n.translate('frontend.error.message'), false);
|
||||
showErrorNotification(I18n.translate('frontend.error.message'));
|
||||
},
|
||||
complete: () => {
|
||||
checkbox.removeAttribute('disabled');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Rails from '@rails/ujs';
|
||||
import { showNotification, showErrorNotification } from 'utilities/notifications';
|
||||
import I18n from '../../../legacy/i18n';
|
||||
|
||||
export function userActionHandler(event: Event): void {
|
||||
|
@ -17,11 +18,11 @@ export function userActionHandler(event: Event): void {
|
|||
}).toString(),
|
||||
success: (data) => {
|
||||
success = data.success;
|
||||
window['showNotification'](data.message, data.success);
|
||||
showNotification(data.message, data.success);
|
||||
},
|
||||
error: (data, status, xhr) => {
|
||||
console.log(data, status, xhr);
|
||||
window['showNotification'](I18n.translate('frontend.error.message'), false);
|
||||
showErrorNotification(I18n.translate('frontend.error.message'));
|
||||
},
|
||||
complete: () => {
|
||||
if (!success) return;
|
||||
|
|
Loading…
Reference in New Issue