* Finish task #41238.

This commit is contained in:
holan20180123
2021-08-18 17:23:13 +08:00
parent f26c989ed2
commit 25242a2317
6 changed files with 63 additions and 5 deletions

View File

@@ -1,3 +1,45 @@
/**
* Save team members.
*
* @access public
* @return void
*/
function saveMemebers()
{
var isDeleted = false;
var accountList = [];
$("[name^='accounts']").each(function()
{
if($(this).val()) accountList.push($(this).val());
})
oldAccountList.forEach(function(account)
{
if(accountList.indexOf(account) < 0)
{
isDeleted = true;
return false;
}
})
if(!isDeleted)
{
$('#saveBtn').addClass('hidden');
$('#submit').removeClass('hidden');
$('#submit').click();
}
else
{
bootbox.confirm(unlinkExecutionMembers, function(result)
{
$('#saveBtn').addClass('hidden');
$('#submit').removeClass('hidden');
if(result) $('#removeExecution').val('yes');
$('#submit').click();
})
}
}
/**
* Set role when select an account.
*

View File

@@ -140,6 +140,7 @@ $lang->project->multiLinkedProductsTip = 'The following products linked to this
$lang->project->linkStoryByPlanTips = "This action will associate all {$lang->SRCommon} under the selected plan to this project";
$lang->project->createExecution = "There is no {$lang->executionCommon} under this project, please create {$lang->executionCommon} first";
$lang->project->unlinkExecutionMember = "The user participated in %s executions such as %s%s. Do you want to remove the user from those executions as well? (The data related to this user will not be deleted.)";
$lang->project->unlinkExecutionMembers = "The team members you are removing are also in the execution team of this project. Do you want to remove them from the execution team too?";
$lang->project->tenThousand = '';

View File

@@ -140,6 +140,7 @@ $lang->project->multiLinkedProductsTip = '该项目关联的如下产品还关
$lang->project->linkStoryByPlanTips = "此操作会将所选计划下面的{$lang->SRCommon}全部关联到此项目中";
$lang->project->createExecution = "该项目下没有{$lang->executionCommon},请先创建{$lang->executionCommon}";
$lang->project->unlinkExecutionMember = "该用户参与了%s%s%s个{$lang->execution->common},是否同时将其移除?(该用户所产生的数据不会受影响。)";
$lang->project->unlinkExecutionMembers = "移除的团队成员还参与了项目下的执行,是否同步从执行团队中移除?";
$lang->project->tenThousand = '万';

View File

@@ -1324,8 +1324,8 @@ class projectModel extends model
/* Only changed account update userview. */
$oldAccounts = array_keys($oldJoin);
$changedAccounts = array_diff($accounts, $oldAccounts);
$changedAccounts = array_merge($changedAccounts, array_diff($oldAccounts, $accounts));
$removedAccounts = array_diff($oldAccounts, $accounts);
$changedAccounts = array_merge($removedAccounts, array_diff($accounts, $oldAccounts));
$changedAccounts = array_unique($changedAccounts);
$childSprints = $this->dao->select('id')->from(TABLE_PROJECT)->where('project')->eq($projectID)->andWhere('type')->in('stage,sprint')->andWhere('deleted')->eq('0')->fetchPairs();
@@ -1334,6 +1334,16 @@ class projectModel extends model
$this->loadModel('user')->updateUserView(array($projectID), 'project', $changedAccounts);
if(!empty($childSprints)) $this->user->updateUserView($childSprints, 'sprint', $changedAccounts);
if(!empty($linkedProducts)) $this->user->updateUserView(array_keys($linkedProducts), 'product', $changedAccounts);
/* Remove execution members. */
if($removeExecution == 'yes' and !empty($childSprints) and !empty($removedAccounts))
{
$this->dao->delete()->from(TABLE_TEAM)
->where('root')->in($childSprints)
->andWhere('type')->eq('execution')
->andWhere('account')->in($removedAccounts)
->exec();
}
}
/**

View File

@@ -3,6 +3,8 @@
<?php js::set('roles', $roles);?>
<?php js::set('deptID', $dept);?>
<?php js::set('copyProjectID', $copyProjectID);?>
<?php js::set('oldAccountList', array_keys($currentMembers));?>
<?php js::set('unlinkExecutionMembers', $lang->project->unlinkExecutionMembers);?>
<div id='mainMenu' class='clearfix'>
<div class='btn-toolbar pull-left'>
<span class='btn btn-link btn-active-text'>
@@ -105,7 +107,9 @@
<tfoot>
<tr>
<td colspan='6' class='text-center form-actions'>
<?php echo html::submitButton() . html::backButton();?>
<?php echo html::hidden('removeExecution', 'no');?>
<?php echo html::submitButton('', '', 'hidden btn btn-wide btn-primary');?>
<?php echo html::commonButton($lang->save, 'onclick="saveMemebers()" id="saveBtn"', 'btn btn-wide btn-primary') . html::backButton();?>
</td>
</tr>
</tfoot>