diff --git a/app/static/js/userProfile.js b/app/static/js/userProfile.js index 13c7b15f9..2cd70726f 100644 --- a/app/static/js/userProfile.js +++ b/app/static/js/userProfile.js @@ -44,11 +44,10 @@ $(document).ready(function(){ }); $('.removeFromTranscriptCheckbox').click(function() { - var removeFromTranscript = $(this).is(':checked'); + var removeFromTranscript = $('#removeFromTranscriptCheckbox').is(':checked') + console.log("HAHA", removeFromTranscript); var username = $(this).data('username'); - var program = $(".banEdit").data("programid") - //erase later - console.log("programIdinsideRemoveFromTrans...", program) + $.ajax({ type: "POST", @@ -100,9 +99,11 @@ $(document).ready(function(){ var programID; $(".banEdit").click(function() { + + removeFromTranscriptState = $('#removeFromTranscriptCheckbox').is(':checked'); + $.ajax({ url: `/profile/${$(this).data("username")}/removeFromTranscript/${$(this).data("programid")}`, - // url: `/profile/${$(this).data("username")}/removeFromTranscript/${programID}`, type: "GET", success: function(response) { // Check if the program is marked for removal from transcript @@ -112,9 +113,7 @@ $(document).ready(function(){ console.log(error, status); } }); - //erase later - console.log("programIDinsideBanEdit", $(this).data("programid")) - + var banButton = $("#banButton") var banEndDateDiv = $("#banEndDate") // Div containing the datepicker in the ban modal var banEndDatepicker = $("#banEndDatepicker") // Datepicker in the ban modal @@ -122,12 +121,15 @@ $(document).ready(function(){ banNoteDiv.hide(); //Should only diplay when the modal is going to unban a user var banNote = $("#banNote") var banValue = $(this).val() + console.log("LOL", banValue) banButton.text(banValue + " Volunteer"); programID = $(this).data("programid"); // Assign value to programID variable banButton.data("programID", programID) banButton.data("username", $(".banEdit").data("username")) banButton.data("banOrUnban", banValue); + banButton.data("removeFromTranscript", $('.removeFromTranscriptCheckbox').is(':checked')) + console.log("TEST", $('.removeFromTranscriptCheckbox').is(':checked')) banEndDateDiv.show(); banEndDatepicker.val("") $(".modal-title-ban").text(banValue + " Volunteer"); @@ -142,16 +144,9 @@ $(document).ready(function(){ banNoteDiv.show() // $("#removeFromTranscriptDiv").show(); banNote.text($(this).data("note")) + $('#removeFromTranscriptCheckbox').prop('checked', removeFromTranscriptState); } else {$('#removeFromTranscriptCheckbox').prop('checked', true);} - var removeFromTranscript = $('.removeFromTranscriptCheckbox').is(':checked'); - console.log("value", removeFromTranscript) - console.log("ProgramId", programID) - console.log("ProgramfromBan", $("#banButton").data("programId")) - console.log("programfrombanEdit", $(".banEdit").data("programId")) - console.log("username", $(".banEdit").data("username")) - console.log("username2", $(".removeFromTranscript").data("username")) - }); @@ -164,13 +159,17 @@ $(document).ready(function(){ $("#banButton").prop("disabled", true) var username = $(this).data("username") //Expected to be the unique username of a user in the database var route = ($(this).data("banOrUnban")).toLowerCase() //Expected to be "ban" or "unban" - // var program = $(this).data("programID") //Expected to be a program's primary ID - var program = programID + var program = $(this).data("programID") //Expected to be a program's primary ID + var removeFromTranscript = $("#removeFromTranscriptCheckbox").is(':checked'); + console.log("ANNA", removeFromTranscript) + + $.ajax({ method: "POST", url: "/" + username + "/" + route + "/" + program, data: {"note": $("#banNoteTxtArea").val(), - "endDate":$("#banEndDatepicker").val() //Expected to be a date in this format YYYY-MM-DD + "endDate":$("#banEndDatepicker").val(), //Expected to be a date in this format YYYY-MM-DD + "removeFromTranscript": $("#removeFromTranscriptCheckbox").is(':checked') }, success: function(response) { reloadWithAccordion("programTable")