Skip to content

Commit

Permalink
Fixed #348 -- Fixed bug in admin JavaScript filter interface. Thanks …
Browse files Browse the repository at this point in the history
…for the patch, Gary Wilson

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6015 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Aug 25, 2007
1 parent 132605d commit 70740d6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions django/contrib/admin/media/js/SelectBox.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var SelectBox = {
SelectBox.cache[id] = new Array(); SelectBox.cache[id] = new Array();
var cache = SelectBox.cache[id]; var cache = SelectBox.cache[id];
for (var i = 0; (node = box.options[i]); i++) { for (var i = 0; (node = box.options[i]); i++) {
cache.push({ value: node.value, text: node.text, displayed: 1 }); cache.push({value: node.value, text: node.text, displayed: 1});
} }
}, },
redisplay: function(id) { redisplay: function(id) {
Expand Down Expand Up @@ -50,7 +50,7 @@ var SelectBox = {
SelectBox.cache[id].length--; SelectBox.cache[id].length--;
}, },
add_to_cache: function(id, option) { add_to_cache: function(id, option) {
SelectBox.cache[id].push({ value: option.value, text: option.text, displayed: 1 }); SelectBox.cache[id].push({value: option.value, text: option.text, displayed: 1});
}, },
cache_contains: function(id, value) { cache_contains: function(id, value) {
// Check if an item is contained in the cache // Check if an item is contained in the cache
Expand All @@ -68,7 +68,7 @@ var SelectBox = {
var option; var option;
for (var i = 0; (option = from_box.options[i]); i++) { for (var i = 0; (option = from_box.options[i]); i++) {
if (option.selected && SelectBox.cache_contains(from, option.value)) { if (option.selected && SelectBox.cache_contains(from, option.value)) {
SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 }); SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
SelectBox.delete_from_cache(from, option.value); SelectBox.delete_from_cache(from, option.value);
} }
} }
Expand All @@ -80,8 +80,10 @@ var SelectBox = {
var to_box = document.getElementById(to); var to_box = document.getElementById(to);
var option; var option;
for (var i = 0; (option = from_box.options[i]); i++) { for (var i = 0; (option = from_box.options[i]); i++) {
SelectBox.add_to_cache(to, { value: option.value, text: option.text, displayed: 1 }); if (SelectBox.cache_contains(from, option.value)) {
SelectBox.delete_from_cache(from, option.value); SelectBox.add_to_cache(to, {value: option.value, text: option.text, displayed: 1});
SelectBox.delete_from_cache(from, option.value);
}
} }
SelectBox.redisplay(from); SelectBox.redisplay(from);
SelectBox.redisplay(to); SelectBox.redisplay(to);
Expand Down

0 comments on commit 70740d6

Please sign in to comment.