diff --git a/app/config/contributors.yaml b/app/config/contributors.yaml index c3b1fe7e..c9df0f7e 100755 --- a/app/config/contributors.yaml +++ b/app/config/contributors.yaml @@ -41,3 +41,12 @@ contributors: - name: "Luis Jesus Riera Soto" username: "rieral" year: 2022 + - name: "Tyler Parton" + username: "" + year: 2023 + - name: "Madinabonu Solijonova" + username: "" + year: 2023 + - name: "Finn Bledsoe" + username: "" + year: 2025 diff --git a/app/controllers/main_routes/laborStatusForm.py b/app/controllers/main_routes/laborStatusForm.py index 982718b9..9dd7a437 100755 --- a/app/controllers/main_routes/laborStatusForm.py +++ b/app/controllers/main_routes/laborStatusForm.py @@ -22,7 +22,7 @@ from app.controllers.main_routes.laborReleaseForm import createLaborReleaseForm from app.controllers.admin_routes.allPendingForms import saveStatus -@main_bp.route('/laborstatusform', methods=['GET']) +@main_bp.route('/laborstatusform', methods=['GET', 'POST']) @main_bp.route('/laborstatusform/', methods=['GET']) def laborStatusForm(laborStatusKey = None): """ Render labor Status Form, and pre-populate LaborStatusForm page with the correct information when redirected from Labor History.""" @@ -34,6 +34,9 @@ def laborStatusForm(laborStatusKey = None): return redirect('/laborHistory/' + currentUser.student.ID) # Logged in + supervisorForms = ((FormHistory.select().where((FormHistory.historyType == "Labor Status Form") & (FormHistory.formID.termCode.termState) & ((FormHistory.formID.supervisor == currentUser.supervisor) | (FormHistory.createdBy == currentUser))) + .join(LaborStatusForm) + .join(Term)).distinct()).order_by(FormHistory.createdDate.desc()) students = Tracy().getStudents() terms = Term.select().where(Term.termState == "open") # changed to term state, open, closed, inactive staffs = Tracy().getSupervisors() @@ -57,6 +60,7 @@ def laborStatusForm(laborStatusKey = None): forms = forms, students = students, terms = terms, + supervisorForms = supervisorForms, staffs = staffs, departments = departments) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index e05be361..6ef8f7fb 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -3,6 +3,7 @@ var display_failed = []; var laborStatusFormNote = null; $(document).ready(function(){ + $('#lsfTable').DataTable(); if($("#selectedDepartment").val()){ // prepopulates position on redirect from rehire button and checks whether department is in compliance. checkCompliance($("#selectedDepartment")); getDepartment($("#selectedDepartment")); @@ -13,22 +14,32 @@ $(document).ready(function(){ fillHoursPerWeek("fillhours"); } var cookies = document.cookie; - if (cookies){ - parsedArrayOfStudentCookies = JSON.parse(cookies); - document.cookie = parsedArrayOfStudentCookies + ";max-age=28800;"; - for (i in parsedArrayOfStudentCookies) { - createAndFillTable(parsedArrayOfStudentCookies[i]); - } - $("#selectedTerm option[value=" + parsedArrayOfStudentCookies[0].stuTermCode + "]").attr('selected', 'selected'); - $("#selectedSupervisor option[value=" + parsedArrayOfStudentCookies[0].stuSupervisorID + "]").attr('selected', 'selected'); - $("#selectedDepartment option[value=\"" + parsedArrayOfStudentCookies[0].stuDepartmentORG + "\"]").attr('selected', 'selected'); - getDepartment($("#selectedDepartment")); - preFilledDate($("#selectedTerm")); - showAccessLevel($("#selectedTerm")); - disableTermSupervisorDept(); + if ((document.cookie).includes("lsfPreselected=")){ + console.log(cookies) + var cookieData = parseCookie(document.cookie) + console.log(cookieData) + var presetData = (cookieData).split(",") + console.log(presetData) + $("#selectedSupervisor").val(presetData[0]) + $("#selectedDepartment").val(presetData[1]) + checkCompliance($("#selectedDepartment")); + getDepartment($("#selectedDepartment")); + $("#selectedTerm").val(presetData[2]) + preFilledDate($("#selectedTerm")) + $('#position').val(presetData[3]).prop('selected', true); + $('select[name=position]').change() + $("#jobType").val(presetData[4]) + fillHoursPerWeek() + $("#selectedHoursPerWeek").val(presetData[5]) } }); +$( "#addMoreStudent" ).click(function() { + document.cookie = "lsfPreselected=" + $("#selectedSupervisor").val() + "," + $("#selectedDepartment").val() + ',' + $("#selectedTerm").val() + "," + $('#position option:selected').val() + "," + $("#jobType").val() + "," + $("#selectedHoursPerWeek").val(); + +}); + + $("#laborStatusForm").submit(function(event) { event.preventDefault(); }); @@ -60,6 +71,23 @@ $("#jobType").change(function(){ // Pops up a modal for Seconday Postion } }); + function parseCookie(str){ + console.log(str) + var pageCookies = str.split(";") + console.log(pageCookies) + let desiredString; + for (let i = 0; i < pageCookies.length; i++) { // This code was generated by Bard, a large language model from Google AI. (src: https://bard.google.com/) + if (pageCookies[i].includes("lsfPreselected=")) { + desiredString = pageCookies[i]; + break; + } + } + console.log(desiredString); + lsfData = desiredString.split("=") + // '{"termCode":"202100","departmentID":"70","supervis…","formStatus":[],"formType":[],"evaluations":[]}'] + return lsfData[1]; + }; + function checkIfFreshman() { var jobType = $("#jobType").val(); var wls = $("#position :selected").attr("data-wls") @@ -227,8 +255,9 @@ function getDepartment(object, stopSelectRefresh="") { // get department from se .attr("data-content", "" + response[key].position + " " + "(" + response[key].WLS+ ")" + "" + "" + " " + "(" + response[key].positionCode + ")" + "") .attr("id", key) - .attr("value", response[key].position) + .attr("value", key) .attr("data-wls", response[key].WLS) + ); } @@ -336,15 +365,6 @@ function checkCompliance(obj) { }); } -// TABLE LABELS -$("#contractHours").hide(); -$("#hoursPerWeek").hide(); -$("#JobTypes").hide(); -$("#plus").hide(); -$("#mytable").hide(); -$("#failedTable").hide(); - - function showAccessLevel(){ // Make Table labels appear if ($("#selectedSupervisor").val() && $("#selectedDepartment").val() && $("#selectedTerm").val()){ var isBreak = $("#selectedTerm").find("option:selected").data("termbreak"); @@ -362,11 +382,6 @@ function showAccessLevel(){ // Make Table labels appear } } } -// TABLE LABELS - -// hide review button will show when add student is clicked -$("#reviewButton").hide(); -//end // Table glyphicons function showNotesModal(glyphicon){// pops up Note Modal when notes glyphicon is clicked @@ -388,34 +403,6 @@ function saveNotes(arrayIndex){ // saves notes written in textarea when save but } } -function deleteRow(glyphicon) { - var rowParent = glyphicon.parentNode.parentNode; - var table = document.getElementById("mytable").getElementsByTagName("tbody")[0]; - for (var i = 0, row; row = table.rows[i]; i++) { - if (rowParent === table.rows[i]) { - $(glyphicon).parents("tr").remove(); - globalArrayOfStudents.splice(i, 1); - if(globalArrayOfStudents.length > 1){ - document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=28800;"; - } - else { - parsedArrayOfStudentCookies = document.cookie; - document.cookie = parsedArrayOfStudentCookies + ";max-age=0;"; - } - break; - } - } - if (globalArrayOfStudents.length <= 0) { - $("#selectedTerm").prop("disabled", false); - $("#selectedTerm").selectpicker("refresh"); - $("#selectedSupervisor").prop("disabled", false); - $("#selectedSupervisor").selectpicker("refresh"); - $("#selectedDepartment").prop("disabled", false); - $("#selectedDepartment").selectpicker("refresh"); - } -} -//END of glyphicons - function msgFlash(flash_message, status){ if (status === "success") { category = "success"; @@ -578,18 +565,19 @@ function checkPrimaryPositionToCreateTheTable(studentDict) { function initialLSFInsert(studentDict){ //Add student info to the table if they have no previous lsf's in the database if (checkDuplicate(studentDict) == false){ checkTotalHours(studentDict); - createAndFillTable(studentDict); + createAndFillTable(studentDict, reviewButtonFunctionality); } } -function createAndFillTable(studentDict) { +function createAndFillTable(studentDict, callback=null) { globalArrayOfStudents.push(studentDict); - document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=28800;"; + if(callback){ + callback() + } $("#mytable").show(); $("#jobTable").show(); $("#hoursTable").show(); var isBreak = (studentDict).isTermBreak; - var table = document.getElementById("mytable").getElementsByTagName("tbody")[0]; //This one needs document.getElementById, it won't work without it if (!isBreak) { var notesID0 = String((studentDict).stuName + (studentDict).stuJobType + (studentDict).stuPosition); var notesID1 = notesID0.replace(/ /g, ""); @@ -718,7 +706,6 @@ $("#resetConfirmButton").click(function(){ $("#warningModal").modal('hide'); globalArrayOfStudents = []; $("#tbodyid tr").remove(); - document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=0;"; location.reload(); }); @@ -744,7 +731,7 @@ function createModalContent() { // Populates Submit Modal with Student informati globalArrayOfStudents[i].stuContractHours + " hours"; modalList.push(bigString); } - $("#SubmitModalText").html("Labor status form(s) will be submitted for:

