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 {
foreach ($hierarchy as $collegeId => $college) {
$colleges[$collegeId] = $college['name'];
foreach ($college['departments'] as $departmentId => $department) {
$departments[$college['name']][$departmentId] = $department['name'];
$departments[$department['name']] = array('collegeId' => $collegeId, 'departmentId' => $departmentId);
$departmentsSerial[$departmentId] = $department['name'];
foreach ($department['subjects'] as $subjectCode => $subjectName) {
$subjects[$department['name']][$subjectCode] = $subjectCode . ' - ' . $subjectName;
$subjects[$subjectCode . ' - ' . $subjectName] = array('departmentId' => $departmentId, 'subjectCode' => $subjectCode);
$subjectsSerial[$subjectCode] = $subjectCode . ' - ' . $subjectName;
}
}
}
ksort($departments);
ksort($subjects);
$this->view->colleges = $colleges;
$this->view->departments = $departments;
$this->view->departmentsSerial = $departmentsSerial;
......
......@@ -23,11 +23,36 @@
</tr>
<tr class="even">
<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 class="odd">
<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 class="even">
<th>Course Number</th>
......
......@@ -29,18 +29,18 @@ function handleChangeSelectHierarchy()
var departmentSelect = document.getElementById('department');
var subjectSelect = document.getElementById('subject');
var selectedCollege = collegeSelect.options[collegeSelect.selectedIndex].label;
var optGroups = departmentSelect.getElementsByTagName('optgroup');
for (var i = optGroups.length - 1; i >= 0; i--) {
if (optGroups[i].label == selectedCollege || collegeSelect.value == 0) {
optGroups[i].style.display = ''
var selectedCollegeId = collegeSelect.options[collegeSelect.selectedIndex].value;
var options = departmentSelect.getElementsByTagName('option');
for (var i = options.length - 1; i >= 0; i--) {
if (options[i].getAttribute('rel') == selectedCollegeId || collegeSelect.value == 0 || options[i].value == 0) {
options[i].style.display = '';
} else {
optGroups[i].style.display = 'none';
options[i].style.display = 'none';
}
}
var selectedDepartment = departmentSelect.options[departmentSelect.selectedIndex];
if (selectedDepartment.parentNode.style.display == 'none') {
if (selectedDepartment.style.display == 'none') {
departmentSelect.selectedIndex = 0;
}
......@@ -49,27 +49,27 @@ function handleChangeSelectHierarchy()
if (departmentSelect.selectedIndex == 0) {
var options = departmentSelect.getElementsByTagName('option');
for (var i = options.length - 1; i >= 0; i--) {
if (options[i].parentNode.style.display == 'none') {
if (options[i].style.display == 'none') {
continue;
}
selectedDepartments.push(options[i].label);
selectedDepartments.push(options[i].value);
}
} 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--) {
if (selectedDepartments.inArray(optGroups[i].label)) {
optGroups[i].style.display = ''
for (var i = options.length - 1; i >= 0; i--) {
if (selectedDepartments.inArray(options[i].getAttribute('rel')) || options[i].value == 0) {
options[i].style.display = '';
} else {
optGroups[i].style.display = 'none';
options[i].style.display = 'none';
}
}
var selectedSubject = subjectSelect.options[subjectSelect.selectedIndex];
if (selectedSubject.parentNode.style.display == 'none') {
if (selectedSubject.style.display == 'none') {
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