From 26b8c19f335a23c101e633e6ddeb421e5fbc077c Mon Sep 17 00:00:00 2001 From: sunguangming Date: Thu, 9 Nov 2023 11:28:04 +0800 Subject: [PATCH] * Get RD kanban data. --- module/execution/control.php | 4 +- module/execution/ui/kanban.html.php | 52 +++++++++++++ module/index/config.php | 5 -- module/kanban/model.php | 117 ++++++++++++++-------------- module/kanban/ui/view.html.php | 1 - 5 files changed, 112 insertions(+), 67 deletions(-) create mode 100644 module/execution/ui/kanban.html.php diff --git a/module/execution/control.php b/module/execution/control.php index 59fa4bc8b4..feb3caff92 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1593,7 +1593,6 @@ class execution extends control $this->session->set('rdSearchValue', ''); /* Get kanban data and set actions. */ - $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, $browseType, $orderBy, 0, $groupBy); $executionActions = array(); foreach($this->config->execution->statusActions as $action) { @@ -1612,16 +1611,15 @@ class execution extends control $this->executionZen->assignKanbanVars($executionID); $this->view->title = $this->lang->kanban->view; - $this->view->regions = $kanbanData; $this->view->execution = $execution; $this->view->executionID = $executionID; + $this->view->kanbanList = $this->loadModel('kanban')->getRDKanban($executionID, $browseType, $orderBy, 0, $groupBy); $this->view->browseType = $browseType; $this->view->orderBy = $orderBy; $this->view->groupBy = $groupBy; $this->view->projectID = $execution->project; $this->view->project = $this->loadModel('project')->getByID($execution->project); $this->view->features = $features; - $this->view->kanbanData = $kanbanData; $this->view->executionActions = $executionActions; $this->view->kanban = $this->lang->execution->kanban; $this->view->taskToOpen = $taskToOpen; diff --git a/module/execution/ui/kanban.html.php b/module/execution/ui/kanban.html.php new file mode 100644 index 0000000000..fa73c5bef8 --- /dev/null +++ b/module/execution/ui/kanban.html.php @@ -0,0 +1,52 @@ + + * @package kanban + * @link https://www.zentao.net + */ +namespace zin; + +$laneCount = 0; +$groupCols = array(); // 卡片可以移动到的同一group下的列。 +foreach($kanbanList as $current => $region) +{ + foreach($region['items'] as $index => $group) + { + $groupID = $group['id']; + + $group['getLane'] = jsRaw('window.getLane'); + $group['getCol'] = jsRaw('window.getCol'); + $group['getItem'] = jsRaw('window.getItem'); + $group['canDrop'] = jsRaw('window.canDrop'); + $group['onDrop'] = jsRaw('window.onDrop'); + $group['minColWidth'] = $execution->fluidBoard == '0' ? $execution->colWidth : $execution->minColWidth; + $group['maxColWidth'] = $execution->fluidBoard == '0' ? $execution->colWidth : $execution->maxColWidth; + $group['colProps'] = array('actions' => jsRaw('window.getColActions')); + $group['laneProps'] = array('actions' => jsRaw('window.getLaneActions')); + $group['itemProps'] = array('actions' => jsRaw('window.getItemActions')); + + foreach($group['data']['cols'] as $colIndex => $col) + { + if($col['parent'] != '-1') $groupCols[$groupID][$col['id']] = $col['title']; + } + + $kanbanList[$current]['items'][$index] = $group; + } + + $laneCount += $region['laneCount']; +} + +div +( + set::id('kanbanList'), + zui::kanbanList + ( + set::key('kanban'), + set::items($kanbanList), + set::height('calc(100vh - 120px)') + ) +); diff --git a/module/index/config.php b/module/index/config.php index e6099faa20..ea595eb5d5 100644 --- a/module/index/config.php +++ b/module/index/config.php @@ -23,10 +23,5 @@ $config->index->appGroup['effort'] = 'my'; $config->index->appGroup['user'] = 'admin'; $config->index->oldPages = array(); -$config->index->oldPages[] = 'product-kanban'; -$config->index->oldPages[] = 'program-kanban'; -$config->index->oldPages[] = 'project-kanban'; -$config->index->oldPages[] = 'execution-kanban'; -$config->index->oldPages[] = 'execution-taskkanban'; $config->index->oldPages[] = 'host-treemap'; $config->index->oldPages[] = 'screen-view'; diff --git a/module/kanban/model.php b/module/kanban/model.php index ac5f871ef9..595508c507 100755 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -989,8 +989,7 @@ class kanbanModel extends model { if($groupBy != 'default' and $groupBy != '') return $this->getKanban4Group($executionID, $browseType, $groupBy, $searchValue, $orderBy); - $kanbanData = array(); - $actions = array('sortGroup'); + $kanbanList = array(); $regions = $this->getRegionPairs($executionID, $regionID, 'execution'); $regionIDList = $regionID == 0 ? array_keys($regions) : array(0 => $regionID); $groupGroup = $this->getGroupGroupByRegions($regionIDList); @@ -1001,10 +1000,18 @@ class kanbanModel extends model foreach($regions as $regionID => $regionName) { - $region = new stdclass(); - $region->id = $regionID; - $region->name = $regionName; - $region->laneCount = 0; + $laneCount = 0; + $regionData = array(); + $groupData = array(); + + $heading = new stdclass(); + $heading->title = $regionName; + //$heading->actions = $this->getRegionActions($kanbanID, $regionID); + + $regionData['key'] = "region{$regionID}"; + $regionData['id'] = $regionID; + $regionData['heading'] = $heading; + $regionData['toggleFromHeading'] = true; $groups = zget($groupGroup, $regionID, array()); foreach($groups as $group) @@ -1012,35 +1019,40 @@ class kanbanModel extends model $lanes = zget($laneGroup, $group->id, array()); if(!$lanes) continue; + $cols = zget($columnGroup, $group->id, array()); + $items = zget($cardGroup, $group->id, array()); + foreach($lanes as $key => $lane) { + $lane['execution'] = $executionID; if(in_array($execution->attribute, array('request', 'design', 'review')) and $lane->type == 'bug') continue 2; if(in_array($execution->attribute, array('request', 'review')) and $lane->type == 'story') continue 2; $this->refreshCards($lane); - $lane->items = isset($cardGroup[$lane->id]) ? $cardGroup[$lane->id] : array(); - $lane->defaultCardType = $lane->type; + $lane['defaultCardType'] = $lane['type']; if($searchValue != '' and count($lane->items) == 0) unset($lanes[$key]); } + $lanes = array_values($lanes); + $laneCount += count($lanes); if($searchValue != '' and empty($lanes)) continue; - $group->columns = zget($columnGroup, $group->id, array()); - $group->lanes = $lanes; - $group->actions = array(); - foreach($actions as $action) - { - if(commonModel::hasPriv('kanban', $action)) $group->actions[] = $action; - } + $laneCount += count($lanes); - $region->groups[] = $group; - $region->laneCount += count($lanes); + $groupData['id'] = $group->id; + $groupData['key'] = "group{$group->id}"; + $groupData['data']['lanes'] = $lanes; + $groupData['data']['cols'] = $cols; + $groupData['data']['items'] = $items; + + $regionData['items'][] = $groupData; } - $kanbanData[$regionID] = $region; + $regionData['laneCount'] = $laneCount; + $kanbanList[] = $regionData; } - return $kanbanData; + return $kanbanList; } /** @@ -1432,43 +1444,31 @@ class kanbanModel extends model $actions = array('setColumn', 'setWIP', 'deleteColumn'); /* Group by parent. */ - $parentColumnGroup = array(); + $columnData = array(); foreach($columnGroup as $group => $columns) { foreach($columns as $column) { - $column->actions = array(); + $item = array(); + $item['title'] = htmlspecialchars_decode($column->name); + $item['name'] = $column->id; + $item['id'] = $column->id; + $item['type'] = $column->type; + $item['color'] = $column->color; + $item['limit'] = $column->limit; + $item['region'] = $column->region; + $item['group'] = $column->group; + $item['parent'] = $column->parent; + $item['color'] = $column->color; + if($column->parent > 0) $item['parentName'] = $column->parent; + /* Judge column action priv. */ foreach($actions as $action) { - if($this->isClickable($column, $action)) $column->actions[] = $action; + if($this->isClickable($column, $action)) $item['actionList'][] = $action; } - if($column->parent > 0) continue; - - $parentColumnGroup[$group][] = $column; - } - } - - $columnData = array(); - foreach($parentColumnGroup as $group => $parentColumns) - { - foreach($parentColumns as $parentColumn) - { - $columnData[$group][] = $parentColumn; - foreach($columnGroup[$group] as $column) - { - if($column->parent == $parentColumn->id) - { - $parentColumn->asParent = true; - - if(strpos(',developing,developed,', $column->type) !== false) $column->parentType = 'develop'; - if(strpos(',testing,tested,', $column->type) !== false) $column->parentType = 'test'; - if(strpos(',fixing,fixed,', $column->type) !== false) $column->parentType = 'resolving'; - - $columnData[$group][] = $column; - } - } + $columnData[$group][] = $item; } } @@ -1488,7 +1488,7 @@ class kanbanModel extends model */ public function getCardGroupByExecution($executionID, $browseType = 'all', $orderBy = 'id_asc', $searchValue = '') { - $cards = $this->dao->select('t1.*, t2.type as columnType') + $cards = $this->dao->select('t1.*, t2.type as columnType, t2.group') ->from(TABLE_KANBANCELL)->alias('t1') ->leftJoin(TABLE_KANBANCOLUMN)->alias('t2')->on('t1.column=t2.id') ->where('t1.kanban')->eq($executionID) @@ -1518,6 +1518,7 @@ class kanbanModel extends model if(empty($object)) continue; $cardData['id'] = $object->id; + $cardData['name'] = $object->id; $cardData['order'] = $cardOrder++; $cardData['pri'] = $object->pri ? $object->pri : ''; $cardData['estimate'] = $cell->type == 'bug' ? '' : $object->estimate; @@ -1535,7 +1536,7 @@ class kanbanModel extends model if($cell->type == 'task') { if($searchValue != '' and strpos($object->name, $searchValue) === false) continue; - $cardData['name'] = $object->name; + $cardData['title'] = $object->name; $cardData['left'] = $object->left; $cardData['estStarted'] = $object->estStarted; $cardData['mode'] = $object->mode; @@ -1545,7 +1546,7 @@ class kanbanModel extends model if($searchValue != '' and strpos($object->title, $searchValue) === false) continue; $cardData['title'] = $object->title; } - $cardGroup[$laneID][$cell->columnType][] = $cardData; + $cardGroup[$cell->group][$laneID][$cell->column][] = $cardData; } } } @@ -2994,14 +2995,14 @@ class kanbanModel extends model */ public function refreshCards($lane) { - $laneType = $lane->type; - $executionID = $lane->execution; + $laneType = $lane['type']; + $executionID = $lane['execution']; $otherCardList = ''; $otherLanes = $this->dao->select('t2.id, t2.cards')->from(TABLE_KANBANLANE)->alias('t1') ->leftJoin(TABLE_KANBANCELL)->alias('t2')->on('t1.id=t2.lane') - ->where('t1.id')->ne($lane->id) + ->where('t1.id')->ne($lane['id']) ->andWhere('t1.execution')->eq($executionID) - ->andWhere('t2.`type`')->eq($lane->type) + ->andWhere('t2.`type`')->eq($lane['type']) ->fetchPairs(); foreach($otherLanes as $cardIDList) @@ -3013,7 +3014,7 @@ class kanbanModel extends model $cardPairs = $this->dao->select('t2.type, t1.cards')->from(TABLE_KANBANCELL)->alias('t1') ->leftJoin(TABLE_KANBANCOLUMN)->alias('t2')->on('t1.`column` = t2.id') ->where('t1.kanban')->eq($executionID) - ->andWhere('t1.lane')->eq($lane->id) + ->andWhere('t1.lane')->eq($lane['id']) ->fetchPairs(); if(empty($cardPairs)) return; @@ -3114,7 +3115,7 @@ class kanbanModel extends model $colPairs = $this->dao->select('t2.type, t2.id')->from(TABLE_KANBANCELL)->alias('t1') ->leftJoin(TABLE_KANBANCOLUMN)->alias('t2')->on('t1.`column` = t2.id') ->where('t1.kanban')->eq($executionID) - ->andWhere('t1.lane')->eq($lane->id) + ->andWhere('t1.lane')->eq($lane['id']) ->fetchPairs(); $updated = false; @@ -3123,11 +3124,11 @@ class kanbanModel extends model if(!isset($colPairs[$colType])) continue; if($sourceCards[$colType] == $cards) continue; - $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq($cards)->where('lane')->eq($lane->id)->andWhere('`column`')->eq($colPairs[$colType])->exec(); + $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq($cards)->where('lane')->eq($lane['id'])->andWhere('`column`')->eq($colPairs[$colType])->exec(); if(!$updated) $updated = true; } - if($updated) $this->dao->update(TABLE_KANBANLANE)->set('lastEditedTime')->eq(helper::now())->where('id')->eq($lane->id)->exec(); + if($updated) $this->dao->update(TABLE_KANBANLANE)->set('lastEditedTime')->eq(helper::now())->where('id')->eq($lane['id'])->exec(); } /** diff --git a/module/kanban/ui/view.html.php b/module/kanban/ui/view.html.php index f24a1fe726..59c358cb15 100644 --- a/module/kanban/ui/view.html.php +++ b/module/kanban/ui/view.html.php @@ -38,7 +38,6 @@ foreach($kanbanList as $current => $region) } $laneCount += $region['laneCount']; - } $regionMenu = array();