" + + $("#SubmitModalText").html("Labor status form will be submitted for:

" + ""+ "

The labor status form will be eligible for approval in one business day."); @@ -838,8 +825,6 @@ function userInsert(){ $("a").attr("onclick", "").unbind("click"); $(".glyphicon-edit").css("color", "grey"); $(".glyphicon-remove").css("color", "grey"); - parsedArrayOfStudentCookies = document.cookie; - document.cookie = parsedArrayOfStudentCookies +";max-age=0"; window.location.replace("/laborstatusform"); } } @@ -893,4 +878,5 @@ function releaseAndRehire(){ } } }) + } diff --git a/app/static/js/supervisorPortal.js b/app/static/js/supervisorPortal.js index ac9208ac..052b58df 100644 --- a/app/static/js/supervisorPortal.js +++ b/app/static/js/supervisorPortal.js @@ -28,8 +28,20 @@ $(document).ready(function(){ }); function parseCookie(str){ - cookieArray = str.split('=') - return cookieArray[1]; + console.log(str) + var pageCookies = str.split(";") + console.log(pageCookies) + let desiredString; + for (let i = 0; i < pageCookies.length; i++) { // This code was generated by Bard, a large language model from Google AI. (src: https://bard.google.com/) + if (pageCookies[i].includes("searchResults=")) { + desiredString = pageCookies[i]; + break; + } +} + console.log(desiredString); + supervisorPortalData = desiredString.split("=") + // '{"termCode":"202100","departmentID":"70","supervis…","formStatus":[],"formType":[],"evaluations":[]}'] + return supervisorPortalData[1]; }; function runFormSearchQuery(newData='', cookie) { diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 83b2b286..a42db768 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -3,10 +3,12 @@ {% block styles %} {{super()}} + {% endblock %} ​{% block scripts %} {{super()}} + {% endblock %} @@ -167,8 +169,8 @@

Labor Status Form {% endfor %} -
- +
+
-
+
- - +
- + + - + + + + {% for form in supervisorForms %} + + + + + + + + + - + {% endfor %}
Student Student Position (WLS) Job Type HoursTerm Contract Dates NotesRemoveEdit
{{form.formID.studentName}}{{form.formID.POSN_CODE}} ({{form.formID.WLS}}){{form.formID.jobType}}{{form.formID.weeklyHours}}{{form.formID.termCode.termName}}{{form.formID.startDate}} - {{form.formID.endDate}}