Skip to content

Commit

Permalink
Anna, added removeFromTranscript state inside banButton click functio…
Browse files Browse the repository at this point in the history
…n, more debug statements
  • Loading branch information
vungc authored Nov 4, 2024
1 parent d8089e2 commit afcf66d
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions app/static/js/userProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -112,22 +113,23 @@ $(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
var banNoteDiv = $("#banNoteDiv") // Div containing the note displaying why the user was banned previously
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");
Expand All @@ -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"))

});


Expand All @@ -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")
Expand Down

0 comments on commit afcf66d

Please sign in to comment.