Skip to content

Commit

Permalink
[FIXED Issue #17] Refactored how the HTML is rendered, removing the c…
Browse files Browse the repository at this point in the history
…heckbox from the <a> tag and pulling the parent checkbox from the row class.
  • Loading branch information
Corey Oordt committed May 15, 2011
1 parent 141f753 commit 70e758e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 7 additions & 5 deletions editor/templates/admin/editor/tree_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
(function($) {
$(document).ready(function() {
treeTable = $("#result_list").treeTable({initialState : "{{ EDITOR_TREE_INITIAL_STATE }}"});
function toggleChildren() {
this.checked = event.currentTarget.checked;
var row = this.parentNode.parentNode.parentNode;
function toggleChildren(index, value) {
var row = value.parentNode.parentNode;
if (row.className.match(/child-of-node-\d+/)) {
value.checked = /child-of-node-(\d+)/.exec(row.className);
}
if($(row).hasClass("parent")) {
$("table.treeTable tbody tr.child-of-" + row.id + " input").each(toggleChildren);
}
Expand All @@ -17,8 +19,8 @@
$('.action-select').each(
function(){
$(this).bind('click', function(event){
// Get the tr from checkbox -> a -> td -> tr
var row = event.currentTarget.parentNode.parentNode.parentNode;
// Get the tr from checkbox -> td -> tr
var row = event.currentTarget.parentNode.parentNode;
$("table.treeTable tbody tr.child-of-" + row.id + " input").each(toggleChildren);
});
});
Expand Down
8 changes: 4 additions & 4 deletions editor/templatetags/admin_tree_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def items_for_tree_result(cl, result, form):
row_class = ' class="nowrap"'
if first:
try:
f, attr, value = lookup_field('action_checkbox', result, cl.model_admin)
result_repr = mark_safe("%s%s" % (value, result_repr))
f, attr, checkbox_value = lookup_field('action_checkbox', result, cl.model_admin)
#result_repr = mark_safe("%s%s" % (value, result_repr))
if row_class:
row_class = "%s%s" % (row_class[:-1],' disclosure"')
else:
Expand All @@ -72,8 +72,8 @@ def items_for_tree_result(cl, result, form):
value = result.serializable_value(attr)
result_id = repr(force_unicode(value))[1:]
first = False
yield mark_safe(u'<%s%s><a href="%s"%s>%s</a></%s>' % \
(table_tag, row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))
yield mark_safe(u'<%s%s>%s<a href="%s"%s>%s</a></%s>' % \
(table_tag, row_class, checkbox_value, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %s); return false;"' % result_id or ''), conditional_escape(result_repr), table_tag))
else:
# By default the fields come from ModelAdmin.list_editable, but if we pull
# the fields out of the form instead of list_editable custom admins
Expand Down

0 comments on commit 70e758e

Please sign in to comment.