From 5aacb6441e2870a77f96c4449a296ca21dc5eb83 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Wed, 22 Mar 2023 16:28:50 -0400 Subject: [PATCH 01/12] new issue branch --- app/static/js/laborStatusForm.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index e05be3611..ec20244e0 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -74,6 +74,7 @@ function checkIfFreshman() { laborStatusFormNote = null; } searchDataToPrepareToCheckPrimaryPosition(); + userInsert(); } function disableTermSupervisorDept() { From bfb36e190d3350ab93d1872ad3de04bb0310f8ee Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Thu, 23 Mar 2023 15:07:51 -0400 Subject: [PATCH 02/12] Working on getting the button switched. --- app/static/js/laborStatusForm.js | 3 ++- app/templates/main/laborStatusForm.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index ec20244e0..3ab7243fc 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -74,7 +74,6 @@ function checkIfFreshman() { laborStatusFormNote = null; } searchDataToPrepareToCheckPrimaryPosition(); - userInsert(); } function disableTermSupervisorDept() { @@ -767,6 +766,8 @@ function createModalContent() { // Populates Submit Modal with Student informati // userInsert() sends SubmitModal's info to controller using ajax and gets the response in array containing true(s) or/and false(s) function userInsert(){ + checkIfFreshman(); + reviewButtonFunctionality(); $("#laborStatusForm").on("submit", function(e) { e.preventDefault(); }); diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 83b2b2864..1dd127798 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -229,7 +229,7 @@

Labor Status Form name = "addStudent" id="addMoreStudent" value = "formSubmission" - onclick="checkIfFreshman();">Add Student + onclick="userInsert();">Add Student *Want to add multiple students for this supervisor? Add them now! From 681afc47093464815c00e7d324b019c11e246f06 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Thu, 23 Mar 2023 15:59:25 -0400 Subject: [PATCH 03/12] need to attack from different angle. --- app/static/js/laborStatusForm.js | 3 +-- app/templates/main/laborStatusForm.html | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 3ab7243fc..5a0b47569 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -766,8 +766,6 @@ function createModalContent() { // Populates Submit Modal with Student informati // userInsert() sends SubmitModal's info to controller using ajax and gets the response in array containing true(s) or/and false(s) function userInsert(){ - checkIfFreshman(); - reviewButtonFunctionality(); $("#laborStatusForm").on("submit", function(e) { e.preventDefault(); }); @@ -895,4 +893,5 @@ function releaseAndRehire(){ } } }) + } diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 1dd127798..83b2b2864 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -229,7 +229,7 @@

Labor Status Form name = "addStudent" id="addMoreStudent" value = "formSubmission" - onclick="userInsert();">Add Student + onclick="checkIfFreshman();">Add Student *Want to add multiple students for this supervisor? Add them now! From 61243dce19f944c6d6330291b4f9f7c895171f19 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Wed, 29 Mar 2023 16:56:09 -0400 Subject: [PATCH 04/12] fixed issue with calling function in order. --- app/static/js/laborStatusForm.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 5a0b47569..06430d650 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -578,12 +578,15 @@ 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); + if(callback){ + callback() + } document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=28800;"; $("#mytable").show(); $("#jobTable").show(); From 6480b8c72a068024c229ee24adbe6175f0d5e7e9 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Mon, 3 Apr 2023 16:56:16 -0400 Subject: [PATCH 05/12] set table up to insert existing records. --- app/controllers/main_routes/laborStatusForm.py | 7 +++++++ app/templates/main/laborStatusForm.html | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/main_routes/laborStatusForm.py b/app/controllers/main_routes/laborStatusForm.py index 613156922..caa1f401c 100755 --- a/app/controllers/main_routes/laborStatusForm.py +++ b/app/controllers/main_routes/laborStatusForm.py @@ -34,6 +34,12 @@ def laborStatusForm(laborStatusKey = None): return redirect('/laborHistory/' + currentUser.student.ID) # Logged in + supervisorForms = (FormHistory.select().where((FormHistory.formID.termCode.termState) & ((FormHistory.formID.supervisor == currentUser.supervisor) | (FormHistory.createdBy == currentUser))) + .join(LaborStatusForm) + .join(Term)).distinct() + + for form in supervisorForms: + print(form.formID.laborStatusFormID) students = Tracy().getStudents() terms = Term.select().where(Term.termState == "open") # changed to term state, open, closed, inactive staffs = Tracy().getSupervisors() @@ -56,6 +62,7 @@ def laborStatusForm(laborStatusKey = None): UserID = currentUser, forms = forms, students = students, + supervisorForms = supervisorForms, terms = terms, staffs = staffs, departments = departments) diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 83b2b2864..b2b62adf2 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -238,14 +238,27 @@

Labor Status Form - + + - + + {% 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.ternName}}{{form.formID.startDate}} - {{form.formID.endDate}}
From 2c2609100491404c51982447ac22140f6cd06370 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Tue, 4 Apr 2023 15:54:03 -0400 Subject: [PATCH 06/12] made new table that holds all forms for this semester sorted as well as an edit button. --- app/controllers/main_routes/laborStatusForm.py | 5 ++--- app/static/js/laborStatusForm.js | 1 - app/templates/main/laborStatusForm.html | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/main_routes/laborStatusForm.py b/app/controllers/main_routes/laborStatusForm.py index caa1f401c..28bb0599d 100755 --- a/app/controllers/main_routes/laborStatusForm.py +++ b/app/controllers/main_routes/laborStatusForm.py @@ -34,10 +34,9 @@ def laborStatusForm(laborStatusKey = None): return redirect('/laborHistory/' + currentUser.student.ID) # Logged in - supervisorForms = (FormHistory.select().where((FormHistory.formID.termCode.termState) & ((FormHistory.formID.supervisor == currentUser.supervisor) | (FormHistory.createdBy == currentUser))) + 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() - + .join(Term)).distinct()).order_by(FormHistory.createdDate.desc()) for form in supervisorForms: print(form.formID.laborStatusFormID) students = Tracy().getStudents() diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 06430d650..405eb1aaf 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -341,7 +341,6 @@ $("#contractHours").hide(); $("#hoursPerWeek").hide(); $("#JobTypes").hide(); $("#plus").hide(); -$("#mytable").hide(); $("#failedTable").hide(); diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index b2b62adf2..2abdc1ccc 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -253,10 +253,10 @@

Labor Status Form {{form.formID.POSN_CODE}} ({{form.formID.WLS}}) {{form.formID.jobType}} {{form.formID.weeklyHours}} - {{form.formID.termCode.ternName}} + {{form.formID.termCode.termName}} {{form.formID.startDate}} - {{form.formID.endDate}} - - + + {% endfor %} From 643bd4ecb78d46df39823d065ed4303be096fc1b Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Fri, 7 Apr 2023 11:48:26 -0400 Subject: [PATCH 07/12] converted to datatable with pagination working on filling in data. --- .../main_routes/laborStatusForm.py | 20 +++++++++------ app/static/js/laborStatusForm.js | 25 +++++++++++++++++++ app/templates/main/laborStatusForm.html | 4 ++- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/app/controllers/main_routes/laborStatusForm.py b/app/controllers/main_routes/laborStatusForm.py index 28bb0599d..d834c560b 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,11 +34,6 @@ 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()) - for form in supervisorForms: - print(form.formID.laborStatusFormID) students = Tracy().getStudents() terms = Term.select().where(Term.termState == "open") # changed to term state, open, closed, inactive staffs = Tracy().getSupervisors() @@ -61,11 +56,22 @@ def laborStatusForm(laborStatusKey = None): UserID = currentUser, forms = forms, students = students, - supervisorForms = supervisorForms, terms = terms, staffs = staffs, departments = departments) +@main_bp.route('/lsfdatatable', methods=['GET']) +def lsfdatatable(): + """This function in called in laborStatusFrom.js to get data for the DataTable on the lsf creation page.""" + + currentUser = require_login() + supervisorForms = list(((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())) + print(supervisorForms) + + return supervisorForms + @main_bp.route('/laborstatusform/userInsert', methods=['POST']) def userInsert(): """ Create labor status form. Create labor history form. Most of the functions called here are in userInsertFunctions.py""" diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 405eb1aaf..db68727f4 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(){ + intializeDataTable() if($("#selectedDepartment").val()){ // prepopulates position on redirect from rehire button and checks whether department is in compliance. checkCompliance($("#selectedDepartment")); getDepartment($("#selectedDepartment")); @@ -897,3 +898,27 @@ function releaseAndRehire(){ }) } + +function intializeDataTable() { + var lsfTable = $('#lsfTable').DataTable({ + paging: true, + ordering: false, + info: false, + responsive: true, + searching: false, + ajax: { + url: "/lsfdatatable", + type: "GET", + columns: [ + { data: 'Student' }, + { data: 'Position (WLS)' }, + { data: 'Job Type' }, + { data: 'Hours' }, + { data: 'Term' }, + { data: 'Contract Dates' }, + { data: 'Notes'}, + { data: 'Edit'} + ], + } + }); + }; diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 2abdc1ccc..427830e66 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -3,11 +3,13 @@ {% block styles %} {{super()}} + {% endblock %} ​{% block scripts %} {{super()}} + {% endblock %} {% block app_content %} @@ -235,7 +237,7 @@

