Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fewer form confirmation 381 #413

Draft
wants to merge 14 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/config/contributors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion app/controllers/main_routes/laborStatusForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<laborStatusKey>', methods=['GET'])
def laborStatusForm(laborStatusKey = None):
""" Render labor Status Form, and pre-populate LaborStatusForm page with the correct information when redirected from Labor History."""
Expand All @@ -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()
Expand All @@ -57,6 +60,7 @@ def laborStatusForm(laborStatusKey = None):
forms = forms,
students = students,
terms = terms,
supervisorForms = supervisorForms,
staffs = staffs,
departments = departments)

Expand Down
114 changes: 50 additions & 64 deletions app/static/js/laborStatusForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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();
});
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -227,8 +255,9 @@ function getDepartment(object, stopSelectRefresh="") { // get department from se
.attr("data-content", "<span>" + response[key].position + " " + "(" + response[key].WLS+ ")"
+ "</span>" + "<small class='text-muted'>" + " " + "(" + response[key].positionCode + ")" + "</small>")
.attr("id", key)
.attr("value", response[key].position)
.attr("value", key)
.attr("data-wls", response[key].WLS)

);

}
Expand Down Expand Up @@ -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");
Expand All @@ -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
Expand All @@ -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";
Expand Down Expand Up @@ -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, "");
Expand Down Expand Up @@ -718,7 +706,6 @@ $("#resetConfirmButton").click(function(){
$("#warningModal").modal('hide');
globalArrayOfStudents = [];
$("#tbodyid tr").remove();
document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=0;";
location.reload();
});

Expand All @@ -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:<br><br>" +
$("#SubmitModalText").html("Labor status form will be submitted for:<br><br>" +
"<ul style=\"display:inline-block;text-align:left;\">" +
modalList.join("</li>")+"</ul>"+
"<br><br>The labor status form will be eligible for approval in one business day.");
Expand Down Expand Up @@ -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");
}
}
Expand Down Expand Up @@ -893,4 +878,5 @@ function releaseAndRehire(){
}
}
})

}
16 changes: 14 additions & 2 deletions app/static/js/supervisorPortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 22 additions & 9 deletions app/templates/main/laborStatusForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
{% block styles %}
{{super()}}
<link rel="stylesheet" href="/static/css/laborStatusForm.css?u={{lastStaticUpdate}}" type="text/css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.21/b-1.6.2/datatables.min.css"/>
{% endblock %}

​{% block scripts %}
{{super()}}
<script type="text/javascript" src="https://cdn.datatables.net/v/bs/dt-1.10.21/b-1.6.2/datatables.min.js"></script>
<script type=text/javascript src="{{url_for('static', filename='js/laborStatusForm.js')}}?u={{lastStaticUpdate}}"></script>
{% endblock %}

Expand Down Expand Up @@ -167,8 +169,8 @@ <h1 id ="title">Labor Status Form
{% endfor %}
</select>
</div>
<div class= "form-group " id="Position">
<!--selectpicker for positio3-->
<div class= "form-group " id="positionDiv">
<!--selectpicker for position-->
<label for="position"><span class="tooltip-right" data-tooltip="Required">Position (WLS)<span class="required-mark">*</span></span></label>
<select class="selectpicker disable"
name='position'
Expand Down Expand Up @@ -208,7 +210,7 @@ <h1 id ="title">Labor Status Form
{% if forms %} <option value="{{forms.weeklyHours}}" selected >{{forms.weeklyHours}}</option> {% endif %}
</select>​
</div>
<div id="contractHours" class= "form-group ">
<div id="contractHours" class= "form-group " hidden>
<!-- Contract hours for breaks -->
<label for="selectedContractHours"><span class="tooltip-right" data-tooltip="Required">Total Contract Hours<span class="required-mark">*</span></span></label>
<input class="form-control quantity disable"
Expand All @@ -231,22 +233,33 @@ <h1 id ="title">Labor Status Form
value = "formSubmission"
onclick="checkIfFreshman();">Add Student
</button>
<strong>*Want to add multiple students for this supervisor? Add them now!</strong>
</div>
<br />

<table class="table table-striped" id="mytable">
<table class="table table-striped" class="display" id="lsfTable">
<thead>
<tr>
<th>Student </th>
<th id ='studentName'>Student </th>
<th id = "positionTable">Position (WLS) </th>
<th id = "jobTable">Job Type </th>
<th id = "hoursTable">Hours</th>
<th id = "term">Term</th>
<th id = "datesTable">Contract Dates</th>
<th id = "notes">Notes</th>
<th>Remove</th>
<th id = "edit">Edit</th>
</tr>
</thead>
{% for form in supervisorForms %}
<tr>
<td>{{form.formID.studentName}}</td>
<td>{{form.formID.POSN_CODE}} ({{form.formID.WLS}})</td>
<td>{{form.formID.jobType}}</td>
<td>{{form.formID.weeklyHours}}</td>
<td>{{form.formID.termCode.termName}}</td>
<td>{{form.formID.startDate}} - {{form.formID.endDate}}</td>
<td><a href="#\" data-toggle="modal" tabindex="0" aria-label="View Notes" onclick = "showNotesModal(this)" id= "nGlyphicon" ><span class="glyphicon glyphicon-edit"></span></a></td>
<td><a href="/alterLSF/{{form.formID.laborStatusFormID}}"><button type="button" class="btn btn-primary">Edit</button></a></td>
</tr>
</thead>
{% endfor %}
<tbody id='tbodyid'></tbody>
</table>
<div class="col-md-12" id="reviewButton">
Expand Down