From 0013f8ea60027334735bb0761e9deca6b5b98b97 Mon Sep 17 00:00:00 2001 From: wangyuting Date: Thu, 10 Aug 2023 16:59:40 +0800 Subject: [PATCH] * Optimize bug batchEdit. --- module/bug/control.php | 38 +++++++++++++++++++++++++----- module/bug/js/batchedit.js | 16 ++++++------- module/bug/js/resolve.js | 17 ------------- module/bug/model.php | 2 +- module/bug/view/batchedit.html.php | 4 ++-- module/user/control.php | 4 ++-- 6 files changed, 45 insertions(+), 36 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index cd3ab3e21e..90aea685f7 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1417,8 +1417,7 @@ class bug extends control $this->view->showFields = $this->config->bug->custom->batchEditFields; /* Set users. */ - $users = $this->loadModel('user')->getPairs('devfirst', '', $this->config->batchMaxCount); - $users = array('' => '', 'ditto' => $this->lang->bug->ditto) + $users; + $users = $this->loadModel('user')->getPairs(); $branchIdList = array(); $projectIdList = array(); @@ -1444,12 +1443,37 @@ class bug extends control } } - $this->config->moreLinks["duplicateBugs[{$bug->id}]"] = inlink('ajaxGetProductBugs', "productID={$bug->product}&bugID={$bug->id}&type=json"); - if(!empty($this->config->user->moreLink)) + $bug->assignedToList = array(); + if($this->app->tab == 'project' or $this->app->tab == 'execution') { - $this->config->moreLinks["resolvedBys[$bug->id]"] = $this->config->user->moreLink; - $this->config->moreLinks["assignedTos[$bug->id]"] = $this->config->user->moreLink; + if($bug->execution) + { + $bug->assignedToList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $executionMembers[$bug->execution]; + } + elseif($bug->project) + { + $bug->assignedToList = array('' => '', 'ditto' => $this->lang->bug->ditto) + $projectMembers[$bug->project]; + } + else + { + $bug->assignedToList = $productMembers[$bug->product][$bug->branch]; + if(empty($bug->assignedToList)) + { + $bug->assignedToList = $users; + $this->config->moreLinks["assignedTos[$bug->id]"] = helper::createLink('user', 'ajaxGetMore'); + unset($bug->assignedToList['closed']); + } + } } + else + { + $bug->assignedToList = $users; + $this->config->moreLinks["assignedTos[$bug->id]"] = helper::createLink('user', 'ajaxGetMore'); + unset($bug->assignedToList['closed']); + } + + $this->config->moreLinks["duplicateBugs[{$bug->id}]"] = inlink('ajaxGetProductBugs', "productID={$bug->product}&bugID={$bug->id}&type=json"); + $this->config->moreLinks["resolvedBys[$bug->id]"] = helper::createLink('user', 'ajaxGetMore'); } /* Get assigned to member. */ @@ -1938,6 +1962,8 @@ class bug extends control $this->bug->checkBugExecutionPriv($bug); $this->qa->setMenu($this->products, $productID, $bug->branch); + $this->config->moreLinks['duplicateBug'] = inlink('ajaxGetProductBugs', "productID={$productID}&bugID={$bugID}&type=json"); + $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->resolve; $this->view->bug = $bug; $this->view->users = $users; diff --git a/module/bug/js/batchedit.js b/module/bug/js/batchedit.js index 5869da870b..c7055e2d23 100644 --- a/module/bug/js/batchedit.js +++ b/module/bug/js/batchedit.js @@ -24,7 +24,7 @@ $(document).on('click', '.chosen-with-drop', function(){oldValue = $(this).prev( /* Set ditto value. */ $(document).on('change', 'select', function() { - if($(this).val() == 'ditto') + if($(this).data('zui.picker').getValue() == 'ditto') { var index = $(this).closest('td').index(); var row = $(this).closest('tr').index(); @@ -38,34 +38,34 @@ $(document).on('change', 'select', function() } var value = ''; + var label = ''; for(i = row - 1; i >= 0; i--) { - value = tbody.children('tr').eq(i).find('td').eq(index).find('select').val(); + value = tbody.children('tr').eq(i).find('td').eq(index).find('select').data('zui.picker').getValue(); + label = tbody.children('tr').eq(i).find('td').eq(index).find('select').data('zui.picker').getListItem(value).text; if(value != 'ditto') break; } isPlans = $(this).attr('name').indexOf('plans') != -1; + $(this).data('zui.picker').updateOptionList([{text: label, value}]); if(isPlans) { var valueStr = ',' + $(this).find('option').map(function(){return $(this).val();}).get().join(',') + ','; if(valueStr.indexOf(',' + value + ',') != -1) { - $(this).val(value); + $(this).data('zui.picker').setValue(value); } else { alert(dittoNotice); - $(this).val(oldValue); + $(this).data('zui.picker').setValue(oldValue); } } else { - $(this).val(value); + $(this).data('zui.picker').setValue(value); } - - $(this).trigger("chosen:updated"); - $(this).trigger("change"); } }) diff --git a/module/bug/js/resolve.js b/module/bug/js/resolve.js index 93542c8770..8afea5743c 100644 --- a/module/bug/js/resolve.js +++ b/module/bug/js/resolve.js @@ -2,23 +2,6 @@ function setDuplicate(resolution) { if(resolution == 'duplicate') { - $.ajaxSettings.async = false; - link = createLink('bug', 'ajaxGetProductBugs', 'projectID=' + productID + '&bugID=' + bugID); - link = link + (link.indexOf('?') !== -1 ? '&' : '?') + 'limit=200'; - remoteLink = createLink('bug', 'ajaxGetProductBugs', 'productID=' + productID + '&bugID=' + bugID + '&type=json'); - remoteLink = remoteLink + (remoteLink.indexOf('?') !== -1 ? '&' : '?') + 'search={search}'; - $.get(link, function(data) - { - $('#duplicateBug').replaceWith(data); - $('#pk_duplicateBug-search').parent().parent().remove(); - $('#duplicateBug').picker( - { - disableEmptySearch : true, - dropWidth : 'auto', - remote: remoteLink - }); - }); - $.ajaxSettings.async = true; $('#duplicateBugBox').show(); } else diff --git a/module/bug/model.php b/module/bug/model.php index 82bea49c23..45db8dde1c 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -561,7 +561,7 @@ class bugModel extends model $bug = $this->loadModel('file')->replaceImgURL($bug, 'steps'); if($setImgSize) $bug->steps = $this->file->setImgSize($bug->steps); - foreach($bug as $key => $value) if(strpos($key, 'Date') !== false and !(int)substr($value, 0, 4)) $bug->$key = ''; + foreach($bug as $key => $value) if(strpos($key, 'Date') !== false && $value && !(int)substr($value, 0, 4)) $bug->$key = ''; if($bug->duplicateBug) $bug->duplicateBugTitle = $this->dao->findById($bug->duplicateBug)->from(TABLE_BUG)->fields('title')->fetch('title'); if($bug->case) $bug->caseTitle = $this->dao->findById($bug->case)->from(TABLE_CASE)->fields('title')->fetch('title'); diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index da22c77db3..92b030f31d 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -129,12 +129,12 @@ unset($assignedToList['closed']); } ?> - ' style='overflow:visible'>status == 'closed' ? html::input("assignedTos[$bugID]", ucfirst($bug->assignedTo), 'class=form-control disabled') : html::select("assignedTos[$bugID]", $assignedToList, $bug->assignedTo, "class='form-control picker-select' data-drop-width='135px'");?> + ' style='overflow:visible'>status == 'closed' ? html::input("assignedTos[$bugID]", ucfirst($bug->assignedTo), 'class=form-control disabled') : html::select("assignedTos[$bugID]", array('' => '', 'ditto' => $this->lang->bug->ditto) + array($bug->assignedTo => zget($bug->assignedToList, $bug->assignedTo)), $bug->assignedTo, "class='form-control picker-select' data-drop-width='135px'");?> ' style='overflow:visible'>deadline) ? '' : $bug->deadline, "class='form-control form-date'");?> >bug->osList, $bug->os, 'class="form-control chosen" multiple');?> >bug->browserList, $bug->browser, 'class="form-control chosen" multiple');?> >keywords, 'class=form-control');?> - ' style='overflow:visible'>resolvedBy, "class='form-control picker-select' data-drop-width='auto'");?> + ' style='overflow:visible'> '', 'ditto' => $this->lang->bug->ditto) + array($bug->resolvedBy => zget($users, $bug->resolvedBy)), $bug->resolvedBy, "class='form-control picker-select' data-drop-width='auto'");?> > diff --git a/module/user/control.php b/module/user/control.php index 97bbec4472..8bde992c9c 100755 --- a/module/user/control.php +++ b/module/user/control.php @@ -1384,13 +1384,13 @@ class user extends control { $params = base64_decode($this->get->params); parse_str($params, $parsedParams); - $users = $this->user->getPairs($parsedParams['params'], $parsedParams['usersToAppended']); + $users = $this->user->getPairs(zget($parsedParams, 'params', ''), zget($parsedParams, 'usersToAppended', '')); $search = $this->get->search; $limit = $this->get->limit; $index = 0; $newUsers = array(); - if(empty($search)) return array(); + //if(empty($search)) return array(); foreach($users as $account => $realname) { if($index >= $limit) break;