* Finish task #41244.

This commit is contained in:
tianshujie98
2021-08-11 15:04:29 +08:00
parent b16fa82740
commit 201285215b
9 changed files with 124 additions and 32 deletions
+23
View File
@@ -1340,6 +1340,7 @@ class execution extends control
$this->view->name = $name;
$this->view->code = $code;
$this->view->team = $team;
$this->view->teams = array(0 => '') + $this->execution->getTeamPairsByProject((int)$projectID);
$this->view->allProjects = array(0 => '') + $this->project->getPairsByModel();
$this->view->executionID = $executionID;
$this->view->productID = $productID;
@@ -2635,6 +2636,28 @@ class execution extends control
}
}
/**
* AJAX: get team members by projectID/executionID.
*
* @param int $objectID
* @access public
* @return string
*/
public function ajaxGetTeamMembers($objectID)
{
$type = 'execution';
if($this->config->systemMode == 'new')
{
$type = $this->dao->findById($objectID)->from(TABLE_PROJECT)->fetch('type');
$type = $type == 'project' ? $type : 'execution';
}
$users = $this->loadModel('user')->getPairs('nodeleted|noclosed');
$members = $this->user->getTeamMemberPairs($objectID, $type);
die(html::select('teamMembers[]', $users, array_keys($members), "class='form-control chosen' multiple"));
}
/**
* When create a execution, help the user.
*
+12
View File
@@ -42,6 +42,18 @@ $(function()
};
adjustMainCol();
$(window).on('resize', adjustMainCol);
$('#teams').change(function()
{
var objectID = $(this).val();
$.get(createLink('execution', 'ajaxGetTeamMembers', 'objectID=' + objectID), function(data)
{
$('#teamMembers').parent().html(data);
$('#teamMembers').chosen();
});
})
$('#teams').change();
});
function showLifeTimeTips()
+3
View File
@@ -99,6 +99,9 @@ $lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Start';
$lang->execution->activate = 'Aktivieren';
$lang->execution->putoff = 'Zurückstellen';
+3
View File
@@ -100,6 +100,9 @@ $lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Start';
$lang->execution->activate = 'Activate';
$lang->execution->putoff = 'Delay';
+3
View File
@@ -99,6 +99,9 @@ $lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Démarrer';
$lang->execution->activate = 'Activer';
$lang->execution->putoff = 'Ajourner';
+3
View File
@@ -100,6 +100,9 @@ $lang->execution->recent = 'Recent visits: ';
$lang->execution->copyNoExecution = 'There are no ' . $lang->executionCommon . 'available to copy.';
$lang->execution->noTeam = 'No team members at the moment';
if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "select Project/{$lang->execution->common} to copy its members";
if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "select Project/{$lang->executionCommon} to copy its members";
$lang->execution->start = 'Bắt đầu';
$lang->execution->activate = 'Kích hoạt';
$lang->execution->putoff = 'Tạm ngưng';
+3
View File
@@ -100,6 +100,9 @@ $lang->execution->recent = '近期访问:';
$lang->execution->copyNoExecution = '没有可用的' . $lang->executionCommon . '来复制';
$lang->execution->noTeam = '暂时没有团队成员';
if($this->config->systemMode == 'new') $lang->execution->copyTeamTip = "可以选择复制项目或{$lang->execution->common}团队的成员";
if($this->config->systemMode == 'classic') $lang->execution->copyTeamTip = "可以选择复制{$lang->executionCommon}团队的成员";
$lang->execution->start = "开始";
$lang->execution->activate = "激活";
$lang->execution->putoff = "延期";
+58 -25
View File
@@ -325,7 +325,7 @@ class executionModel extends model
->join('whitelist', ',')
->add('type', $type)
->stripTags($this->config->execution->editor->create['id'], $this->config->allowedTags)
->remove('products, workDays, delta, branch, uid, plans')
->remove('products, workDays, delta, branch, uid, plans, teams, teamMembers')
->get();
/* Check the workload format and total. */
@@ -368,6 +368,7 @@ class executionModel extends model
$executionID = $this->dao->lastInsertId();
$today = helper::today();
$creatorExists = false;
$teamMembers = array();
/* Save order. */
$this->dao->update(TABLE_EXECUTION)->set('`order`')->eq($executionID * 5)->where('id')->eq($executionID)->exec();
@@ -376,39 +377,42 @@ class executionModel extends model
/* Update the path. */
if($this->config->systemMode == 'new') $this->setTreePath($executionID);
/* Copy team of execution. */
if($copyExecutionID != '')
/* Set team of execution. */
$members = isset($_POST['teamMembers']) ? $_POST['teamMembers'] : array();
$roles = $this->loadModel('user')->getUserRoles(array_keys($members));
foreach($members as $account)
{
$members = $this->dao->select('*')->from(TABLE_TEAM)->where('root')->eq($copyExecutionID)->andWhere('type')->eq('execution')->fetchAll();
foreach($members as $member)
{
unset($member->id);
$member->root = $executionID;
$member->join = $today;
$member->days = $sprint->days;
$member->type = 'execution';
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
if($member->account == $this->app->user->account) $creatorExists = true;
}
}
if(empty($account)) continue;
/* Add the creator to team. */
if($copyExecutionID == '' or !$creatorExists)
{
$this->app->loadLang('user');
$member = new stdclass();
$member = new stdClass();
$member->root = $executionID;
$member->account = $this->app->user->account;
$member->role = zget($this->lang->user->roleList, $this->app->user->role, '');
$member->join = $today;
$member->type = 'execution';
$member->account = $account;
$member->role = zget($roles, $account, '');
$member->join = $today;
$member->days = $sprint->days;
$member->hours = $this->config->execution->defaultWorkhours;
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
if($this->config->systemMode == 'new') $this->addProjectMembers($sprint->project, array($member));
if($member->account == $this->app->user->account) $creatorExists = true;
$teamMembers[$account] = $member;
}
if(!$creatorExists)
{
$member = new stdClass();
$member->root = $executionID;
$member->type = 'execution';
$member->account = $this->app->user->account;
$member->role = zget($this->lang->user->roleList, $this->app->user->role, '');
$member->join = $today;
$member->days = $sprint->days;
$member->hours = $this->config->execution->defaultWorkhours;
$this->dao->insert(TABLE_TEAM)->data($member)->exec();
$teamMembers[$member->account] = $member;
}
if($this->config->systemMode == 'new') $this->addProjectMembers($sprint->project, $teamMembers);
/* Create doc lib. */
$this->app->loadLang('doc');
$lib = new stdclass();
@@ -2439,6 +2443,35 @@ class executionModel extends model
->fetchAll('account');
}
/**
* Get the project and execution the team through the projectID.
*
* @param int $projectID
* @access public
* @return array
*/
public function getTeamPairsByProject($projectID = 0)
{
$teams = $this->dao->select('id,team,type')->from(TABLE_PROJECT)
->where('deleted')->eq(0)
->andWhere('project')->eq($projectID)
->orWhere('id')->eq($projectID)
->fetchAll('id');
if(empty($teams)) return array();
$teamPairs = array();
foreach($teams as $id => $team)
{
if(empty($team->team)) continue;
$object = $team->type == 'project' ? $this->lang->project->common . '-' : $this->lang->execution->common . '-';
$teamPairs[$id] = $object . $team->team;
}
return $teamPairs;
}
/**
* Manage team members.
*
+16 -7
View File
@@ -50,13 +50,13 @@
<tr>
<th class='w-120px'><?php echo $lang->execution->project;?></th>
<td class="col-main"><?php echo html::select("project", $allProjects, $projectID, "class='form-control chosen' required onchange='refreshPage(this.value)'");?></td>
<td></td><td></td>
<td colspan='2'></td>
</tr>
<?php endif;?>
<tr>
<th class='w-120px'><?php echo (($from == 'execution') and ($config->systemMode == 'new')) ? $lang->execution->execName : $lang->execution->name;?></th>
<td class="col-main"><?php echo html::input('name', $name, "class='form-control' required");?></td>
<td></td><td></td>
<td colspan='2'></td>
</tr>
<tr>
<th><?php echo (($from == 'execution') and ($config->systemMode == 'new')) ? $lang->execution->execCode : $lang->execution->code;?></th>
@@ -82,13 +82,9 @@
</div>
</td><td></td><td></td>
</tr>
<tr>
<th><?php echo $lang->execution->teamname;?></th>
<td><?php echo html::input('team', $team, "class='form-control'");?></td><td></td><td></td>
</tr>
<tr>
<th><?php echo (($from == 'execution') and ($config->systemMode == 'new')) ? $lang->execution->execType : $lang->execution->type;?></th>
<td><?php echo html::select('lifetime', $lang->execution->lifeTimeList, '', "class='form-control' onchange='showLifeTimeTips()'"); ?></td>
<td><?php echo html::select('lifetime', $lang->execution->lifeTimeList, '', "class='form-control chosen' onchange='showLifeTimeTips()'"); ?></td>
<td class='muted' colspan='2'><div id='lifeTimeTips'><?php echo $lang->execution->typeDesc;?></div></td>
</tr>
<tr class='hide'>
@@ -144,6 +140,19 @@
</div>
</td>
</tr>
<tr>
<th><?php echo $lang->execution->teamname;?></th>
<td><?php echo html::input('team', $team, "class='form-control'");?></td>
<td colspan='2'></td>
</tr>
<tr>
<th><?php echo $lang->execution->copyTeam;?></th>
<td><?php echo html::select('teams', $teams, $copyExecutionID, "class='form-control chosen' data-placeholder='{$lang->execution->copyTeamTip}'"); ?></td>
</tr>
<tr>
<th><?php echo $lang->execution->team;?></th>
<td colspan='3'><?php echo html::select('teamMembers[]', $users, '', "class='form-control chosen' multiple"); ?></td>
</tr>
<tr>
<th><?php echo (($from == 'execution') and ($config->systemMode == 'new')) ? $lang->execution->execDesc : $lang->execution->desc;?></th>
<td colspan='3'>