Make the initial state of the editor tree an app setting with collapsed as the default.

This commit is contained in:
Erik Simmler 2011-03-26 09:21:30 -04:00
parent e8b7aeca8f
commit 858a356e42
3 changed files with 4 additions and 2 deletions

View file

@ -7,3 +7,5 @@ STATIC_URL = getattr(settings, 'STATIC_URL', settings.MEDIA_URL)
if STATIC_URL == None:
STATIC_URL = settings.MEDIA_URL
MEDIA_PATH = getattr(settings, 'EDITOR_MEDIA_PATH', '%seditor/' % STATIC_URL)
TREE_INITIAL_STATE = getattr(settings, 'EDITOR_TREE_INITIAL_STATE', 'collapsed')

View file

@ -5,8 +5,7 @@
<script type="text/javascript">
(function($) {
$(document).ready(function() {
//treeTable = $("#result_list").treeTable({initialState : "expanded"});
treeTable = $("#result_list").treeTable({initialState : "collapsed"});
treeTable = $("#result_list").treeTable({initialState : "{{ EDITOR_TREE_INITIAL_STATE }}"});
function toggleChildren() {
this.checked = event.currentTarget.checked;
var row = this.parentNode.parentNode.parentNode;

View file

@ -77,6 +77,7 @@ class TreeEditor(admin.ModelAdmin):
"""
extra_context = extra_context or {}
extra_context['EDITOR_MEDIA_PATH'] = settings.MEDIA_PATH
extra_context['EDITOR_TREE_INITIAL_STATE'] = settings.TREE_INITIAL_STATE
extra_context['tree_structure'] = mark_safe(simplejson.dumps(
_build_tree_structure(self.model)))