Skip to content
Snippets Groups Projects
Commit 295091b8 authored by Tim Steiner's avatar Tim Steiner
Browse files

Add javascript to handle the creation/removal of 'X' crosslistings when web...

Add javascript to handle the creation/removal of 'X' crosslistings when web delivery method is seleceted/deselected.
parent ea61692b
Branches
Tags
No related merge requests found
......@@ -82,7 +82,7 @@ document.formSessionId = '<?php echo $this->formSessionId; ?>';
<h2>Crosslistings</h2>
<fieldset class="three_column">
<table>
<table id="crosslistingsTable">
<?php $hasTieIn = false;
foreach($this->course->getCrosslistings() as $key => $crosslist) {
if($crosslist['type'] == 'grad tie-in') { $hasTieIn = true; }
......@@ -539,6 +539,7 @@ document.formSessionId = '<?php echo $this->formSessionId; ?>';
<div class="column">
<input type="checkbox"
class="deliveryMethodsInput"
id="deliveryMethods_classroom"
name="deliveryMethods[]"
value="Classroom"
......@@ -551,6 +552,7 @@ document.formSessionId = '<?php echo $this->formSessionId; ?>';
<div class="column">
<input type="checkbox"
class="deliveryMethodsInput"
id="deliveryMethods_web"
name="deliveryMethods[]"
value="Web"
......
......@@ -42,6 +42,7 @@ $(document).ready(function() {
$('.activitySelect').change(handleChangeActivity);
$('#credits input').change(handleChangeCredits);
$('.dfRemovalRadio').change(handleChangeDfRemoval);
$('.deliveryMethodsInput').change(handleChangeDeliveryMethods);
$('#dialog').dialog({
autoOpen: false,
......@@ -332,21 +333,21 @@ function handleChangeCourseLetter()
var courseLetter = this.value;
var message = '';
switch (courseLetter) {
switch (courseLetter.toUpperCase()) {
case 'L':
message = '"L" represents a laboratory class.';
break;
case 'H':
message = '"L" represents an honors class.';
message = '"H" represents an honors class.';
break;
case 'X':
message = '"L" represents an independent study class.';
message = '"X" represents a course that has a web delivery method.';
break;
case 'G':
message = '"L" represents professional courses for graduate credit.';
message = '"G" represents professional courses for graduate credit.';
break;
case 'C':
......@@ -535,6 +536,85 @@ function handleChangeDfRemoval()
}
}
function doesCrosslistExist(subject, courseNumber, courseLetter)
{
var itDoes = false;
$('#crosslistingsTable tr').each(function(index) {
if ($(this).attr('class') == 'hidden_new_record') {
return;
}
var courseCodeInputs = $(this).find('input.courseCodeInput');
if (courseCodeInputs.length != 3) {
return;
}
if (courseCodeInputs[0].value == subject &&
courseCodeInputs[1].value == courseNumber &&
courseCodeInputs[2].value == courseLetter) {
itDoes = index;
}
})
return itDoes;
}
function handleChangeDeliveryMethods()
{
var message = '';
var addCrosslist = false;
var removeCrosslist = false;
var subject = $('#subject').val();
var courseNumber = $('#courseNumber').val();
var courseLetter = $('#courseLetter').val();
switch (this.value) {
case 'Web':
var crosslistExists = doesCrosslistExist(subject, courseNumber, 'X');
if (this.checked && !crosslistExists) {
message = 'Web delivered courses must have a crosslisting ending in an X. It will be created now.';
addCrosslist = true;
} else if (!this.checked && crosslistExists !== false) {
message = 'Non-Web delivered courses must not have a crosslisting ending in an X. It will be removed now.';
removeCrosslist = crosslistExists;
}
break;
}
if (message) {
var deliveryMethodNode = this;
queuePopup(
message,
{
'Reset': function() {
deliveryMethodNode.checked = !deliveryMethodNode.checked;
$(this).dialog('close');
},
'Ignore': function() {
$(this).dialog('close');
},
'Ok': function() {
if (addCrosslist) {
$('[alt=Add Crosslisting]').parent().click();
var crosslistingRows = $('#crosslistingsTable tr');
var newCrosslistingRow = $(crosslistingRows[crosslistingRows.length - 3]);
var newCrosslistingInputs = newCrosslistingRow.find('input.courseCodeInput');
document.foobar = newCrosslistingInputs;
$(newCrosslistingInputs[0]).val(subject);
$(newCrosslistingInputs[1]).val(courseNumber);
$(newCrosslistingInputs[2]).val('X');
}
if (removeCrosslist !== false) {
$('#crosslistingsTable tr:eq(' + removeCrosslist + ') a').click()
}
$(this).dialog('close');
}
},
'dfRemoval'
);
}
}
function handleOutcomeClicked()
{
this.blur();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment