Fixed the duplicate slots view.
The script would not clear the screen upon recalculation also the list of duplicates would increase with every iteration because the variables weren't properly reset.
Patch by: Merio Ferraro, Lennard de Rijk
Reviewed by: to-be-reviewed
--- a/app/soc/content/js/duplicate-slots-090330.js Mon Mar 30 21:12:44 2009 +0000
+++ b/app/soc/content/js/duplicate-slots-090330.js Mon Mar 30 21:16:18 2009 +0000
@@ -12,6 +12,7 @@
this.showDuplicatesInit = function() {
// Remember this object for Javascript scoping
+ html_string = '';
var this_object = this;
var NUMBER_OF_ORGS = number_of_orgs;
var OFFSET_LENGTH = offset_length;
@@ -59,6 +60,8 @@
function showDuplicates(url_to_query,OFFSET_LENGTH,NUMBER_OF_ORGS) {
var current_offset = 0;
+ orgs_details = {};
+ assigned_proposals = new Array();
// Here Ajax call is handled
setTimeout(function() {
@@ -163,7 +166,8 @@
// public function to output actual HTML out of the data (cached or not)
this.showDuplicatesHtml = function(orgs_details,student,student_key,proposals) {
- if (html_string==='') {
+ if (html_string == '') {
+ $("#div_duplicate_slots").html('');
html_string='<ul>';
}
html_string+= '<li>Student: <strong><a href="/student/show/'+student_key+'">'+student.name+'</a></strong> (<a href="mailto:'+student.contact+'">'+student.contact+'</a>)';
--- a/app/soc/templates/soc/program/show_duplicates.html Mon Mar 30 21:12:44 2009 +0000
+++ b/app/soc/templates/soc/program/show_duplicates.html Mon Mar 30 21:16:18 2009 +0000
@@ -37,6 +37,7 @@
// then the button will show "recalculate" instead of "calculate"
$("#id_button_duplicate_slots").val("Recalculate");
// and then we will show the html based on the cache
+ html_string = '';
for (var student_key in cache.data.students) {
duplicateSlots.showDuplicatesHtml(cache.data.orgs,cache.data.students[student_key],student_key,cache.data.students[student_key].proposals);
}