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

Change the way the hierarchy works in public view. No more optgroups.

parent a8774abb
No related branches found
No related tags found
No related merge requests found
...@@ -354,14 +354,18 @@ class Courses_PublicViewController extends App_Controller_Action { ...@@ -354,14 +354,18 @@ class Courses_PublicViewController extends App_Controller_Action {
foreach ($hierarchy as $collegeId => $college) { foreach ($hierarchy as $collegeId => $college) {
$colleges[$collegeId] = $college['name']; $colleges[$collegeId] = $college['name'];
foreach ($college['departments'] as $departmentId => $department) { foreach ($college['departments'] as $departmentId => $department) {
$departments[$college['name']][$departmentId] = $department['name']; $departments[$department['name']] = array('collegeId' => $collegeId, 'departmentId' => $departmentId);
$departmentsSerial[$departmentId] = $department['name']; $departmentsSerial[$departmentId] = $department['name'];
foreach ($department['subjects'] as $subjectCode => $subjectName) { foreach ($department['subjects'] as $subjectCode => $subjectName) {
$subjects[$department['name']][$subjectCode] = $subjectCode . ' - ' . $subjectName; $subjects[$subjectCode . ' - ' . $subjectName] = array('departmentId' => $departmentId, 'subjectCode' => $subjectCode);
$subjectsSerial[$subjectCode] = $subjectCode . ' - ' . $subjectName; $subjectsSerial[$subjectCode] = $subjectCode . ' - ' . $subjectName;
} }
} }
} }
ksort($departments);
ksort($subjects);
$this->view->colleges = $colleges; $this->view->colleges = $colleges;
$this->view->departments = $departments; $this->view->departments = $departments;
$this->view->departmentsSerial = $departmentsSerial; $this->view->departmentsSerial = $departmentsSerial;
......
...@@ -23,11 +23,36 @@ ...@@ -23,11 +23,36 @@
</tr> </tr>
<tr class="even"> <tr class="even">
<th>Department</th> <th>Department</th>
<td><?php echo $this->formSelect('department', $this->criteria['department'], null, array(0 => '--Select a Department--') + $this->departments); ?></td> <td>
<?php // echo $this->formSelect('department', $this->criteria['department'], null, array(0 => '--Select a Department--') + $this->departments); ?>
<select id="department" name="department">
<option value="0">--Select a Department--</option>
<?php foreach ($this->departments as $departmentName => $departmentInfo) { ?>
<option rel="<?php echo $departmentInfo['collegeId']; ?>"
value="<?php echo $departmentInfo['departmentId']; ?>"
<?php if ($this->criteria['department'] == $departmentInfo['departmentId']) { ?>selected="selected"<?php } ?>
>
<?php echo $departmentName; ?>
</option>
<?php } ?>
</select>
</td>
</tr> </tr>
<tr class="odd"> <tr class="odd">
<th>Subject Area</th> <th>Subject Area</th>
<td><?php echo $this->formSelect('subject', $this->criteria['subject'], null, array('' => '--Select a Subject--') + $this->subjects); ?></td> <td>
<select id="subject" name="subject">
<option value="0">--Select a Subject--</option>
<?php foreach ($this->subjects as $subjectName => $subjectInfo) { ?>
<option rel="<?php echo $subjectInfo['departmentId']; ?>"
value="<?php echo $subjectInfo['subjectCode']; ?>"
<?php if ($this->criteria['subject'] == $subjectInfo['subjectCode']) { ?>selected="selected"<?php } ?>
>
<?php echo $subjectName; ?>
</option>
<?php }?>
</select>
</td>
</tr> </tr>
<tr class="even"> <tr class="even">
<th>Course Number</th> <th>Course Number</th>
......
...@@ -29,18 +29,18 @@ function handleChangeSelectHierarchy() ...@@ -29,18 +29,18 @@ function handleChangeSelectHierarchy()
var departmentSelect = document.getElementById('department'); var departmentSelect = document.getElementById('department');
var subjectSelect = document.getElementById('subject'); var subjectSelect = document.getElementById('subject');
var selectedCollege = collegeSelect.options[collegeSelect.selectedIndex].label; var selectedCollegeId = collegeSelect.options[collegeSelect.selectedIndex].value;
var optGroups = departmentSelect.getElementsByTagName('optgroup'); var options = departmentSelect.getElementsByTagName('option');
for (var i = optGroups.length - 1; i >= 0; i--) { for (var i = options.length - 1; i >= 0; i--) {
if (optGroups[i].label == selectedCollege || collegeSelect.value == 0) { if (options[i].getAttribute('rel') == selectedCollegeId || collegeSelect.value == 0 || options[i].value == 0) {
optGroups[i].style.display = '' options[i].style.display = '';
} else { } else {
optGroups[i].style.display = 'none'; options[i].style.display = 'none';
} }
} }
var selectedDepartment = departmentSelect.options[departmentSelect.selectedIndex]; var selectedDepartment = departmentSelect.options[departmentSelect.selectedIndex];
if (selectedDepartment.parentNode.style.display == 'none') { if (selectedDepartment.style.display == 'none') {
departmentSelect.selectedIndex = 0; departmentSelect.selectedIndex = 0;
} }
...@@ -49,27 +49,27 @@ function handleChangeSelectHierarchy() ...@@ -49,27 +49,27 @@ function handleChangeSelectHierarchy()
if (departmentSelect.selectedIndex == 0) { if (departmentSelect.selectedIndex == 0) {
var options = departmentSelect.getElementsByTagName('option'); var options = departmentSelect.getElementsByTagName('option');
for (var i = options.length - 1; i >= 0; i--) { for (var i = options.length - 1; i >= 0; i--) {
if (options[i].parentNode.style.display == 'none') { if (options[i].style.display == 'none') {
continue; continue;
} }
selectedDepartments.push(options[i].label); selectedDepartments.push(options[i].value);
} }
} else { } else {
selectedDepartments.push(departmentSelect.options[departmentSelect.selectedIndex].label); selectedDepartments.push(departmentSelect.options[departmentSelect.selectedIndex].value);
} }
optGroups = subjectSelect.getElementsByTagName('optgroup'); options = subjectSelect.getElementsByTagName('option');
for (var i = optGroups.length - 1; i >= 0; i--) { for (var i = options.length - 1; i >= 0; i--) {
if (selectedDepartments.inArray(optGroups[i].label)) { if (selectedDepartments.inArray(options[i].getAttribute('rel')) || options[i].value == 0) {
optGroups[i].style.display = '' options[i].style.display = '';
} else { } else {
optGroups[i].style.display = 'none'; options[i].style.display = 'none';
} }
} }
var selectedSubject = subjectSelect.options[subjectSelect.selectedIndex]; var selectedSubject = subjectSelect.options[subjectSelect.selectedIndex];
if (selectedSubject.parentNode.style.display == 'none') { if (selectedSubject.style.display == 'none') {
subjectSelect.selectedIndex = 0; subjectSelect.selectedIndex = 0;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment