-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated the code so it will work with or without Grappelli installed
- Loading branch information
Showing
7 changed files
with
105 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
categories/editor/templates/admin/editor/grappelli_tree_editor.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{% extends "admin/change_list.html" %} | ||
{% load adminmedia admin_list i18n admin_tree_list %} | ||
{% block extrahead %} | ||
{{block.super}} | ||
<script type="text/javascript"> | ||
(function($) { | ||
$(document).ready(function() { | ||
var srchString = document.getElementById('grp-changelist-search').value; | ||
if (srchString == '') | ||
treeTable = $("#result_list").treeTable({initialState : "{{ EDITOR_TREE_INITIAL_STATE }}"}); | ||
else | ||
treeTable = $("#result_list").treeTable({initialState : "expanded"}); | ||
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); | ||
} | ||
$("tr input.action-select").actions(); | ||
}; | ||
$('.action-select').each( | ||
function(){ | ||
$(this).bind('click', function(event){ | ||
// Get the tr from checkbox -> td -> tr | ||
var row = event.currentTarget.parentNode.parentNode; | ||
$("table.treeTable tbody tr.child-of-" + row.id + " input").each(toggleChildren); | ||
}); | ||
}); | ||
}); | ||
})(django.jQuery); | ||
</script> | ||
{% endblock %} | ||
{% block result_list %} | ||
{% result_tree_list cl %} | ||
{% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %} | ||
{% endblock %} |
28 changes: 28 additions & 0 deletions
28
categories/editor/templates/admin/editor/grappelli_tree_list_results.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{% if result_hidden_fields %} | ||
<div class="hiddenfields"> {# DIV for HTML validation #} | ||
{% for item in result_hidden_fields %}{{ item }}{% endfor %} | ||
</div> | ||
{% endif %} | ||
|
||
{% if results %} | ||
<div class="grp-module grp-changelist-results"> | ||
<table cellspacing="0" id="result_list"> | ||
<thead> | ||
<tr> | ||
{% for header in result_headers %} | ||
<th scope="col" {{ header.class_attrib }}> | ||
{% if header.sortable %}<a href="{{ header.url }}">{% endif %} | ||
{{ header.text|capfirst }} | ||
{% if header.sortable %}</a>{% endif %} | ||
</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for result in results %} | ||
<tr id="node-{{ result.pk }}" class="grp-row {% cycle 'grp-row-even' 'grp-row-odd' %}{% if result.parent_pk %} child-of-node-{{result.parent_pk}}{% endif %}">{% for item in result %}{{ item }}{% endfor %}</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 19 additions & 23 deletions
42
categories/editor/templates/admin/editor/tree_list_results.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
{% if result_hidden_fields %} | ||
<div class="hiddenfields"> {# DIV for HTML validation #} | ||
{% for item in result_hidden_fields %}{{ item }}{% endfor %} | ||
</div> | ||
<div class="hiddenfields"> {# DIV for HTML validation #} | ||
{% for item in result_hidden_fields %}{{ item }}{% endfor %} | ||
</div> | ||
{% endif %} | ||
|
||
{% if results %} | ||
<div class="grp-module grp-changelist-results"> | ||
<table cellspacing="0" id="result_list"> | ||
<thead> | ||
<tr> | ||
{% for header in result_headers %} | ||
<th scope="col" {{ header.class_attrib }}> | ||
{% if header.sortable %}<a href="{{ header.url }}">{% endif %} | ||
{{ header.text|capfirst }} | ||
{% if header.sortable %}</a>{% endif %} | ||
</th> | ||
{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for result in results %} | ||
<tr id="node-{{ result.pk }}" class="grp-row {% cycle 'grp-row-even' 'grp-row-odd' %}{% if result.parent_pk %} child-of-node-{{result.parent_pk}}{% endif %}">{% for item in result %}{{ item }}{% endfor %}</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<div class="results"> | ||
<table cellspacing="0" id="result_list"> | ||
<thead> | ||
<tr> | ||
{% for header in result_headers %}<th{{ header.class_attrib }}> | ||
{% if header.sortable %}<a href="{{ header.url }}">{% endif %} | ||
{{ header.text|capfirst }} | ||
{% if header.sortable %}</a>{% endif %}</th>{% endfor %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for result in results %} | ||
<tr id="node-{{ result.pk }}" class="{% cycle 'row1' 'row2' %}{% if result.parent_pk %} child-of-node-{{result.parent_pk}}{% endif %}">{% for item in result %}{{ item }}{% endfor %}</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters