diff --git a/module/execution/control.php b/module/execution/control.php index 3cb03c47ec..d2f065afdc 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1840,12 +1840,13 @@ class execution extends control /* Compatibility IE8. */ if(strpos($this->server->http_user_agent, 'MSIE 8.0') !== false) header("X-UA-Compatible: IE=EmulateIE7"); - $kanban = $this->loadModel('kanban')->getExecutionKanban($executionID); - if(empty($kanban)) + $kanbanGroup = $this->loadModel('kanban')->getExecutionKanban($executionID); + if(empty($kanbanGroup)) { $this->kanban->createLanes($executionID); - $kanban = $this->kanban->getExecutionKanban($executionID); + $kanbanGroup = $this->kanban->getExecutionKanban($executionID); } + a($kanbanGroup);die; $this->execution->setMenu($executionID); $execution = $this->loadModel('execution')->getById($executionID); @@ -1861,6 +1862,7 @@ class execution extends control $this->view->orderBy = 'id_asc'; $this->view->executionID = $executionID; $this->view->browseType = ''; + $this->view->kanbanGroup = $kanbanGroup; $this->view->execution = $execution; $this->view->type = $type; $this->view->canBeChanged = $canBeChanged; diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index d78efa7ffa..fae86bc121 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -6,6 +6,7 @@ */ function getStoryKanbanDemoData() { + return kanbanGroup.story; /* Define kanban columns 定义看板列 */ var columns = [ @@ -134,6 +135,7 @@ function getStoryKanbanDemoData() */ function getBugKanbanDemoData() { + return kanbanGroup.bug; /* Define kanban columns 定义看板列 */ var columns = [ @@ -252,6 +254,7 @@ function getBugKanbanDemoData() */ function getTaskKanbanDemoData() { + return kanbanGroup.task; /* Define kanban columns 定义看板列 */ var columns = [ diff --git a/module/execution/view/kanban.html.php b/module/execution/view/kanban.html.php index 8bf05ba391..8f591678f8 100644 --- a/module/execution/view/kanban.html.php +++ b/module/execution/view/kanban.html.php @@ -65,5 +65,5 @@ - + diff --git a/module/kanban/model.php b/module/kanban/model.php index ed594ba43d..98e67ca832 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -38,32 +38,66 @@ class kanbanModel extends model if($objectType == 'story' or $objectType == 'all') $stories = $this->loadModel('story')->getExecutionStories($executionID); if($objectType == 'bug' or $objectType == 'all') $bugs = $this->loadModel('bug')->getExecutionBugs($executionID); if($objectType == 'task' or $objectType == 'all') $tasks = $this->loadModel('execution')->getKanbanTasks($executionID, "id"); - foreach($columns as $laneID => $cols) - { - $laneType = $lanes[$laneID]->type; - foreach($cols as $colID => $col) - { - $cardIdList = array_filter(explode(',', $col->cards)); - $col->cards = array(); - foreach($cardIdList as $objectID) - { - if($laneType == 'story') $col->cards[$objectID] = zget($stories, $objectID, ''); - if($laneType == 'bug') $col->cards[$objectID] = zget($bugs, $objectID, ''); - if($laneType == 'task') $col->cards[$objectID] = zget($tasks, $objectID, ''); - } - if($col->parent > 0) - { - $cols[$col->parent]->childs[$colID] = $col; - unset($cols[$colID]); - } - } - } + /* Init vars. */ $kanban = array(); foreach($lanes as $laneID => $lane) { - $lane->columns = $columns[$laneID]; - $kanban[$lane->type] = $lane; + $laneData = array(); + $columnData = array(); + $cards = array(); + + $laneData['id'] = $lane->type; + $laneData['name'] = $lane->name; + $laneData['color'] = $lane->color; + $laneData['defaultItemType'] = $lane->type; + $laneData['order'] = $lane->order; + + foreach($columns[$laneID] as $colID => $col) + { + if($col->parent > 0) continue; + + $columnData[$col->id]['id'] = $lane->type . '-' . $col->type; + $columnData[$col->id]['type'] = $col->type; + $columnData[$col->id]['name'] = $col->name; + $columnData[$col->id]['color'] = $col->color; + $columnData[$col->id]['limit'] = $col->limit; + $columnData[$col->id]['asParent'] = $col->parent == -1 ? true : false; + + unset($columns[$laneID][$colID]); + } + + foreach($columns[$laneID] as $colID => $col) + { + $columnData[$col->parent]['subs']['id'] = $lane->type . '-' . $col->type; + $columnData[$col->parent]['subs']['type'] = $col->type; + $columnData[$col->parent]['subs']['name'] = $col->name; + $columnData[$col->parent]['subs']['color'] = $col->color; + $columnData[$col->parent]['subs']['limit'] = $col->limit; + $columnData[$col->parent]['subs']['parentType'] = $columnData[$col->parent]['type']; + + $cardIdList = array_filter(explode(',', $col->cards)); + $cardOrder = 1; + foreach($cardIdList as $cardID) + { + if($lane->type == 'story') $object = zget($stories, $cardID, array()); + if($lane->type == 'task') $object = zget($tasks, $cardID, array()); + if($lane->type == 'bug') $object = zget($bugs, $cardID, array()); + + $laneData['cards'][$col->type][$object->id]['id'] = $object->id; + $laneData['cards'][$col->type][$object->id]['order'] = $cardOrder; + $laneData['cards'][$col->type][$object->id]['pri'] = $object->pri; + $laneData['cards'][$col->type][$object->id]['estimate'] = $lane->type == 'bug' ? '' : $object->estimate; + $laneData['cards'][$col->type][$object->id]['assignedTo'] = $object->assignedTo; + $laneData['cards'][$col->type][$object->id]['deadline'] = $lane->type == 'task' ? $object->deadline : ''; + + $cardOrder ++; + } + } + + $kanban[$lane->type]['id'] = $lane->type; + $kanban[$lane->type]['columns'] = $columnData; + $kanban[$lane->type]['lanes'] = $laneData; } return $kanban;