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

Pull Spring and Fall terms out of the Term select - IN PROCESS #339

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
14 changes: 13 additions & 1 deletion app/controllers/main_routes/laborStatusForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,21 @@ def laborStatusForm(laborStatusKey = None):

# Logged in
students = Tracy().getStudents()
terms = Term.select().where(Term.termState == "open") # changed to term state, open, closed, inactive
allTerms = Term.select().where(Term.termState == "open") # changed to term state, open, closed, inactive
staffs = Tracy().getSupervisors()
departments = Tracy().getDepartments()







springFallOnlyTerms = {}
terms = []
[terms.append(term) if (term.isBreak or term.isAcademicYear) else springFallOnlyTerms[str(term.termCode)[:4]].append(term) if
str(term.termCode)[:4] in springFallOnlyTerms else springFallOnlyTerms.__setitem__(str(term.termCode)[:4], [term]) for term in allTerms]

# Only prepopulate form if current user is the supervisor or creator of the form.
if laborStatusKey != None:
selectedLSForm = LaborStatusForm.get(LaborStatusForm.laborStatusFormID == laborStatusKey)
Expand All @@ -57,6 +68,7 @@ def laborStatusForm(laborStatusKey = None):
forms = forms,
students = students,
terms = terms,
springFallOnlyTerms = springFallOnlyTerms,
staffs = staffs,
departments = departments)

Expand Down
4 changes: 2 additions & 2 deletions app/static/css/laborStatusForm.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
.floatleft {
float: left;
width: 47%;
height: 310px;
height: 80%;
}

.floatright {
float: right;
width: 47%;
height: 310px;
height: 80%;
}

#mytable {
Expand Down
63 changes: 54 additions & 9 deletions app/static/js/laborStatusForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ $(document).ready(function(){
for (i in parsedArrayOfStudentCookies) {
createAndFillTable(parsedArrayOfStudentCookies[i]);
}
$("#selectedTerm option[value=" + parsedArrayOfStudentCookies[0].stuTermCode + "]").attr('selected', 'selected');
$("#selectedTerm").val(parsedArrayOfStudentCookies[0].stuTermCode).attr('name', parsedArrayOfStudentCookies[0].stuTermName)
$("#selectedTerm option[value=" + parsedArrayOfStudentCookies[0].selectedTerm + "]").attr('selected', 'selected');
$("#selectedSupervisor option[value=" + parsedArrayOfStudentCookies[0].stuSupervisorID + "]").attr('selected', 'selected');
$("#selectedDepartment option[value=\"" + parsedArrayOfStudentCookies[0].stuDepartmentORG + "\"]").attr('selected', 'selected');
if (parsedArrayOfStudentCookies[0].stuTermCode != parsedArrayOfStudentCookies[0].selectedTerm ){
showCheckbox(parsedArrayOfStudentCookies[0].stuTermCode)
$(".termChecked[value='" + parsedArrayOfStudentCookies[0].stuTermCode + "']").prop('checked', true);
}
getDepartment($("#selectedDepartment"));
preFilledDate($("#selectedTerm"));
showAccessLevel($("#selectedTerm"));
preFilledDate($("#term"));
showAccessLevel($("#term"));
disableTermSupervisorDept();
}
});
Expand All @@ -33,6 +38,34 @@ $("#laborStatusForm").submit(function(event) {
event.preventDefault();
});

$("#selectedTerm").change(function(){
var term =$(this).val();
lastTwoDigit = term % 100;
$('.termChecked').prop('checked', false);
if (lastTwoDigit == 0){
showCheckbox(term);
}
else{
$(".termCheckbox").hide()
}
$("#term").val("")
$("#term").val(term).attr('name', $("#selectedTerm").find("option:selected").attr('name'))
})

$('.termChecked').on('change', function() {
if ($(this).is(':checked')){
$("#term").val("");
$('.termChecked').not(this).prop('checked', false);
$('#term').attr('name', $(this).attr('name')).val($(this).val());
}
else{
$("#term").val("");
$("#term").attr('name', $("#selectedTerm").find("option:selected").attr('name')).val($("#selectedTerm").find("option:selected").val());
}
preFilledDate($("#term"));
showAccessLevel($("#term"));
});

$("#calendarIcon1").click(function() {
$("#dateTimePicker1").datepicker('show') // Shows the start date datepicker when glyphicon is clicked
});
Expand Down Expand Up @@ -60,6 +93,12 @@ $("#jobType").change(function(){ // Pops up a modal for Seconday Postion
}
});

function showCheckbox(term){
termYear = term.toString().slice(0,4);
$(".termCheckbox").show()
$('.termCheckbox').not('#' + termYear).hide();
}