Labor Status Form
- +
From 24b50f55042daa520d5e885467ea073c5215e07f Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Tue, 11 Apr 2023 16:49:53 -0400 Subject: [PATCH 08/12] Got datatable set up, now working on cookies. --- .../main_routes/laborStatusForm.py | 16 +++--------- app/static/js/laborStatusForm.js | 26 +------------------ app/templates/main/laborStatusForm.html | 6 ++--- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/app/controllers/main_routes/laborStatusForm.py b/app/controllers/main_routes/laborStatusForm.py index d834c560b..4ad77d617 100755 --- a/app/controllers/main_routes/laborStatusForm.py +++ b/app/controllers/main_routes/laborStatusForm.py @@ -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,21 +60,10 @@ def laborStatusForm(laborStatusKey = None): forms = forms, students = students, terms = terms, + supervisorForms = supervisorForms, staffs = staffs, departments = departments) -@main_bp.route('/lsfdatatable', methods=['GET']) -def lsfdatatable(): - """This function in called in laborStatusFrom.js to get data for the DataTable on the lsf creation page.""" - - currentUser = require_login() - supervisorForms = list(((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())) - print(supervisorForms) - - return supervisorForms - @main_bp.route('/laborstatusform/userInsert', methods=['POST']) def userInsert(): """ Create labor status form. Create labor history form. Most of the functions called here are in userInsertFunctions.py""" diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index db68727f4..efcd66116 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -3,7 +3,7 @@ var display_failed = []; var laborStatusFormNote = null; $(document).ready(function(){ - intializeDataTable() + $('#lsfTable').DataTable(); if($("#selectedDepartment").val()){ // prepopulates position on redirect from rehire button and checks whether department is in compliance. checkCompliance($("#selectedDepartment")); getDepartment($("#selectedDepartment")); @@ -898,27 +898,3 @@ function releaseAndRehire(){ }) } - -function intializeDataTable() { - var lsfTable = $('#lsfTable').DataTable({ - paging: true, - ordering: false, - info: false, - responsive: true, - searching: false, - ajax: { - url: "/lsfdatatable", - type: "GET", - columns: [ - { data: 'Student' }, - { data: 'Position (WLS)' }, - { data: 'Job Type' }, - { data: 'Hours' }, - { data: 'Term' }, - { data: 'Contract Dates' }, - { data: 'Notes'}, - { data: 'Edit'} - ], - } - }); - }; diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 427830e66..81a96b1de 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -8,8 +8,8 @@ ​{% block scripts %} {{super()}} - + {% endblock %} {% block app_content %} @@ -237,7 +237,7 @@

Labor Status Form
-

Student
+
@@ -249,6 +249,7 @@

Labor Status Form

+ {% for form in supervisorForms %} @@ -261,7 +262,6 @@

Labor Status Form

{% endfor %} -
Student Notes Edit
{{form.formID.studentName}}
From d237b281427fee6d3544a5a5cbdbb9dcee8ddf25 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Wed, 12 Apr 2023 11:22:18 -0400 Subject: [PATCH 09/12] Working on cookies. --- app/static/js/laborStatusForm.js | 70 ++++++++------------------------ 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index efcd66116..03041edf6 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -15,21 +15,26 @@ $(document).ready(function(){ } 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(); + } }); +$( "#addMoreStudent" ).click(function() { + // var presetSupervisor = $("#").val() + // var presetDepartment = $("#").val() + // var presetTerm = $("#").val() + // var presetPosition = $("#").val() + // var presetJobType = $("#").val() + // var presetHours = $("#").val() + presetDict = {presetSupervisor: $("#selectedSupervisor").val(), + presetDepartment: $("#selectedDepartment").val(), + presetTerm: $("#selectedTerm").val(), + presetPosition: $("#position").val(), + presetJobType: $("#jobType").val(), + presetHours: $("#selectedHoursPerWeek").val()} + console.log(presetDict) +}); + $("#laborStatusForm").submit(function(event) { event.preventDefault(); }); @@ -337,14 +342,6 @@ function checkCompliance(obj) { }); } -// TABLE LABELS -$("#contractHours").hide(); -$("#hoursPerWeek").hide(); -$("#JobTypes").hide(); -$("#plus").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 +359,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 +380,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"; From 2d3623e6ae635629ed75577523253175fb2e5a08 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Wed, 12 Apr 2023 16:39:09 -0400 Subject: [PATCH 10/12] got cookies set up just need to apply them on page load. --- app/config/contributors.yaml | 9 +++++++++ app/static/js/laborStatusForm.js | 23 ++++------------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/config/contributors.yaml b/app/config/contributors.yaml index c3b1fe7e5..c9df0f7eb 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/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 03041edf6..6aec62e3d 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -15,26 +15,16 @@ $(document).ready(function(){ } var cookies = document.cookie; if (cookies){ - + console.log(cookies) } }); $( "#addMoreStudent" ).click(function() { - // var presetSupervisor = $("#").val() - // var presetDepartment = $("#").val() - // var presetTerm = $("#").val() - // var presetPosition = $("#").val() - // var presetJobType = $("#").val() - // var presetHours = $("#").val() - presetDict = {presetSupervisor: $("#selectedSupervisor").val(), - presetDepartment: $("#selectedDepartment").val(), - presetTerm: $("#selectedTerm").val(), - presetPosition: $("#position").val(), - presetJobType: $("#jobType").val(), - presetHours: $("#selectedHoursPerWeek").val()} - console.log(presetDict) + document.cookie = "lsfPreselected=" + "presetSupervisor:" + $("#selectedSupervisor").val() + "presetDepartment:" + $("#selectedDepartment").val() + "presetTerm:" + $("#selectedTerm").val() + "presetPosition:" + $("#position").val() + "presetJobType:" + $("#jobType").val() + "presetHours:" + $("#selectedHoursPerWeek").val(); + }); + $("#laborStatusForm").submit(function(event) { event.preventDefault(); }); @@ -551,12 +541,10 @@ function createAndFillTable(studentDict, callback=null) { if(callback){ callback() } - document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=28800;"; $("#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, ""); @@ -685,7 +673,6 @@ $("#resetConfirmButton").click(function(){ $("#warningModal").modal('hide'); globalArrayOfStudents = []; $("#tbodyid tr").remove(); - document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=0;"; location.reload(); }); @@ -805,8 +792,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"); } } From d77317d35c79b45c710b4bd9d5cf5f29df76b933 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Thu, 13 Apr 2023 16:56:11 -0400 Subject: [PATCH 11/12] got every field to set based off of cookies except position. --- app/static/js/laborStatusForm.js | 17 ++++++++++++++++- app/templates/main/laborStatusForm.html | 4 +--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 6aec62e3d..3179c9370 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -16,11 +16,26 @@ $(document).ready(function(){ var cookies = document.cookie; if (cookies){ console.log(cookies) + var pageCookies = cookies.split("/") + var cookieData = (pageCookies[0]).split("lsfPreselected=") + var presetData = (cookieData[1]).split(",") + console.log(presetData) + $("#selectedSupervisor").val(presetData[0]) + $("#selectedDepartment").val(presetData[1]) + checkCompliance($("#selectedDepartment")); + getDepartment($("#selectedDepartment")); + $("#selectedTerm").val(presetData[2]) + preFilledDate($("#selectedTerm")) + var selectedPosition = "#" + presetData[3] + $(selectedPosition).attr("selected","selected") + $("#jobType").val(presetData[4]) + fillHoursPerWeek() + $("#selectedHoursPerWeek").val(presetData[5]) } }); $( "#addMoreStudent" ).click(function() { - document.cookie = "lsfPreselected=" + "presetSupervisor:" + $("#selectedSupervisor").val() + "presetDepartment:" + $("#selectedDepartment").val() + "presetTerm:" + $("#selectedTerm").val() + "presetPosition:" + $("#position").val() + "presetJobType:" + $("#jobType").val() + "presetHours:" + $("#selectedHoursPerWeek").val(); + document.cookie = "lsfPreselected=" + $("#selectedSupervisor").val() + "," + $("#selectedDepartment").val() + ',' + $("#selectedTerm").val() + "," + $('#position option:selected').attr('id') + "," + $("#jobType").val() + "," + $("#selectedHoursPerWeek").val() + "/"; }); diff --git a/app/templates/main/laborStatusForm.html b/app/templates/main/laborStatusForm.html index 81a96b1de..d978b7665 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -210,7 +210,7 @@

Labor Status Form {% if forms %} {% endif %} ​

-
+
- From a5d941e1914626f05a64479baea090bfec507e71 Mon Sep 17 00:00:00 2001 From: Tyler Parton Date: Mon, 24 Apr 2023 16:47:10 -0400 Subject: [PATCH 12/12] got cookies from two pages to work together. --- app/static/js/laborStatusForm.js | 36 ++++++++++++++++++------- app/static/js/supervisorPortal.js | 16 +++++++++-- app/templates/main/laborStatusForm.html | 4 +-- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/app/static/js/laborStatusForm.js b/app/static/js/laborStatusForm.js index 3179c9370..6ef8f7fbc 100755 --- a/app/static/js/laborStatusForm.js +++ b/app/static/js/laborStatusForm.js @@ -14,11 +14,11 @@ $(document).ready(function(){ fillHoursPerWeek("fillhours"); } var cookies = document.cookie; - if (cookies){ + if ((document.cookie).includes("lsfPreselected=")){ console.log(cookies) - var pageCookies = cookies.split("/") - var cookieData = (pageCookies[0]).split("lsfPreselected=") - var presetData = (cookieData[1]).split(",") + var cookieData = parseCookie(document.cookie) + console.log(cookieData) + var presetData = (cookieData).split(",") console.log(presetData) $("#selectedSupervisor").val(presetData[0]) $("#selectedDepartment").val(presetData[1]) @@ -26,8 +26,8 @@ $(document).ready(function(){ getDepartment($("#selectedDepartment")); $("#selectedTerm").val(presetData[2]) preFilledDate($("#selectedTerm")) - var selectedPosition = "#" + presetData[3] - $(selectedPosition).attr("selected","selected") + $('#position').val(presetData[3]).prop('selected', true); + $('select[name=position]').change() $("#jobType").val(presetData[4]) fillHoursPerWeek() $("#selectedHoursPerWeek").val(presetData[5]) @@ -35,7 +35,7 @@ $(document).ready(function(){ }); $( "#addMoreStudent" ).click(function() { - document.cookie = "lsfPreselected=" + $("#selectedSupervisor").val() + "," + $("#selectedDepartment").val() + ',' + $("#selectedTerm").val() + "," + $('#position option:selected').attr('id') + "," + $("#jobType").val() + "," + $("#selectedHoursPerWeek").val() + "/"; + document.cookie = "lsfPreselected=" + $("#selectedSupervisor").val() + "," + $("#selectedDepartment").val() + ',' + $("#selectedTerm").val() + "," + $('#position option:selected').val() + "," + $("#jobType").val() + "," + $("#selectedHoursPerWeek").val(); }); @@ -71,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") @@ -238,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) + ); } @@ -713,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:

" + "
    " + modalList.join("")+"
"+ "

The labor status form will be eligible for approval in one business day."); diff --git a/app/static/js/supervisorPortal.js b/app/static/js/supervisorPortal.js index ac9208ac8..052b58df0 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 d978b7665..a42db768e 100755 --- a/app/templates/main/laborStatusForm.html +++ b/app/templates/main/laborStatusForm.html @@ -169,8 +169,8 @@

Labor Status Form {% endfor %} -
- +
+