From e6e6bb3c302f1cbec989d375acafafb3072aae1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E9=87=91=E5=8B=87?= Date: Wed, 21 Jun 2023 07:39:49 +0000 Subject: [PATCH] * Fix browseTask of tree. --- lib/zin/wg/tree/v1.php | 2 +- module/tree/control.php | 11 +++++++---- module/tree/model.php | 12 ++++++------ module/tree/ui/browsetask.html.php | 29 +++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/lib/zin/wg/tree/v1.php b/lib/zin/wg/tree/v1.php index 21fc9d9f8f..c6388af1fa 100644 --- a/lib/zin/wg/tree/v1.php +++ b/lib/zin/wg/tree/v1.php @@ -20,7 +20,7 @@ class tree extends wg foreach($items as $key => $item) { $item = (array)$item; - $treeItem = array('text' => $item['text'], 'url' => $item['url']); + $treeItem = array('text' => $item['name'], 'url' => $item['url']); if(isset($item['items'])) $treeItem['items'] = $this->buildTree($item['items']); $items[$key] = $treeItem; diff --git a/module/tree/control.php b/module/tree/control.php index fafa954e8c..bba84f8037 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -25,7 +25,7 @@ class tree extends control * @access public * @return void */ - public function browse($rootID, $viewType, $currentModuleID = 0, $branch = 0, $from = '') + public function browse(int $rootID, string $viewType, int $currentModuleID = 0, int $branch = 0, string $from = '') { $this->loadModel('product'); @@ -110,10 +110,12 @@ class tree extends control { /* Set menu.*/ $products = $this->product->getPairs($mode = '', $programID = 0, $append = '', 'all'); - $this->product->saveState($rootID, $products); + + $rootID = $this->product->getAccessableProductID($rootID, $products); + $this->session->set('product', $rootID, $this->app->tab); unset($products[$rootID]); - $currentProduct = key($products); + $currentProduct = (int)key($products); $this->lang->modulePageNav = ''; $this->view->allProduct = $products; @@ -180,7 +182,8 @@ class tree extends control unset($this->lang->product->menu->set['subModule']); $products = $this->product->getPairs(); - $this->product->saveState($productID, $products); + $productID = $this->product->getAccessableProductID($productID, $products); + $this->session->set('product', $productID, $this->app->tab); } elseif($from == 'project') { diff --git a/module/tree/model.php b/module/tree/model.php index ad0df0afcb..370dbada87 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -85,7 +85,7 @@ class treeModel extends model if(($type == 'feedback' or $type == 'ticket') and strpos($param, 'noproduct') === false and isset($syncConfig[$rootID])) $type = 'story,' . $type; if($this->isMergeModule($rootID, $type)) { - return $this->dao->select('*, name AS text')->from(TABLE_MODULE) + return $this->dao->select('*')->from(TABLE_MODULE) ->where('root')->eq((int)$rootID) ->beginIF($type == 'task')->andWhere('type')->eq('task')->fi() ->beginIF($type != 'task')->andWhere('type')->in("story,$type")->fi() @@ -602,7 +602,7 @@ class treeModel extends model if(empty($branchGroups[$id])) $branchGroups[$id]['0'] = ''; foreach($branchGroups[$id] as $branch => $branchName) { - $query = $this->dao->select('*, name AS text')->from(TABLE_MODULE)->where("((root = '" . (int)$rootID . "' and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") + $query = $this->dao->select('*')->from(TABLE_MODULE)->where("((root = '" . (int)$rootID . "' and type = 'task' and parent != 0) OR (root = $id and type = 'story' and branch ='$branch'))") ->andWhere('deleted')->eq(0) ->orderBy('grade desc, `order`, type') ->get(); @@ -611,15 +611,15 @@ class treeModel extends model if($branch != 0) { $children = $this->getDataStructure($stmt, 'task', $rootID, $executionModules); - if($children) $branchTrees[] = array('text' => $branchName, 'root' => $id, 'type' => 'branch', 'actions' => false, 'items' => $children); + if($children) $branchTrees[] = array('name' => $branchName, 'root' => $id, 'type' => 'branch', 'actions' => false, 'items' => $children); } } - if($branchTrees) $productTree[] = array('text' => $this->lang->product->branchName[$productInfo->type], 'root' => $id, 'type' => 'branch', 'actions' => false, 'items' => $branchTrees); - $fullTrees[] = array('text' => $productInfo->name, 'root' => $id, 'type' => 'product', 'actions' => false, 'items' => $productTree); + if($branchTrees) $productTree[] = array('name' => $this->lang->product->branchName[$productInfo->type], 'root' => $id, 'type' => 'branch', 'actions' => false, 'items' => $branchTrees); + $fullTrees[] = array('name' => $productInfo->name, 'root' => $id, 'type' => 'product', 'actions' => false, 'items' => $productTree); } /* Get execution module. */ - $query = $this->dao->select('*, name AS text')->from(TABLE_MODULE) + $query = $this->dao->select('*')->from(TABLE_MODULE) ->where('root')->eq((int)$rootID) ->andWhere('type')->eq('task') ->andWhere('deleted')->eq(0) diff --git a/module/tree/ui/browsetask.html.php b/module/tree/ui/browsetask.html.php index 612d847d7b..cc1b066949 100644 --- a/module/tree/ui/browsetask.html.php +++ b/module/tree/ui/browsetask.html.php @@ -18,6 +18,28 @@ foreach($sons as $son) { if($son->order > $maxOrder) $maxOrder = $son->order; + if($newModule and !$productID) + { + foreach($products as $product) + { + $moduleRows[] = formRow + ( + formGroup + ( + setClass('row-module'), + input + ( + setClass('col-module'), + set::name("products[id$product->id]"), + set::type('input'), + set::value($product->name), + set::disabled(true), + ), + ) + ); + } + } + $moduleRows[] = formRow ( formGroup @@ -78,6 +100,13 @@ for($i = 0; $i < \tree::NEW_CHILD_COUNT; $i ++) set::value(''), set::placeholder($lang->tree->short), ), + input + ( + setClass('hidden'), + set::name("branch[$i]"), + set::value(0), + set::control('hidden'), + ), ), batchActions(), ),