Loading...
 
Skip to main content

Gantt Chart Order not sorting as it should

Status
Open
Subject
Gantt Chart Order not sorting as it should
Version
20.x
Category
  • Bug
Feature
Gantt Chart
Resolution status
New
Submitted by
amorangi
Lastmod by
amorangi
Rating
(0)
Description

The chart is saving order correctly to the database, but when reading from the database order is the order in the table (not the order field). This read in order is then assigned to the items, then is written out incorrectly. I'm not sure how

Copy to clipboard
$orderItems = ! empty($orderField['fieldId']) ? 'f_' . $orderField['fieldId'] . '_asc' : 'created_asc'; $listItems = $trklib->list_items($trackerId, 0, -1, $orderItems, $listfields);


is supposed to work.

Solution

A temporary fix is to sort the items by order immediately after they are read from the database.
In tiki/lib/wiki-plugins/wikiplugin_ganttchart.php line 211 add:

Copy to clipboard
$orderKey = array_search($order, array_column($listfields, 'permName')); function array_sort($arrayToSort, $orderKey) { $new_array = array(); $sortable_array = array(); if (count($arrayToSort) > 0) { foreach ($arrayToSort as $k => $v) { $sortable_array[$k] = $v['field_values'][$orderKey]['value']; } } asort($sortable_array); foreach ($sortable_array as $k => $v) { $new_array[$k] = $arrayToSort[$k]; } return $new_array; } $listItems['data'] = array_sort($listItems['data'], $orderKey);
Importance
8
Easy to solve?
8
Priority
64
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
7198
Created
Wednesday 23 October, 2019 03:38:44 UTC
by amorangi
LastModif
Thursday 24 October, 2019 04:25:28 UTC


Show PHP error messages