Use swal to show error message when adding players

This commit is contained in:
printempw 2018-06-19 11:40:52 +08:00
parent b7a2d368f7
commit 6926ae21ff
2 changed files with 6 additions and 8 deletions

View File

@ -717,7 +717,7 @@ describe('tests for "player" module', () => {
expect(document.getElementById('1')).toBeNull();
await deletePlayer(1);
expect(toastr.warning).toBeCalledWith('warning');
expect(swal).toBeCalledWith({ type: 'warning', html: 'warning' });
await deletePlayer(1);
expect(showAjaxError).toBeCalled();
@ -759,7 +759,7 @@ describe('tests for "player" module', () => {
expect(modal).toBeCalled();
await addNewPlayer();
expect(toastr.warning).toBeCalledWith('warning');
expect(swal).toBeCalledWith({ type: 'warning', html: 'warning' });
await addNewPlayer();
expect(showAjaxError).toBeCalled();

View File

@ -208,7 +208,7 @@ async function deletePlayer(pid) {
});
$(`tr#${pid}`).remove();
} else {
toastr.warning(msg);
swal({ type: 'warning', html: msg });
}
} catch (error) {
showAjaxError(error);
@ -225,14 +225,12 @@ async function addNewPlayer() {
});
if (errno === 0) {
swal({
type: 'success',
html: msg
}).then(() => location.reload());
await swal({ type: 'success', html: msg });
$('#modal-add-player').modal('hide');
location.reload();
} else {
toastr.warning(msg);
swal({ type: 'warning', html: msg });
}
} catch (error) {
showAjaxError(error);