From 0e9fd198eb79ea00d6df406d3d6adb054850f5f7 Mon Sep 17 00:00:00 2001 From: wangyuting Date: Fri, 29 Aug 2025 15:13:26 +0800 Subject: [PATCH] * [bug#62391,done,3h,0h] Optimize bug create autoload js. --- module/bug/control.php | 6 ++++-- module/bug/js/create.ui.js | 7 ------- module/bug/ui/create.html.php | 7 ++++--- www/js/zui3/zin.js | 14 +++++++++++--- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 4926c79779..25faf0b5ab 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -248,7 +248,8 @@ class bug extends control if(!empty($_POST)) { - $formData = form::data($this->config->bug->form->create); + if(!empty($params['productID'])) $product = $this->bug->fetchByID((int)$params['productID'], 'product'); + $formData = form::data($this->config->bug->form->create, 0, !empty($product->workflowGroup) ? $product->workflowGroup : 0); $bug = $this->bugZen->prepareCreateExtras($formData); $bugID = $this->bug->create($bug, $from); @@ -268,8 +269,9 @@ class bug extends control /* 初始化一个bug对象,尽可能把属性都绑定到bug对象上,extract() 出来的变量除外。 */ /* Init bug, give bug as many variables as possible, except for extract variables. */ - $fields = array('productID' => $productID, 'branch' => $branch, 'title' => ($from == 'sonarqube' ? $_COOKIE['sonarqubeIssue'] : ''), 'assignedTo' => (isset($product->QD) ? $product->QD : '')); + $fields = array('id' => 0, 'productID' => $productID, 'branch' => $branch, 'title' => ($from == 'sonarqube' ? $_COOKIE['sonarqubeIssue'] : ''), 'assignedTo' => (isset($product->QD) ? $product->QD : '')); $fields = array_merge($fields, $params); + $fields['product'] = $fields['productID']; $bug = $this->bugZen->initBug($fields); diff --git a/module/bug/js/create.ui.js b/module/bug/js/create.ui.js index eccd4d65ef..e69de29bb2 100644 --- a/module/bug/js/create.ui.js +++ b/module/bug/js/create.ui.js @@ -1,7 +0,0 @@ -window.reloadByProduct = function(e) -{ - let extra = 'bugID=' + copyBugID + ',projectID=' + projectID + ',executionID=' + executionID; - if(typeof fromID != 'undefined') extra += ',fromID=' + fromID; - if(typeof fromType != 'undefined') extra += ',fromType=' + fromType; - loadPage($.createLink('bug', 'create', 'productID=' + $(e.target).val() + '&branch=0&extra=' + extra)); -} diff --git a/module/bug/ui/create.html.php b/module/bug/ui/create.html.php index 15d6311d04..d6a0ffc716 100644 --- a/module/bug/ui/create.html.php +++ b/module/bug/ui/create.html.php @@ -16,7 +16,9 @@ include($this->app->getModuleRoot() . 'ai/ui/inputinject.html.php'); $fields = useFields('bug.create'); if(!empty($executionType) && $executionType == 'kanban') $fields->merge('bug.kanban'); -$fields->autoLoad('branch', 'module,execution,project,story,task,assignedTo') + +$fields->autoLoad('product', array('items' => 'product,module,execution,project,story,task,assignedTo,' . (!empty($lang->bug->flowExtraFields) ? implode(',', $lang->bug->flowExtraFields) : ''), 'updateOrders' => true)) + ->autoLoad('branch', 'module,execution,project,story,task,assignedTo') ->autoLoad('module', 'assignedTo,story') ->autoLoad('project', 'project,execution,story,task,assignedTo,injection,identify,openedBuild') ->autoLoad('execution', 'execution,story,task,assignedTo,openedBuild') @@ -40,8 +42,7 @@ jsVar('projectExecutionPairs', $projectExecutionPairs); formGridPanel ( - on::change('[name="product"]', 'reloadByProduct'), - on::change('[name="branch"], [name="project"], [name="execution"]', 'loadBuilds'), + on::change('[name="product"], [name="branch"], [name="project"], [name="execution"]', 'loadBuilds'), set::title($lang->bug->create), set::fields($fields), set::loadUrl($loadUrl) diff --git a/www/js/zui3/zin.js b/www/js/zui3/zin.js index 38d5bfb1f3..d6fa4f71cc 100644 --- a/www/js/zui3/zin.js +++ b/www/js/zui3/zin.js @@ -1303,9 +1303,17 @@ } else { - const $item = $data.filter(`[data-name="${name}"]`); - $oldItems.filter(`[data-name="${name}"]`).replaceWith($item); - $item.zuiInit(); + const $items = $data.filter(`[data-name="${name}"]`); + const $oldMatchItems = $oldItems.filter(`[data-name="${name}"]`); + if($oldMatchItems.length) + { + $oldMatchItems.replaceWith($items); + } + else + { + $oldItems.last().after($items); + } + $items.zuiInit(); } });