* Optimize bug edit, change render testtasks with ajax.

This commit is contained in:
chaideqing
2023-06-28 05:43:32 +00:00
parent 7c4c863e3c
commit 22a691a2fd
3 changed files with 32 additions and 4 deletions

View File

@@ -1189,7 +1189,6 @@ class bug extends control
$this->view->branchOption = $branchOption;
$this->view->branchTagOption = $branchTagOption;
$this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution);
$this->view->testtasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask);
$this->view->users = $this->user->getPairs('', "$bug->assignedTo,$bug->resolvedBy,$bug->closedBy,$bug->openedBy");
$this->view->assignedToList = $assignedToList;
$this->view->cases = array('' => '') + $cases;
@@ -1255,6 +1254,17 @@ class bug extends control
echo json_encode($builds);
}
public function ajaxGetTestTasks($bugID)
{
$bug = $this->bug->getById($bugID);
$testTasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask);
$testTasks = array_map(function($key, $value)
{
return (object) array('value' => $key, 'text' => $value);
}, array_keys($testTasks), array_values($testTasks));
echo json_encode($testTasks);
}
/**
* Batch edit bug.
*

View File

@@ -15,7 +15,8 @@ $(function()
initPicker($('#case'));
initPicker($('#duplicateBug'));
getAllBuilds();
renderBuilds();
renderTestTasks();
$('#duplicateBug').picker(
{
@@ -48,7 +49,7 @@ $(function()
* @access public
* @return void
*/
function getAllBuilds()
function renderBuilds()
{
$.get(createLink('bug', 'ajaxGetAllBuilds', 'bugID=' + bugID), function(data)
{
@@ -81,6 +82,22 @@ function getAllBuilds()
}, 'json');
}
/**
* render testTasks.
*
* @access public
* @return void
*/
function renderTestTasks()
{
$.get(createLink('bug', 'ajaxGetTestTasks', 'bugID=' + bugID), function(data)
{
$('#testtask').data('zui.picker').destroy();
$('#testtask').picker({list: data});
$('#testtask').data('zui.picker').setValue(bugTestTask);
}, 'json');
}
/**
* Set duplicate field.
*

View File

@@ -32,6 +32,7 @@ js::set('isClosedBug' , $bug->status == 'closed');
js::set('projectExecutionPairs' , $projectExecutionPairs);
js::set('productID' , $product->id);
js::set('released' , $lang->build->released);
js::set('bugTestTask' , $bug->testtask);
if($this->app->tab == 'execution') js::set('objectID', $bug->execution);
if($this->app->tab == 'project') js::set('objectID', $bug->project);
?>
@@ -313,7 +314,7 @@ if($this->app->tab == 'project') js::set('objectID', $bug->project);
</tr>
<tr>
<th><?php echo $lang->bug->testtask;?></th>
<td id='testtaskBox'><?php echo html::select('testtask', $testtasks, $bug->testtask, 'class="form-control chosen"');?></td>
<td id='testtaskBox'><?php echo html::select('testtask', array(), '', 'class="form-control picker-select"');?></td>
</tr>
<tr>
<th><?php echo $lang->bug->fromCase;?></th>