diff --git a/lumi2/static/js/group_edit.js b/lumi2/static/js/group_edit.js index 88ddddc..a80ffdb 100644 --- a/lumi2/static/js/group_edit.js +++ b/lumi2/static/js/group_edit.js @@ -26,11 +26,10 @@ class UserEntry { $(this.userEntry.buttonElement).click(() => this.userEntry.onClickJoin()); $(this.userEntry.rowElement).prependTo($("#tableNonMembers").find("tbody")); this.userEntry.setButtonAppearanceJoinGroup(); - // TODO check status code! }).fail(function(xhr, status, errorThrown) { console.log(`Error: ${errorThrown}`); console.log(`Status: ${status}`); - alert("Sorry, there was a problem retrieving information from the server."); + showErrorMessage(xhr.responseJSON['message']); this.userEntry.setButtonAppearanceLeaveGroup(); }); } @@ -50,12 +49,11 @@ class UserEntry { $(this.userEntry.buttonElement).click(() => this.userEntry.onClickLeave()); $(this.userEntry.rowElement).prependTo($("#tableMembers").find("tbody")); this.userEntry.setButtonAppearanceLeaveGroup(); - // TODO check status code! }).fail(function(xhr, status, errorThrown) { console.log(`Error: ${errorThrown}`); console.log(`Status: ${status}`); - alert("Sorry, there was a problem retrieving information from the server."); - this.userEntry.setButtonAppearanceLeaveGroup(); + showErrorMessage(xhr.responseJSON['message']); + this.userEntry.setButtonAppearanceJoinGroup(); }); } @@ -88,6 +86,15 @@ class UserEntry { } } +function showErrorMessage(message) { + $("nav").after([ + '