From 3bd75b822cb82370fd787d9032fa1ac957d73466 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Fri, 23 Jun 2017 13:02:26 +0200 Subject: [PATCH] Add subgroup UI changes see BT#12861 --- main/cron/import_csv.php | 3 + main/inc/lib/career.lib.php | 145 +++++++++++++++++++++++------------- 2 files changed, 96 insertions(+), 52 deletions(-) diff --git a/main/cron/import_csv.php b/main/cron/import_csv.php index 927e3d4d5a9..36431cadb51 100755 --- a/main/cron/import_csv.php +++ b/main/cron/import_csv.php @@ -2407,6 +2407,8 @@ private function importCareersDiagram( $groupValue = $row['Group']; $rowValue = $row['Row']; $arrow = $row['DrawArrowFrom']; + $subGroup = $row['SubGroup']; + if ($graph->hasVertex($currentCourseId)) { // Avoid double insertion continue; @@ -2418,6 +2420,7 @@ private function importCareersDiagram( $current->setAttribute('Row', $rowValue); $current->setAttribute('Group', $groupValue); $current->setAttribute('DrawArrowFrom', $arrow); + $current->setAttribute('SubGroup', $subGroup); //$current->setAttribute('graphviz.color', 'blue'); $current->setAttribute('graphviz.shape', 'box'); diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index b2bea94f657..08e3442ae71 100755 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -469,8 +469,10 @@ public static function parseColumns($list, $group, $columnList, $maxColumn, $wid $showGroupLine = false; } } + $borderLine = $showGroupLine ? 'border-style:solid;' : ''; $graphHtml = '
'; + foreach ($columnList as $column => $rows) { $leftColumn = ($defaultSpace).'px'; if ($column == 1) { @@ -490,54 +492,93 @@ public static function parseColumns($list, $group, $columnList, $maxColumn, $wid } $newRowList = []; + $defaultSubGroup = -1; + $subGroupCountList = []; for ($i = 0; $i < $maxRow; $i++) { - $newRowList[$i+1] = isset($rows[$i+1]) ? $rows[$i+1] : null; + /** @var Vertex $vertex */ + $vertex = isset($rows[$i+1]) ? $rows[$i+1] : null; + if (!is_null($vertex)) { + $subGroup = $vertex->getAttribute('SubGroup'); + if ($subGroup == '' || empty($subGroup)) { + $defaultSubGroup = 0; + } else { + $defaultSubGroup = (int) $subGroup; + } + } + $newRowList[$i+1][$defaultSubGroup][] = $vertex; + if (!isset($subGroupCountList[$defaultSubGroup])) { + $subGroupCountList[$defaultSubGroup] = 1; + } else { + $subGroupCountList[$defaultSubGroup]++; + } } + //$graphHtml .= '
'; + $subGroup = null; + $subGroupAdded = []; /** @var Vertex $vertex */ - foreach ($newRowList as $row => $vertex) { - if (is_null($vertex)) { - $graphHtml .= '
'; - $graphHtml .= '
'; - continue; - } - $id = $vertex->getId(); - $rowId = "row_$row"; - $top = $topValue*($row-1); - $graphHtml .= '
'; - $color = ''; - if ($vertex->getAttribute('HasColor') == 1) { - $color = 'danger'; - } - $content = $vertex->getAttribute('Notes'); - $content .= '
['.$id.']
'; - - $graphHtml .= Display::panel( - $content, - $vertex->getAttribute('graphviz.label'), - null, - $color, - null - ); - $graphHtml .= '
'; - - $arrow = $vertex->getAttribute('DrawArrowFrom'); - - if (!empty($arrow)) { - $parts = explode('G', $arrow); - if (empty($parts[0]) && count($parts) == 2) { - $groupArrow = $parts[1]; - $graphHtml .= self::createConnection( - "group_$groupArrow", - "row_$id", - ['Left', 'Right'] - ); - } else { - $graphHtml .= self::createConnection( - "row_$arrow", - "row_$id", - ['Left', 'Right'] + foreach ($newRowList as $row => $subGroupList) { + foreach ($subGroupList as $subGroup => $vertexList) { + if (!empty($subGroup) && $subGroup != -1) { + if (!isset($subGroupAdded[$subGroup])) { + $subGroupAdded[$subGroup] = 1; + } else { + $subGroupAdded[$subGroup]++; + } + if ($subGroupAdded[$subGroup] == 1) { + $graphHtml .= '
'; + } + } + + foreach ($vertexList as $vertex) { + if (is_null($vertex)) { + $graphHtml .= '
'; + $graphHtml .= '
'; + continue; + } + + $id = $vertex->getId(); + $rowId = "row_$row"; + $top = $topValue * ($row - 1); + $graphHtml .= '
'; + $color = ''; + if ($vertex->getAttribute('HasColor') == 1) { + $color = 'danger'; + } + $content = $vertex->getAttribute('Notes'); + $content .= '
['.$id.']
'; + + $graphHtml .= Display::panel( + $content, + $vertex->getAttribute('graphviz.label'), + null, + $color, + null ); + $graphHtml .= '
'; + + $arrow = $vertex->getAttribute('DrawArrowFrom'); + if (!empty($arrow)) { + $parts = explode('G', $arrow); + if (empty($parts[0]) && count($parts) == 2) { + $groupArrow = $parts[1]; + $graphHtml .= self::createConnection( + "group_$groupArrow", + "row_$id", + ['Left', 'Right'] + ); + } else { + $graphHtml .= self::createConnection( + "row_$arrow", + "row_$id", + ['Left', 'Right'] + ); + } + } + } + + if (!empty($subGroup) && $subGroup != -1 && $subGroupCountList[$subGroup] == $subGroupAdded[$subGroup]) { + $graphHtml .= '
'; } } } @@ -583,15 +624,15 @@ public static function createConnection($source, $target, $anchor = []) $anchor = implode('","', $anchor); $html = ''.PHP_EOL; return $html;