function checkIfFreshman() {
var jobType = $("#jobType").val();
var wls = $("#position :selected").attr("data-wls")
Expand Down Expand Up @@ -87,6 +126,7 @@ function disableTermSupervisorDept() {
$("#selectedDepartment").prop("disabled", "disabled");
$("#departmentInfo").show();
$("#selectedDepartment").selectpicker("refresh");
$(".termChecked").prop("disabled", "disabled");
}

function preFilledDate(obj){ // get term start date and end date
Expand All @@ -106,7 +146,7 @@ function fillDates(response) { // prefill term start and term end
$("#primary-cutoff-date").text("");
$("#addMoreStudent").show();

$("#selectedTerm").on("change", function(){
$(".selectedTerm").on("change", function(){
$("#jobType").val('');
});
for (var key in response){
Expand Down Expand Up @@ -343,6 +383,7 @@ $("#JobTypes").hide();
$("#plus").hide();
$("#mytable").hide();
$("#failedTable").hide();
$(".termCheckbox").hide()


function showAccessLevel(){ // Make Table labels appear
Expand Down Expand Up @@ -412,6 +453,7 @@ function deleteRow(glyphicon) {
$("#selectedSupervisor").selectpicker("refresh");
$("#selectedDepartment").prop("disabled", false);
$("#selectedDepartment").selectpicker("refresh");
$(".termChecked").prop("disabled", false);
}
}
//END of glyphicons
Expand Down Expand Up @@ -452,7 +494,9 @@ function createStuDict(){
var department = $("#selectedDepartment").find("option:selected").text();
var departmentORG = $("#selectedDepartment").find("option:selected").val();
var departmentAccount = $("#selectedDepartment").find("option:selected").data("account");
var termCodeSelected = $("#selectedTerm").find("option:selected").val();
var termCodeSelected = $("#selectedTerm").val();
var termName = $("#term").attr('name')
var selectedTerm = $("#selectedTerm").find("option:selected").val();
var isBreak = $("#selectedTerm").find("option:selected").data("termbreak")
var studentName = $("#student option:selected").text();
if (!studentName){
Expand Down Expand Up @@ -494,13 +538,15 @@ function createStuDict(){
stuStartDate: startDate,
stuEndDate: endDate,
stuTermCode: termCodeSelected,
stuTermName: termName,
stuNotes: "",
stuLaborNotes: laborStatusFormNote,
stuSupervisor: supervisor.trim(),
stuDepartment: department.trim(),
stuDepartmentORG: departmentORG,
stuDepartmentAccount: departmentAccount,
stuSupervisorID: supervisorID,
selectedTerm: selectedTerm,
isItOverloadForm: "False",
isTermBreak: isBreak
};
Expand All @@ -520,7 +566,7 @@ function checkDuplicate(studentDict) {// checks for duplicates in the table. Thi

function checkPrimaryPositionToCreateTheTable(studentDict) {
var term = $("#selectedTerm").val();
var termName = $('#selectedTerm').find('option:selected').text();
var termName = $('#selectedTerm').find('option:selected').text();
var url = "/laborstatusform/getstudents/" + term + "/" + studentDict.stuBNumber;
var data = JSON.stringify(studentDict.stuJobType);
$.ajax({
Expand Down Expand Up @@ -548,7 +594,7 @@ function checkPrimaryPositionToCreateTheTable(studentDict) {
$('#oldPosition').html(response['position'])
$('#oldHours').html(response['hours'])

$('#newTerm').html($("#selectedTerm").find("option:selected").text());
$('#newTerm').html(studentDict.stuTermName);
$('#newSupervisor').html(studentDict.stuSupervisor)
$('#newDepartment').html(studentDict.stuDepartment +" ("+ studentDict.stuDepartmentORG+"-"+studentDict.stuDepartmentAccount +")")
$('#newPosition').html(studentDict.stuPositionCode +" - "+ studentDict.stuPosition +" ("+ studentDict.stuWLS+")")
Expand Down Expand Up @@ -664,7 +710,7 @@ function isOneLaborStatusForm(studentDict){
}

function checkTotalHours(studentDict) {
var termCode = $("#selectedTerm").val()
var termCode = $("#term").val()
var isBreak = $("#selectedTerm").find("option:selected").data("termbreak");
var hours = studentDict.stuWeeklyHours
if (isBreak) {
Expand Down Expand Up @@ -719,7 +765,6 @@ $("#resetConfirmButton").click(function(){
globalArrayOfStudents = [];
$("#tbodyid tr").remove();
document.cookie = JSON.stringify(globalArrayOfStudents) + ";max-age=0;";
console.log(document.cookie);
location.reload();
});

Expand Down
Loading