* Finish task #54329.

This commit is contained in:
tianshujie
2022-05-18 16:08:09 +08:00
parent 0134da75fe
commit f1f4c511b5
6 changed files with 163 additions and 8 deletions
+21 -2
View File
@@ -71,7 +71,18 @@ class custom extends control
if(($module == 'story' or $module == 'testcase') and $field == 'review')
{
$this->app->loadConfig($module);
$this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted');
$this->loadModel('user');
if($module == 'story')
{
$this->view->depts = $this->loadModel('dept')->getDeptPairs();
$this->view->forceReviewAll = zget($this->config->$module, 'forceReviewAll', 'false');
$this->view->forceReviewUsers = zget($this->config->$module, 'forceReviewUsers', '');
$this->view->forceReviewRoles = zget($this->config->$module, 'forceReviewRoles', '');
$this->view->forceReviewDepts = zget($this->config->$module, 'forceReviewDepts', '');
}
$this->view->users = $module == 'story' ? $this->user->getCanCreateStoryUsers() : $this->user->getPairs('noclosed|nodeleted');
$this->view->needReview = zget($this->config->$module, 'needReview', 1);
$this->view->forceReview = zget($this->config->$module, 'forceReview', '');
$this->view->forceNotReview = zget($this->config->$module, 'forceNotReview', '');
@@ -112,7 +123,15 @@ class custom extends control
}
elseif($module == 'story' and $field == 'review')
{
$data = fixer::input('post')->join('forceReview', ',')->get();
$data = fixer::input('post')
->setDefault('forceReviewDepts', '')
->join('forceReviewUsers', ',')
->join('forceReviewRoles', ',')
->join('forceReviewDepts', ',')
->get();
$data->forceReviewAll = isset($data->forceReviewAll) ? 1 : 0;
$this->loadModel('setting')->setItems("system.$module@{$this->config->vision}", $data);
}
elseif($module == 'story' and $field == 'reviewRules')
+6
View File
@@ -50,6 +50,10 @@ $lang->custom->oneUnit = "One {$lang->hourCommon}";
$lang->custom->convertRelationTitle = "Please firstly set the conversion factor from {$lang->hourCommon} to %s";
$lang->custom->superReviewers = "Super Reviewer";
$lang->custom->kanban = "Kanban";
$lang->custom->allUsers = 'All Users';
$lang->custom->account = 'Users';
$lang->custom->role = 'Role';
$lang->custom->dept = 'Dept';
if($config->systemMode == 'new') $lang->custom->execution = 'Execution';
if($config->systemMode == 'classic' || !$config->systemMode) $lang->custom->execution = $lang->executionCommon;
@@ -181,6 +185,8 @@ $lang->custom->notice->readOnlyOfKanban = "If Change Forbidden, any change on
$lang->custom->notice->URSREmpty = 'Custom requirement name can not be empty!';
$lang->custom->notice->confirmDelete = 'Are you sure you want to delete it?';
$lang->custom->notice->confirmReviewCase = 'Set the case in Wait to Normal?';
$lang->custom->notice->storyReviewTip = 'After selecting by individual, position, and department, take the union of these three filters. ';
$lang->custom->notice->selectAllTip = 'After selecting all people, the reviewers will be emptied and grayed out while hiding their positions and departments.';
$lang->custom->notice->indexPage['product'] = "ZenTao 8.2+ has Product Home. Do you want to go to Product Home?";
$lang->custom->notice->indexPage['project'] = "ZenTao 8.2+ has Project Home. Do you want to go to Project Home?";
+6
View File
@@ -50,6 +50,10 @@ $lang->custom->oneUnit = "一个{$lang->hourCommon}";
$lang->custom->convertRelationTitle = "请先设置{$lang->hourCommon}转换为%s的换算系数";
$lang->custom->superReviewers = "超级评审人";
$lang->custom->kanban = "看板";
$lang->custom->allUsers = '所有人员';
$lang->custom->account = '人员';
$lang->custom->role = '职位';
$lang->custom->dept = '部门';
if($config->systemMode == 'new') $lang->custom->execution = '执行';
if($config->systemMode == 'classic' || !$config->systemMode) $lang->custom->execution = $lang->executionCommon;
@@ -181,6 +185,8 @@ $lang->custom->notice->readOnlyOfKanban = "禁止修改后,已关闭{$lang-
$lang->custom->notice->URSREmpty = '自定义需求名称不能为空!';
$lang->custom->notice->confirmDelete = '您确定要删除吗?';
$lang->custom->notice->confirmReviewCase = '是否将待评审的用例修改为正常状态?';
$lang->custom->notice->storyReviewTip = '按人员、职位、部门勾选后,取所有人员的并集。';
$lang->custom->notice->selectAllTip = '勾选所有人员后,会清空并置灰评审人员,同时隐藏职位、部门。';
$lang->custom->notice->indexPage['product'] = "从8.2版本起增加了产品主页视图,是否默认进入产品主页?";
$lang->custom->notice->indexPage['project'] = "从8.2版本起增加了项目主页视图,是否默认进入项目主页?";
+74 -5
View File
@@ -36,6 +36,18 @@ EOT;
<style>
.checkbox-primary {width: 170px; margin: 0 10px 10px 0; display: inline-block;}
</style>
<?php if($module == 'story' and $field == 'review'):?>
<style>
.reviewBox > th {width: 95px !important;}
.reviewBox > td {width: 500px !important;}
.checkbox-primary {margin-bottom: 0px; width: 82px !important;}
.storyReviewTip {padding-left: 95px;}
<?php if($app->getClientLang() != 'zh-cn' and $app->getClientLang() !== 'zh-tw'):?>
.reviewBox > th {width: 160px !important;}
.storyReviewTip {padding-left: 160px;}
<?php endif;?>
</style>
<?php endif;?>
<div id='mainContent' class='main-row'>
<div class='side-col' id='sidebar'>
<div class='cell'>
@@ -88,18 +100,39 @@ EOT;
</tr>
</table>
<?php elseif(($module == 'story' or $module == 'testcase') and $field == 'review'):?>
<table class='table table-form mw-800px'>
<tr>
<table class='table table-form'>
<tr class='reviewBox'>
<th class='thWidth'><?php echo $lang->custom->storyReview;?></th>
<td><?php echo html::radio('needReview', $lang->custom->reviewList, $needReview);?></td>
<td></td>
</tr>
<tr <?php if($needReview and $module == 'testcase') echo "class='hidden'"?>>
<?php if($module == 'story'):?>
<tr>
<?php $space = ($app->getClientLang() != 'zh-cn' and $app->getClientLang() !== 'zh-tw') ? ' ': '';?>
<td colspan='3'><div class='storyReviewTip'><?php echo sprintf($lang->custom->notice->forceReview, $lang->$module->common) . $lang->custom->notice->storyReviewTip;?></td>
</tr>
<tr id='userBox'>
<th><?php echo $lang->custom->forceReview . $space . $lang->custom->account;?></th>
<td><?php echo html::select('forceReviewUsers[]', $users, $forceReviewUsers, "class='form-control chosen' multiple");?></td>
<td>
<?php echo html::checkbox('forceReviewAll', array('1' => $lang->custom->allUsers), $forceReviewAll);?>
<icon class='icon icon-help' data-toggle='popover' data-trigger='focus hover' data-placement='right' data-tip-class='text-muted popover-sm' data-content="<?php echo $lang->custom->notice->selectAllTip;?>"></icon>
</td>
</tr>
<tr id='roleBox'>
<th><?php echo $lang->custom->forceReview . $space . $lang->custom->role;?></th>
<td><?php echo html::select('forceReviewRoles[]', $lang->user->roleList, $forceReviewRoles, "class='form-control chosen' multiple");?></td>
</tr>
<tr id='deptBox'>
<th><?php echo $lang->custom->forceReview . $space . $lang->custom->dept;?></th>
<td><?php echo html::select('forceReviewDepts[]', $depts, $forceReviewDepts, "class='form-control chosen' multiple");?></td>
</tr>
<?php endif;?>
<?php if($module == 'testcase'):?>
<tr <?php if($needReview) echo "class='hidden'"?>>
<th><?php echo $lang->custom->forceReview;?></th>
<td><?php echo html::select('forceReview[]', $users, $forceReview, "class='form-control chosen' multiple");?></td>
<td style='width:300px'><?php printf($lang->custom->notice->forceReview, $lang->$module->common);?></td>
</tr>
<?php if($module == 'testcase'):?>
<tr <?php if(!$needReview) echo "class='hidden'"?>>
<th><?php echo $lang->custom->forceNotReview;?></th>
<td><?php echo html::select('forceNotReview[]', $users, $forceNotReview, "class='form-control chosen' multiple");?></td>
@@ -231,6 +264,42 @@ EOT;
</form>
</div>
</div>
<?php if($module == 'story' and $field == 'review'):?>
<script>
$(function()
{
$('[data-toggle="popover"]').popover();
toggleBox($("input[name^='forceReviewAll']").prop('checked'));
$("input[name^='forceReviewAll']").click(function()
{
toggleBox($(this).prop('checked'));
});
/**
* Toggle box.
*
* @param bool $checked
* @access public
* @return void
*/
function toggleBox(checked)
{
$('#roleBox').toggleClass('hidden', checked);
$('#deptBox').toggleClass('hidden', checked);
if(checked)
{
$('#forceReviewUsers').val('').attr('disabled', 'disabled').trigger('chosen:updated');
}
else
{
$('#forceReviewUsers').removeAttr('disabled', 'disabled').trigger('chosen:updated');
}
}
})
</script>
<?php endif;?>
<?php if($module == 'testcase' and $field == 'review'):?>
<script>
$(function()
+24 -1
View File
@@ -4319,7 +4319,30 @@ class storyModel extends model
public function checkForceReview()
{
$forceReview = false;
if(!empty($this->config->story->forceReview)) $forceReview = strpos(",{$this->config->story->forceReview},", ",{$this->app->user->account},") !== false;
if(isset($this->config->story->forceReviewAll) and $this->config->story->forceReviewAll) return true;
$forceUsers = '';
if(!empty($this->config->story->forceReviewUsers)) $forceUsers .= $this->config->story->forceReviewUsers;
if(!empty($this->config->story->forceReviewRoles) or !empty($this->config->story->forceReviewDepts))
{
$users = $this->dao->select('account')->from(TABLE_USER)
->where('deleted')->eq(0)
->andWhere(true, true)
->beginIF(!empty($this->config->story->forceReviewRoles))
->andWhere('role', true)->in($this->config->story->forceReviewRoles)
->andWhere('role')->ne('')
->markRight(1)
->fi()
->beginIF(!empty($this->config->story->forceReviewDepts))->orWhere('dept')->in($this->config->story->forceReviewDepts)->fi()
->markRight(1)
->fetchAll('account');
$forceUsers .= "," . implode(',', array_keys($users));
}
$forceReview = strpos(",{$forceUsers},", ",{$this->app->user->account},") !== false;
return $forceReview;
}
+32
View File
@@ -2766,6 +2766,38 @@ class userModel extends model
return $visionList;
}
/**
* Get users who have authority to create stories.
*
* @access public
* @return array
*/
public function getCanCreateStoryUsers()
{
$users = $this->getPairs('noclosed|nodeleted');
$groups = $this->dao->select('*')->from(TABLE_USERGROUP)
->where('account')->in(array_keys($users))
->fetchGroup('account', 'group');
foreach($users as $account => $user)
{
if(empty($user) or strpos($this->app->company->admins, ",{$account},") !== false) continue;
$group = $groups[$account];
$priv = $this->dao->select('*')->from(TABLE_GROUPPRIV)
->where('`group`')->in(array_keys($group))
->andWhere('module')->eq('story')
->andWhere('(method')->eq('create')
->orWhere('method')->eq('batchCreate')
->markRight(1)
->fetch();
if(empty($priv)) unset($users[$account]);
}
return $users;
}
/**
* Switch admin of ZenTao.
*