From 585b12838ee6999e4b479624a0c2a8429f080983 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 25 Oct 2022 14:03:13 +0800 Subject: [PATCH] * code for task #73472. --- module/product/config.php | 3 +- module/product/control.php | 12 +++++ module/product/css/kanban.css | 2 + module/product/js/kanban.js | 28 ++++++++++- module/product/model.php | 17 ++++++- module/product/view/kanban.html.php | 72 ++++++++++++++++------------- module/program/model.php | 4 +- 7 files changed, 98 insertions(+), 40 deletions(-) create mode 100644 module/product/css/kanban.css diff --git a/module/product/config.php b/module/product/config.php index 5f2be2d5cc..7e65607534 100644 --- a/module/product/config.php +++ b/module/product/config.php @@ -1,6 +1,7 @@ product = new stdclass(); -$config->product->orderBy = 'isClosed,program_asc,order_asc'; +$config->product->orderBy = 'isClosed,program_asc,order_asc'; +$config->product->showAllProjects = 0; $config->product->customBatchEditFields = 'line,PO,QD,RD,status,type,acl'; if($config->systemMode == 'new') $config->product->customBatchEditFields = 'program,' . $config->product->customBatchEditFields; diff --git a/module/product/control.php b/module/product/control.php index b13fcb690c..2e3997754e 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -1572,4 +1572,16 @@ class product extends control $this->view->projectProducts = isset($projectProducts) ? $projectProducts : array(); $this->display(); } + + /** + * Ajax set show setting. + * + * @access public + * @return void + */ + public function ajaxSetShowSetting() + { + $data = fixer::input('post')->get(); + $this->loadModel('setting')->updateItem("{$this->app->user->account}.product.showAllProjects", $data->showAllProjects); + } } diff --git a/module/product/css/kanban.css b/module/product/css/kanban.css new file mode 100644 index 0000000000..14266095ad --- /dev/null +++ b/module/product/css/kanban.css @@ -0,0 +1,2 @@ +#showSettingsBox {text-align:right; margin-top:-15px; margin-right:4px;} +#showSettingsBox .checkbox-primary {display:inline-block;} diff --git a/module/product/js/kanban.js b/module/product/js/kanban.js index 9f8ed6d341..73fe67015c 100644 --- a/module/product/js/kanban.js +++ b/module/product/js/kanban.js @@ -139,9 +139,14 @@ function calcColHeight(col, lane, colCards, colHeight) return colCards.length * 62; } -$(function() +/** + * Init kanban. + * + * @access public + * @return void + */ +function initKanban() { - /* Init all kanbans */ $.each(kanbanList, function(key, programsData) { var $kanban = $('#kanban-' + key); @@ -156,4 +161,23 @@ $(function() calcColHeight: calcColHeight }); }); +} + +$(function() +{ + /* Init all kanbans */ + initKanban(); + + $('#showAllProjects').click(function() + { + var showAllProjects = $(this).prop('checked') ? 1 : 0; + $.post(createLink('product', 'ajaxSetShowSetting'), {"showAllProjects": showAllProjects}, function() + { + $.get(createLink('product', 'kanban'), function(data) + { + $('#kanbanList').html($(data).find('#kanbanList').html()); + initKanban(); + }); + }) + }) }); diff --git a/module/product/model.php b/module/product/model.php index 3ecd794851..7a45c532ce 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -1895,7 +1895,7 @@ class productModel extends model $programList = $this->program->getTopPairs('', '', true); $projectList = $this->program->getProjectStats(0, 'doing'); - $projectProduct = $this->dao->select('t1.product,t1.project')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $projectProduct = $this->dao->select('t1.product,t1.project,t2.parent,t2.path')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id') ->where('t1.product')->in(array_keys($productList)) ->andWhere('t1.project')->in($this->app->user->view->projects) @@ -1904,6 +1904,19 @@ class productModel extends model ->andWhere('t2.deleted')->eq('0') ->fetchGroup('product', 'project'); + if(!$this->config->product->showAllProjects) + { + foreach($projectProduct as $productID => $projects) + { + if(!isset($productList[$productID])) continue; + $product = $productList[$productID]; + foreach($projects as $projectID => $project) + { + if($project->parent != $product->program and strpos($project->path, ",{$product->program},") !== 0) unset($projectProduct[$productID][$projectID]); + } + } + } + $planList = $this->dao->select('id,product,title,parent,begin,end')->from(TABLE_PRODUCTPLAN) ->where('product')->in(array_keys($productList)) ->andWhere('deleted')->eq(0) @@ -1912,7 +1925,7 @@ class productModel extends model ->orderBy('begin desc') ->fetchGroup('product', 'id'); - $executionList = $this->dao->select('t1.product as productID,t2.*')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $executionList = $this->dao->select('t1.product as productID,t2.*')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project=t2.id') ->where('type')->in('stage,sprint,kanban') ->andWhere('t2.project')->in(array_keys($projectList)) diff --git a/module/product/view/kanban.html.php b/module/product/view/kanban.html.php index 3d0b1c270b..b87e1ccb5a 100644 --- a/module/product/view/kanban.html.php +++ b/module/product/view/kanban.html.php @@ -11,12 +11,18 @@ ?> - -
-

