Fixed error introduced in _stormtask_plain_tree() to order tasks trees

This commit is contained in:
Manuel Cillero 2017-09-19 17:06:31 +02:00
parent ed2dd31a97
commit 0ff3402b99
2 changed files with 4 additions and 4 deletions

View file

@ -499,7 +499,7 @@ function stormtask_tasks_filter_reset($form, &$form_state) {
function _stormtask_project_tasks_js($project_nid) {
$tree = _stormtask_get_tree($project_nid);
$tasks = _stormtask_plain_tree($tree);
$tasks = _stormtask_plain_tree($tree, TRUE);
print drupal_to_js($tasks);
exit();
}

View file

@ -1061,11 +1061,11 @@ function _stormtask_get_tree($project_nid, $parent_nid = 0, $depth = -1, $max_de
return isset($tree) ? $tree : array();
}
function _stormtask_plain_tree($tree) {
function _stormtask_plain_tree($tree, $forjs = FALSE) {
$rows = array();
foreach ($tree as $item) {
// Using the space character to preserve the order of tree elements:
$nid = " $item->nid";
// Using the space char to preserve the order in Javascript loaded trees:
$nid = $forjs ? " $item->nid" : $item->nid;
$title = htmlspecialchars_decode(check_plain($item->title));
if ($item->stepno) $title = check_plain($item->stepno) .' '. $title;
if ($nid) $rows[$nid] = str_repeat('--', $item->depth) .' '. $title;