* Optimize project linkage on create bug page.

This commit is contained in:
孔令茂
2022-11-29 13:20:50 +00:00
parent 0b298bf63c
commit e5cfde941d
3 changed files with 46 additions and 22 deletions
-15
View File
@@ -2315,21 +2315,6 @@ class bug extends control
return print(html::select('assignedTo', $allUsers, $selectedUser, 'class="form-control"'));
}
/**
* AJAX: get a project by execution id.
*
* @param string $executionID
* @access public
* @return string
*/
public function ajaxGetProjectByExecutionID($executionID)
{
$execution = $this->loadModel('execution')->getByID($executionID);
$projectPairs = $this->loadModel('project')->getPairsByIdList($execution->project);
return print(html::select('project', $projectPairs, array_keys($projectPairs), 'class="form-control"'));
}
/**
* AJAX: get actions of a bug. for web app.
*
+20 -7
View File
@@ -471,12 +471,12 @@ function loadExecutionRelated(executionID)
if(executionID)
{
if(currentProjectID == 0) loadProjectByExecutionID(executionID);
loadExecutionTasks(executionID);
loadExecutionStories(executionID);
loadExecutionBuilds(executionID);
loadAssignedTo(executionID, $('#assignedTo').val());
loadTestTasks($('#product').val(), executionID);
if(currentProjectID ==0) loadProjectByExecutionID(executionID);
}
else
{
@@ -507,19 +507,32 @@ function loadExecutionRelated(executionID)
*/
function loadProjectByExecutionID(executionID)
{
link = createLink('bug', 'ajaxGetProjectByExecutionID', 'executionID=' + executionID);
required = $('#project_chosen').hasClass('required');
link = createLink('project', 'ajaxGetPairsByExecution', 'executionID=' + executionID, 'json');
required = $('#project_chosen').hasClass('required');
productID = $('#product').val();
$.post(link, function(data)
{
if(!data) data = '<select id="project" name="project" class="form-control"></select>';
$('#project').replaceWith(data);
var originProject = $('#project').html();
if($('#project').find('option[value="' + data.id + '"]').length > 0)
{
$('#project').find('option[value="' + data.id + '"]').attr('selected', 'selected');
originProject = $('#project').html();
$('#project').replaceWith('<select id="project" name="project" class="form-control" onchange="loadProductExecutions(' + productID + ', this.value)">' + originProject + '</select>');
}
else
{
var newProject = '<option value="' + data.id + '" data-keys="' + data.namePinyin + '" selected="selected">' + data.name + '</option>';
$('#project').replaceWith('<select id="project" name="project" class="form-control" onchange="loadProductExecutions(' + productID + ', this.value)">' + originProject + newProject+ '</select>');
}
$('#project_chosen').remove();
$('#project').next('.picker').remove();
$("#project").chosen();
$('#project').chosen();
if(required) $('#project_chosen').addClass('required');
})
}, 'json')
}
/**
+26
View File
@@ -2313,6 +2313,32 @@ class project extends control
return print(html::select('execution', $executions, $executionID, "class='form-control'"));
}
/**
* AJAX: get a project by execution id.
*
* @param string $executionID
* @access public
* @return string
*/
public function ajaxGetPairsByExecution($executionID)
{
$execution = $this->loadModel('execution')->getByID($executionID);
$projectPairs = $this->loadModel('project')->getPairsByIdList($execution->project);
if($this->app->getViewType() == 'json')
{
$project = array('id' => key($projectPairs), 'name' => reset($projectPairs));
$pinyin = common::convert2Pinyin(array(reset($projectPairs)));
$project['namePinyin'] = zget($pinyin, $project['name']);
return print(json_encode($project));
}
else
{
return print(html::select('project', $projectPairs, $execution->project, "class='form-control' onchange='loadProductExecutions({$execution->project}, this.value)'"));
}
}
/**
* Link projects and code repositories.
*