product->noProduct;?>

+
+
+ product->showAllProjects ? 'checked' : '';?>> + +
-
+ +
+

product->noProduct;?>

+
+ $programs):?>
@@ -28,34 +34,34 @@
+ $lang->product->unclosedProduct, 'type' => 'unclosedProduct'); + $kanbanColumns['unexpiredPlan'] = array('name' => $lang->product->unexpiredPlan, 'type' => 'unexpiredPlan'); + $kanbanColumns['doingProject'] = array('name' => $lang->product->doingProject, 'type' => 'doingProject'); + $kanbanColumns['doingExecution'] = array('name' => $lang->product->doingExecution, 'type' => 'doingExecution'); + $kanbanColumns['normalRelease'] = array('name' => $lang->product->normalRelease, 'type' => 'normalRelease'); + $userPrivs = array(); + $userPrivs['product'] = common::hasPriv('product', 'browse'); + $userPrivs['productplan'] = common::hasPriv('productplan', 'view'); + $userPrivs['project'] = common::hasPriv('project', 'index'); + $userPrivs['execution'] = common::hasPriv('execution', 'task'); + $userPrivs['release'] = common::hasPriv('release', 'view'); + js::set('kanbanColumns', array_values($kanbanColumns)); + js::set('userPrivs', $userPrivs); + js::set('kanbanList', $kanbanList); + js::set('programList', $programList); + js::set('productList', $productList); + js::set('planList', $planList); + js::set('projectList', $projectList); + js::set('projectProduct', $projectProduct); + js::set('latestExecutions', $latestExecutions); + js::set('classicExecution', $executionList); + js::set('releaseList', $releaseList); + js::set('hourList', $hourList); + js::set('doingText', $lang->product->doing); + js::set('isLeanMode', $config->systemMode == 'lean'); + ?> +
- $lang->product->unclosedProduct, 'type' => 'unclosedProduct'); -$kanbanColumns['unexpiredPlan'] = array('name' => $lang->product->unexpiredPlan, 'type' => 'unexpiredPlan'); -$kanbanColumns['doingProject'] = array('name' => $lang->product->doingProject, 'type' => 'doingProject'); -$kanbanColumns['doingExecution'] = array('name' => $lang->product->doingExecution, 'type' => 'doingExecution'); -$kanbanColumns['normalRelease'] = array('name' => $lang->product->normalRelease, 'type' => 'normalRelease'); -$userPrivs = array(); -$userPrivs['product'] = common::hasPriv('product', 'browse'); -$userPrivs['productplan'] = common::hasPriv('productplan', 'view'); -$userPrivs['project'] = common::hasPriv('project', 'index'); -$userPrivs['execution'] = common::hasPriv('execution', 'task'); -$userPrivs['release'] = common::hasPriv('release', 'view'); -js::set('kanbanColumns', array_values($kanbanColumns)); -js::set('userPrivs', $userPrivs); -js::set('kanbanList', $kanbanList); -js::set('programList', $programList); -js::set('productList', $productList); -js::set('planList', $planList); -js::set('projectList', $projectList); -js::set('projectProduct', $projectProduct); -js::set('latestExecutions', $latestExecutions); -js::set('classicExecution', $executionList); -js::set('releaseList', $releaseList); -js::set('hourList', $hourList); -js::set('doingText', $lang->product->doing); -js::set('isLeanMode', $config->systemMode == 'lean'); -?> - diff --git a/module/program/model.php b/module/program/model.php index 3466a9095f..05a721e8cb 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -271,7 +271,7 @@ class programModel extends model ->fetchGroup('product'); /* Get all products linked projects. */ - $projectGroup = $this->dao->select('DISTINCT t1.product, t2.id, t2.name, t2.status, t2.end, t2.path')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $projectGroup = $this->dao->select('t1.product,t2.id,t2.name,t2.status,t2.end,t2.parent,t2.path')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->where('t2.deleted')->eq(0) ->andWhere('t1.product')->in($productPairs) @@ -335,7 +335,7 @@ class programModel extends model foreach($projects as $project) { if(helper::diffDate(helper::today(), $project->end) > 0) $project->delay = 1; - if(!$this->config->program->showAllProjects and strpos($project->path, ",{$product->program},") !== 0) continue; + if(!$this->config->program->showAllProjects and $project->parent != $product->program and strpos($project->path, ",{$product->program},") !== 0) continue; $status = $project->status == 'wait' ? 'wait' : 'doing'; $execution = zget($doingExecutions, $project->id, array());