Merge branch 'refactor' into 'master'

Refactor

See merge request easycorp/zentaopms!1229
This commit is contained in:
李玉春
2021-12-31 04:25:42 +00:00
10 changed files with 146 additions and 152 deletions
+5
View File
@@ -322,6 +322,11 @@ $lang->action->label->importfromgitlab = 'Issue associate created';
$lang->action->label->archived = 'Archived';
$lang->action->label->restore = 'Restore';
$lang->action->label->mergedbranch = 'Merge Branch';
$lang->action->label->startedbychild = 'started';
$lang->action->label->finishedbychild = 'finished';
$lang->action->label->closedbychild = 'closed';
$lang->action->label->activatedbychild = 'activated';
$lang->action->label->createchild = 'activated';
/* Dynamic information is grouped by object. */
$lang->action->dynamicAction = new stdclass;
+5
View File
@@ -322,6 +322,11 @@ $lang->action->label->importfromgitlab = '从Gitlab关联创建了';
$lang->action->label->archived = '归档了';
$lang->action->label->restore = '还原了';
$lang->action->label->mergedbranch = '合并分支';
$lang->action->label->startedbychild = '开始了';
$lang->action->label->finishedbychild = '完成了';
$lang->action->label->closedbychild = '关闭了';
$lang->action->label->activatedbychild = '激活了';
$lang->action->label->createchild = '激活了';
/* 动态信息按照对象分组 */
$lang->action->dynamicAction = new stdclass();
+2 -2
View File
@@ -467,7 +467,7 @@ class actionModel extends model
$name = $this->dao->select('name')->from(TABLE_TESTSUITE)->where('id')->eq($action->extra)->fetch('name');
if($name) $action->extra = common::hasPriv('caselib', 'browse') ? html::a(helper::createLink('caselib', 'browse', "libID=$action->extra"), $name) : $name;
}
elseif(strpos('importfromstorylib,importfromrisklib,importfromissuelib,importfromopportunitylib', $actionName)!== false)
elseif(strpos('importfromstorylib,importfromrisklib,importfromissuelib,importfromopportunitylib', $actionName) !== false)
{
$name = $this->dao->select('name')->from(TABLE_ASSETLIB)->where('id')->eq($action->extra)->fetch('name');
if($name) $action->extra = common::hasPriv('assetlib', $action->objectType) ? html::a(helper::createLink('assetlib', $action->objectType, "libID=$action->extra"), $name) : $name;
@@ -707,7 +707,7 @@ class actionModel extends model
{
$desc = $this->lang->$objectType->action->rejectreviewed;
}
elseif($action->objectType == 'productplan' and in_array($action->action, array('startedbychild','finishedbychild','closedbychild','activatedbychild')))
elseif($action->objectType == 'productplan' and in_array($action->action, array('startedbychild','finishedbychild','closedbychild','activatedbychild', 'createchild')))
{
$desc = $this->lang->$objectType->action->changebychild;
}
+25 -16
View File
@@ -66,6 +66,9 @@ class productplan extends control
$this->executeHooks($planID);
if($parent > 0) $this->productplan->updateParentStatus($parent);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $planID));
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => 'parent.refreshPlan()'));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('productplan', 'browse', "productID=$productID&branch=$branchID&browseType=wait")));
@@ -358,6 +361,8 @@ class productplan extends control
if($plan->parent > 0) $this->view->parentPlan = $this->productplan->getById($plan->parent);
if($plan->parent == '-1') $this->view->childrenPlans = $this->productplan->getChildren($plan->id);
if($plan->branch > 0) $this->view->branchStatus = $this->loadModel('branch')->getById($plan->branch, $plan->product, 'status');
$this->loadModel('datatable');
$this->view->modulePairs = $this->loadModel('tree')->getOptionMenu($plan->product, 'story', 0, 'all');
$this->view->title = "PLAN #$plan->id $plan->title/" . zget($products, $plan->product, '');
@@ -398,6 +403,18 @@ class productplan extends control
public function start($planID, $confirm = 'no')
{
$plan = $this->productplan->getByID($planID);
if($_POST)
{
$changes = $this->productplan->start($planID);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$actionID = $this->loadModel('action')->create('productplan', $planID, 'started');
$this->action->logHistory($actionID, $changes);
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
}
if(!isonlybody())
{
if($confirm == 'no')
@@ -406,22 +423,14 @@ class productplan extends control
}
else
{
$changes = $this->productplan->updateStatus($planID, 'doing');
if(dao::isError()) die(js::error(dao::getError()));
$this->productplan->updateStatus($planID, 'doing', 'started');
if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
else
{
if(!empty($_POST))
{
$changes = $this->productplan->updateStatus($planID, 'doing');
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess,'locate' => 'parent'));
}
$this->view->plan = $plan;
$this->display();
}
@@ -443,9 +452,9 @@ class productplan extends control
}
else
{
$changes = $this->productplan->updateStatus($planID, 'done');
if(dao::isError()) die(js::error(dao::getError()));
$this->productplan->updateStatus($planID, 'done', 'finished');
if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
@@ -466,9 +475,9 @@ class productplan extends control
}
else
{
$changes = $this->productplan->updateStatus($planID, 'closed');
if(dao::isError()) die(js::error(dao::getError()));
$this->productplan->updateStatus($planID, 'closed', 'closed');
if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
@@ -489,9 +498,9 @@ class productplan extends control
}
else
{
$changes = $this->productplan->updateStatus($planID, 'doing');
if(dao::isError()) die(js::error(dao::getError()));
$this->productplan->updateStatus($planID, 'doing', 'activated');
if(dao::isError()) die(js::error(dao::getError()));
die(js::reload('parent'));
}
}
+2 -1
View File
@@ -24,7 +24,8 @@ td.c-branch {overflow: hidden; text-align: left !important; text-overflow: ellip
.plan-name {position: relative; display: flex; align-items: center;}
.plan-name > span {flex: none;}
#productplanList .c-title.has-child > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 62px);}
[lang^='zh-'] #productplanList .c-title.has-child > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 62px);}
[lang^='en'] #productplanList .c-title.has-child > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 67px);}
#productplanList .c-title.has-child > .plan-name > a {overflow:hidden; max-width: calc(100% - 16px);}
#productplanList .c-title > .plan-name.expired > a {overflow:hidden; max-width: calc(100% - 46px);}
#productplanList .plan-name.expired > .label.label-danger {margin-left:3px; }
+2 -2
View File
@@ -18,12 +18,11 @@ $lang->productplan->delete = "Delete Plan";
$lang->productplan->start = "Start Plan";
$lang->productplan->finish = "Finish Plan";
$lang->productplan->close = "Close Plan";
$lang->productplan->activate = "Activate Plan";
$lang->productplan->startAB = "Start";
$lang->productplan->finishAB = "Finish";
$lang->productplan->closeAB = "Close";
$lang->productplan->activateAB = "Activate";
$lang->productplan->view = "Plan Detail";
$lang->productplan->activate = "Activate Plan";
$lang->productplan->view = "View";
$lang->productplan->bugSummary = "Total <strong>%s</strong> Bugs on this page.";
$lang->productplan->basicInfo = 'Basic Info';
@@ -102,6 +101,7 @@ $lang->productplan->parentActionList['startedbychild'] = '<strong>starting </s
$lang->productplan->parentActionList['finishedbychild'] = '<strong>finishing </strong>all productplan sets the plan status as <strong>Done</strong>.';
$lang->productplan->parentActionList['closedbychild'] = '<strong>closing </strong>all productplan sets the plan status as <strong>Closed</strong>.';
$lang->productplan->parentActionList['activatedbychild'] = '<strong>activating </strong>the productplan sets the plan status as <strong>Doing</strong>.';
$lang->productplan->parentActionList['createchild'] = '<strong>creating</strong> a child productplan sets the plan status as <strong>Doing</strong>.';
$lang->productplan->endList[7] = '1 Week';
$lang->productplan->endList[14] = '2 Weeks';
+1
View File
@@ -101,6 +101,7 @@ $lang->productplan->parentActionList['startedbychild'] = '系统判断由于
$lang->productplan->parentActionList['finishedbychild'] = '系统判断由于子计划 <strong>全部完成</strong> ,将计划状态置为 <strong>已完成</strong> 。';
$lang->productplan->parentActionList['closedbychild'] = '系统判断由于子计划 <strong>全部关闭</strong> ,将计划状态置为 <strong>已关闭</strong> 。';
$lang->productplan->parentActionList['activatedbychild'] = '系统判断由于子计划 <strong>激活</strong> ,将计划状态置为 <strong>进行中</strong> 。';
$lang->productplan->parentActionList['createchild'] = '系统判断由于 <strong>创建</strong> 子计划 ,将计划状态置为 <strong>进行中</strong> 。';
$lang->productplan->endList[7] = '一星期';
$lang->productplan->endList[14] = '两星期';
+97 -124
View File
@@ -501,6 +501,7 @@ class productplanModel extends model
->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
->where('id')->eq((int)$planID)
->exec();
if(!dao::isError())
{
$this->file->updateObjectID($this->post->uid, $planID, 'plan');
@@ -509,142 +510,114 @@ class productplanModel extends model
}
/**
* Update a plan's status.
*
* @param int $planID
* @param string $status
* Start a plan.
*
* @param int $planID
* @access public
* @return string
* @return array
*/
public function updateStatus($planID, $status = '')
public function start($planID)
{
$planID = (int)$planID;
$oldPlan = $this->getByID($planID);
if($oldPlan->parent > 0)
{
$parentPlan = $this->getByID($oldPlan->parent);
$parentChange = false;
}
$plan = fixer::input('post')
->add('status', 'doing')
->stripTags($this->config->productplan->editor->start['id'], $this->config->allowedTags)
->remove('uid')
->get();
if($status == 'doing' and !empty($_POST))
{
$plan = fixer::input('post')
->add('status', $status)
->stripTags($this->config->productplan->editor->start['id'], $this->config->allowedTags)
->remove('uid')
->get();
$this->checkDate4Plan($oldPlan, $plan->begin, $plan->end);
if(dao::isError()) return false;
$this->checkDate4Plan($oldPlan, $plan->begin, $plan->end);
if(dao::isError()) return false;
$plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->start['id'], $this->post->uid);
$plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->start['id'], $this->post->uid);
$this->dao->update(TABLE_PRODUCTPLAN)
->data($plan)
->autoCheck()
->batchCheck($this->config->productplan->start->requiredFields, 'notempty')
->checkIF(!empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
->where('id')->eq($planID)
->exec();
$this->file->updateObjectID($this->post->uid, $planID, 'productplan');
if(isset($parentPlan) and $parentPlan->status != 'doing')
{
$this->dao->update(TABLE_PRODUCTPLAN)->set('status')->eq($status)->where('id')->eq($oldPlan->parent)->exec();
$parentChange = true;
}
}
elseif($status == 'doing' and isset($parentPlan) and $parentPlan->status != 'doing')
{
$this->dao->update(TABLE_PRODUCTPLAN)
->set('`status`')->eq($status)
->where('id')->eq($planID)
->orWhere('id')->eq($oldPlan->parent)
->exec();
if($parentPlan->status != 'doing') $parentChange = true;
}
elseif($status == 'done' and isset($parentPlan))
{
$parentDone = true;
$childPlans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($oldPlan->parent)->andWhere('deleted')->eq(0)->fetchAll();
foreach($childPlans as $childPlan )
{
if(in_array($childPlan->status, array('wait', 'doing')) and $planID != $childPlan->id)
{
$parentDone = false;
break;
}
}
if($parentDone) $parentChange = true;
$this->dao->update(TABLE_PRODUCTPLAN)
->set('`status`')->eq($status)
->where('id')->eq($planID)
->beginIF($parentDone)->orWhere('id')->eq($oldPlan->parent)->fi()
->exec();
}
elseif($status == 'closed' and isset($parentPlan))
{
$parentClosed = true;
$childPlans = $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($oldPlan->parent)->andWhere('deleted')->eq(0)->fetchAll();
foreach($childPlans as $childPlan)
{
if(in_array($childPlan->status, array('wait', 'doing', 'done')) and $planID != $childPlan->id)
{
$parentClosed = false;
break;
}
}
if($parentClosed) $parentChange = true;
$this->dao->update(TABLE_PRODUCTPLAN)
->set('`status`')->eq($status)
->where('id')->eq($planID)
->beginIF($parentClosed)->orWhere('id')->eq($oldPlan->parent)->fi()
->exec();
}
else
{
$this->dao->update(TABLE_PRODUCTPLAN)
->set('`status`')->eq($status)
->where('id')->eq($planID)
->exec();
}
$this->dao->update(TABLE_PRODUCTPLAN)
->data($plan)
->autoCheck()
->batchCheck($this->config->productplan->start->requiredFields, 'notempty')
->checkIF(!empty($plan->begin) and !empty($plan->end), 'end', 'ge', $plan->begin)
->where('id')->eq($planID)
->exec();
if(dao::isError()) return false;
if(!isset($plan)) $plan = $this->getByID($planID);
if(!dao::isError())
if($oldPlan->parent > 0) $this->updateParentStatus($oldPlan->parent, 'started');
$this->file->updateObjectID($this->post->uid, $planID, 'productplan');
return common::createChanges($oldPlan, $plan);
}
/**
* Update a plan's status.
*
* @param int $planID
* @param string $status doing|done|closed
* @param string $action started|finished|closed|activated
* @access public
* @return array
*/
public function updateStatus($planID, $status = '', $action = '')
{
$oldPlan = $this->getByID($planID);
$plan = new stdclass();
$plan->status = $status;
$this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->where('id')->eq($planID)->exec();
if(dao::isError()) return false;
$changes = common::createChanges($oldPlan, $plan);
$actionID = $this->loadModel('action')->create('productplan', $planID, $action);
$this->action->logHistory($actionID, $changes);
if($oldPlan->parent > 0) $this->updateParentStatus($oldPlan->parent, $action);
return !dao::isError();
}
/**
* Update a parent plan's status.
*
* @param int $parentID
* @param string $action started|finished|closed|activated
* @access public
* @return void
*/
public function updateParentStatus($parentID, $action)
{
$parent = $this->getByID($parentID);
$childStatus = $this->dao->select('status')->from(TABLE_PRODUCTPLAN)->where('parent')->eq($parentID)->andWhere('deleted')->eq(0)->fetchPairs();
switch($action)
{
$method = $this->app->rawMethod;
if($method == 'start')
{
$action = 'started';
if(isset($parentChange) and $parentChange) $parentAction = 'startedbychild';
}
elseif($method == 'finish')
{
$action = 'finished';
if(isset($parentChange) and $parentChange) $parentAction = 'finishedbychild';
}
elseif($method == 'close')
{
$action = 'closed';
if(isset($parentChange) and $parentChange) $parentAction = 'closedbychild';
}
elseif($method == 'activate')
{
$action = 'activated';
if(isset($parentChange) and $parentChange) $parentAction = 'activatedbychild';
}
if(isset($action))
{
$changes = common::createChanges($oldPlan, $plan);
$actionID = $this->loadModel('action')->create('productplan', $planID, $action);
$this->action->loghistory($actionID, $changes);
if(isset($parentChange) and $parentChange) $actionID = $this->action->create('productplan', $oldPlan->parent, $parentAction, '', $parentAction);
}
case 'started':
$parentStatus = 'doing';
$parentAction = $parent->status != 'doing' ? 'startedbychild' : '';
break;
case 'finished':
if(count($childStatus) == 1 and $parent->status != 'done')
{
$parentStatus = 'done';
$parentAction = 'finishedbychild';
}
break;
case 'closed':
if(count($childStatus) == 1 and $parent->status != 'closed')
{
$parentAction = 'closedbychild';
$parentStatus = 'closed';
}
break;
case 'activated':
$parentStatus = 'doing';
$parentAction = $parent->status != 'doing' ? 'activatedbychild' : '';
break;
}
if(isset($parentStatus)) $this->dao->update(TABLE_PRODUCTPLAN)->set('status')->eq($parentStatus)->where('id')->eq($parentID)->exec();
if(isset($parentAction)) $this->loadModel('action')->create('productplan', $parentID, $parentAction, '', $parentAction);
return !dao::isError();
}
/**
@@ -78,7 +78,6 @@
</thead>
<tbody>
<?php $this->loadModel('file');?>
<?php $today = date('Y-m-d');?>
<?php foreach($plans as $plan):?>
<?php
$canBeChanged = common::canBeChanged('plan', $plan);
@@ -115,7 +114,7 @@
<?php
$class = '';
$expired = '';
if($plan->end < $today and in_array($plan->status, array('wait', 'doing')))
if($plan->expired and in_array($plan->status, array('wait', 'doing')))
{
$class .= ' expired';
$expired = "<span class='label label-danger label-badge'>{$this->lang->productplan->expired}</span>";
@@ -159,12 +158,13 @@
$attr = "data-id='{$plan->id}' data-width='550px'";
$isOnlyBody = true;
}
common::printIcon('productplan', 'start', "planID=$plan->id", $plan, 'list', 'play', '', $class, $isOnlyBody);
common::printIcon('productplan', 'start', "planID=$plan->id", $plan, 'list', 'play', '', $class, $isOnlyBody, $attr);
common::printIcon('productplan', 'finish', "planID=$plan->id", $plan, 'list', 'checked', '', $class, false, $attr);
common::printIcon('productplan', 'close', "planID=$plan->id", $plan, 'list', 'off', '', $class, false, $attr);
}
$attr = $plan->expired ? "disabled='disabled'" : '';
$attr = $plan->expired ? "disabled='disabled'" : '';
$disabled = '';
if(common::hasPriv('execution', 'create', $plan) and $plan->parent >= 0)
{
$disabled = '';
@@ -191,13 +191,13 @@
common::printIcon('productplan', 'edit', "planID=$plan->id", $plan, 'list');
if(common::hasPriv('productplan', 'create', $plan))
{
if($plan->parent > 0 or in_array($plan->status, array('done', 'closed')))
if($plan->parent > 0)
{
echo "<button type='button' class='disabled btn'><i class='disabled icon-split' title='{$this->lang->productplan->children}'></i></button> ";
}
else
{
echo html::a($this->createLink('productplan', 'create', "product=$productID&branch=$branch&parent={$plan->id}"), "<i class='icon-split'></i>", '', "class='btn' title='{$this->lang->productplan->children}'");
echo html::a($this->createLink('productplan', 'create', "product=$productID&branch=$branch&parent={$plan->id}"), "<i class='icon-split'></i>", '', "class='btn {$disabled}' title='{$this->lang->productplan->children}'");
}
}
+1 -1
View File
@@ -63,7 +63,7 @@
common::printLink('productplan', 'activate', "planID=$plan->id", "<i class='icon-magic'></i>{$lang->productplan->activateAB}", '', "class='btn btn-link {$class}' target='hiddenwin' title='{$lang->productplan->activate}'", '', false, $plan);
}
$class = in_array($plan->status, array('done', 'closed')) ? 'disabled' : '';
$class= (isset($branchStatus) and $branchStatus == 'closed') ? 'disabled' : '';
if(common::hasPriv('productplan', 'create', $plan) and $plan->parent <= 0) echo html::a($this->createLink('productplan', 'create', "product={$plan->product}&branch={$plan->branch}&parent={$plan->id}"), "<i class='icon-split'></i> " . $this->lang->productplan->children , '', "class='btn btn-link {$class}' title='{$this->lang->productplan->children}'");
if(common::hasPriv('productplan', 'edit', $plan)) echo html::a($this->createLink('productplan', 'edit', "planID=$plan->id"), "<i class='icon-common-edit icon-edit'></i> " . $this->lang->edit, '', "class='btn btn-link' title='{$this->lang->edit}'");
if(common::hasPriv('productplan', 'delete', $plan) and $plan->parent >= 0) echo html::a($this->createLink('productplan', 'delete', "planID=$plan->id"), "<i class='icon-common-delete icon-trash'></i> " . $this->lang->delete, '', "class='btn btn-link' title='{$this->lang->delete}' target='hiddenwin'");