From ed5cbcc2fd3f9488b184b9da070480f10a2d03d5 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Fri, 9 Jun 2023 13:27:52 +0800 Subject: [PATCH 1/4] * Optimize build product drop-down logic. --- module/execution/control.php | 8 ++++---- module/execution/zen.php | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 19303a9938..057244eb74 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -979,10 +979,10 @@ class execution extends control /* Set the product drop-down and search fields. */ $productOption = array(); $branchOption = array(); - $showBranch = false; + $showBranch = $this->loadModel('branch')->showBranch($productID); if($execution->hasProduct) { - list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products); + list($productOption, $branchOption) = $this->executionZen->buildProductSwitcher($productID, $products); unset($this->config->bug->search['fields']['product']); unset($this->config->bug->search['params']['product']); if($project->model != 'scrum') @@ -1119,10 +1119,10 @@ class execution extends control $execution = $this->execution->getByID($executionID); $productOption = array(); $branchOption = array(); - $showBranch = false; + $showBranch = $this->loadModel('branch')->showBranch($productID); if($execution->hasProduct) { - list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products); + list($productOption, $branchOption) = $this->executionZen->buildProductSwitcher($productID, $products); } /* Load pager. */ diff --git a/module/execution/zen.php b/module/execution/zen.php index 66c0ed1a59..a5ca3cd973 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -63,8 +63,8 @@ class executionZen extends execution */ protected function buildProductSwitcher(int $productID, array $products) { - $showBranch = false; $productOption = array(); + $branchOption = array(); $programIdList = array(); if(count($products) > 1) $productOption[0] = $this->lang->product->all; foreach($products as $productData) $programIdList[$productData->program] = $productData->program; @@ -81,9 +81,6 @@ class executionZen extends execution $product = $this->product->getById((int)$productID); if($product and $product->type != 'normal') { - /* Display of branch label. */ - $showBranch = $this->loadModel('branch')->showBranch($productID); - /* Display status of branch. */ $branches = $this->branch->getList($productID, $executionID, 'all'); foreach($branches as $branchInfo) @@ -91,6 +88,6 @@ class executionZen extends execution $branchOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : ''); } } - return array($productOption, $branchOption, $showBranch); + return array($productOption, $branchOption); } } From 88030878800dc3080ee1a6a9076bb24fc364c5e2 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Fri, 9 Jun 2023 13:31:05 +0800 Subject: [PATCH 2/4] * Bind computeEndDate to date select of productplan-create. --- module/productplan/js/create.ui.js | 28 +++++++++++++++++++++++++++ module/productplan/ui/create.html.php | 1 + 2 files changed, 29 insertions(+) diff --git a/module/productplan/js/create.ui.js b/module/productplan/js/create.ui.js index 15d47b9679..62e2a67820 100644 --- a/module/productplan/js/create.ui.js +++ b/module/productplan/js/create.ui.js @@ -2,3 +2,31 @@ function resetDelta() { $(".radio-primary > input").attr("checked",false); } + +function computeEndDate() +{ + var beginDate = $('#begin').val(); + if(!beginDate) return; + console.log(beginDate); + + var delta = parseInt(delta); + beginDate = convertStringToDate(beginDate); + if((delta == 7 || delta == 14) && (beginDate.getDay() == 1)) + { + delta = (weekend == 2) ? (delta - 2) : (delta - 1); + } + + var currentBeginDate = window.zui.formatDate(beginDate, 'yyyy-MM-dd'); + var endDate = window.zui.formatDate(beginDate.addDays(delta - 1), 'yyyy-MM-dd'); + + $('#begin').val(currentBeginDate); + $('#end').val(endDate).datetimepicker('update'); +} + +function convertStringToDate(dateString) +{ + dateString = dateString.split('-'); + dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0]; + + return new Date(dateString); +} diff --git a/module/productplan/ui/create.html.php b/module/productplan/ui/create.html.php index 9100ec4b26..54afe275be 100644 --- a/module/productplan/ui/create.html.php +++ b/module/productplan/ui/create.html.php @@ -64,6 +64,7 @@ formPanel set::title($title), on::change('#begin', 'resetDelta'), on::change('#end', 'resetDelta'), + on::change('.radio-primary > input', 'computeEndDate'), $formHeader, $parentForm, formGroup From 672cfbf6f4ad7fda7bac1e21d184d6baee8e724c Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Fri, 9 Jun 2023 13:38:15 +0800 Subject: [PATCH 3/4] + Add url template string replacement. --- lib/zin/wg/floattoolbar/v1.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/zin/wg/floattoolbar/v1.php b/lib/zin/wg/floattoolbar/v1.php index 90eeb094af..f600606828 100644 --- a/lib/zin/wg/floattoolbar/v1.php +++ b/lib/zin/wg/floattoolbar/v1.php @@ -6,13 +6,15 @@ class floatToolbar extends wg protected static $defineProps = array( 'prefix?:array', 'main?:array', - 'suffix?:array' + 'suffix?:array', + 'object?:object' ); protected static $defineBlocks = array( 'prefix' => array(), 'main' => array(), - 'suffix' => array() + 'suffix' => array(), + 'object' => null ); public static function getPageCSS(): string|false @@ -20,7 +22,7 @@ class floatToolbar extends wg return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css'); } - private function buildDivider(wg|array|null $wg): wg|null + private function buildDivider(wg|array|null|bool $wg): wg|null { if(empty($wg)) return null; @@ -31,8 +33,26 @@ class floatToolbar extends wg { if(empty($items)) return null; + $object = $this->prop('object'); + if($object) + { + /* Set url template string replacement rules. */ + $urlReplaceName = array(); + $urlReplaceValue = array(); + foreach($object as $key => $value) + { + $urlReplaceName[] = "{{$key}}"; + $urlReplaceValue[] = $value; + } + } + $btns = array(); - foreach ($items as $item) $btns[] = btn(set($item), setClass('ghost text-white')); + foreach ($items as $item) + { + if($object && isset($item['url'])) $item['url'] = str_replace($urlReplaceName, $urlReplaceValue, $item['url']); + + $btns[] = btn(set($item), setClass('ghost text-white')); + } return $btns; } @@ -66,7 +86,7 @@ class floatToolbar extends wg $prefixBtns, $this->buildDivider($prefixBtns), $mainBtns, - $this->buildDivider($suffixBtns), + $this->buildDivider($mainBtns && $suffixBtns), $suffixBtns, ); } From c89d9eb2888c29651ad652ddd0708b96605d587b Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Fri, 9 Jun 2023 13:38:50 +0800 Subject: [PATCH 4/4] * Change operate menu init. --- module/task/ui/view.html.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/module/task/ui/view.html.php b/module/task/ui/view.html.php index e86ff0ad04..eb0b2fdc50 100644 --- a/module/task/ui/view.html.php +++ b/module/task/ui/view.html.php @@ -17,28 +17,15 @@ detailHeader common::hasPriv('task', 'create') ? to::suffix(btn(set::icon('plus'), set::url(createLink('task', 'create', "executionID={$task->execution}")), set::type('primary'), $lang->task->create)) : null ); -/* Build replace url param, replace {id} to $task->id. */ -$urlReplaceName = array(); -$urlReplaceValue = array(); -foreach($task as $key => $value) -{ - $urlReplaceName[] = "{{$key}}"; - $urlReplaceValue[] = $value; -} - /* Construct suitable actions for the current task. */ $operateMenus = array(); foreach($config->task->view->operateList['main'] as $operate) { if(!common::hasPriv('task', $operate)) continue; if(!$this->task->isClickable($task, $operate)) continue; - if($operate == 'batchCreate' && (!empty($task->team) || !empty($task->children))) continue; - $settings = $config->task->actionList[$operate]; - $settings['url'] = str_replace($urlReplaceName, $urlReplaceValue, $settings['url']); - - $operateMenus[] = $settings; + $operateMenus[] = $config->task->actionList[$operate]; } /* Construct common actions for task. */ @@ -49,7 +36,6 @@ foreach($config->task->view->operateList['common'] as $operate) if($operate == 'view' && $task->parent <= 0) continue; $settings = $config->task->actionList[$operate]; - $settings['url'] = str_replace($urlReplaceName, $urlReplaceValue, $settings['url']); $settings['text'] = ''; $commonActions[] = $settings; @@ -95,7 +81,8 @@ detailBody array(array('icon' => 'back', 'text' => $lang->goback)) ), set::main($operateMenus), - set::suffix($commonActions) + set::suffix($commonActions), + set::object($task) ), detailSide (