* Finish task #43519.

This commit is contained in:
liyuchun
2021-10-28 13:06:12 +08:00
parent 6a8f69b524
commit 31a12238ee
3 changed files with 68 additions and 14 deletions
+18 -10
View File
@@ -1,16 +1,24 @@
<?php
$lang->kanban = new stdClass();
$lang->kanban->WIP = 'WIP';
$lang->kanban->setWIP = 'WIP Settings';
$lang->kanban->WIPStatus = 'WIP Status';
$lang->kanban->WIPStage = 'WIP Stage';
$lang->kanban->WIPType = 'WIP Type';
$lang->kanban->WIPCount = 'WIP Count';
$lang->kanban->noLimit = 'No Limit ∞';
$lang->kanban->setLane = 'Lane Settings';
$lang->kanban->laneName = 'Lane Name';
$lang->kanban->laneColor = 'Lane Color';
$lang->kanban->WIP = 'WIP';
$lang->kanban->setWIP = 'WIP Settings';
$lang->kanban->WIPStatus = 'WIP Status';
$lang->kanban->WIPStage = 'WIP Stage';
$lang->kanban->WIPType = 'WIP Type';
$lang->kanban->WIPCount = 'WIP Count';
$lang->kanban->noLimit = 'No Limit ∞';
$lang->kanban->setLane = 'Lane Settings';
$lang->kanban->laneName = 'Lane Name';
$lang->kanban->laneColor = 'Lane Color';
$lang->kanban->setLaneColumn = 'Column Settings';
$lang->kanban->columnName = 'Column Name';
$lang->kanban->columnColor = 'Column Color';
$lang->kanban->noColumnUniqueName = 'The Kanban column name already exists.';
$lang->kanban->error = new stdclass();
$lang->kanban->error->parentLimitNote = 'The WIPs in the parent column cannot be < the sum of the WIPs in the child column.';
$lang->kanban->error->childLimitNote = 'The sum of products in the child column cannot be > the number of products in the parent column.';
$this->lang->kanban->laneTypeList = array();
$this->lang->kanban->laneTypeList['story'] = $lang->SRCommon;
+4
View File
@@ -16,6 +16,10 @@ $lang->kanban->columnName = '看板列名称';
$lang->kanban->columnColor = '看板列颜色';
$lang->kanban->noColumnUniqueName = '看板列名称已存在。';
$lang->kanban->error = new stdclass();
$lang->kanban->error->parentLimitNote = '父列的在制品数量不能小与子列在制品数量之和。';
$lang->kanban->error->childLimitNote = '子列在制品数量之和不能大于父列的在制品数量。';
$this->lang->kanban->laneTypeList = array();
$this->lang->kanban->laneTypeList['story'] = $lang->SRCommon;
$this->lang->kanban->laneTypeList['bug'] = 'Bug';
+46 -4
View File
@@ -396,15 +396,57 @@ class kanbanModel extends model
*/
public function setWIP($columnID)
{
$column = $this->getColumnById($columnID);
$data = fixer::input('post')
$oldColumn = $this->getColumnById($columnID);
$column = fixer::input('post')
->cleanInt('limit')
->remove('WIPCount,noLimit')
->get();
$this->dao->update(TABLE_KANBANCOLUMN)->data($data)
/* Check column limit. */
$sumChildLimit = 0;
if($oldColumn->parent == -1 and $column->limit != -1)
{
$childColumns = $this->dao->select('id,`limit`')->from(TABLE_KANBANCOLUMN)->where('parent')->eq($columnID)->fetchAll();
foreach($childColumns as $childColumn)
{
if($childColumn->limit == -1)
{
dao::$errors['limit'] = $this->lang->kanban->error->parentLimitNote;
return false;
}
$sumChildLimit += $childColumn->limit;
}
if($sumChildLimit > $column->limit)
{
dao::$errors['limit'] = $this->lang->kanban->error->parentLimitNote;
return false;
}
}
elseif($oldColumn->parent > 0)
{
$parentColumn = $this->getColumnByID($oldColumn->parent);
if($parentColumn->limit != -1)
{
$brotherColumnLimit = $this->dao->select('`limit`')->from(TABLE_KANBANCOLUMN)
->where('`parent`')->eq($oldColumn->parent)
->andWhere('id')->ne($columnID)
->fetch('limit');
$sumChildLimit = $brotherColumnLimit + $column->limit;
if($column->limit == -1 or $brotherColumnLimit == -1 or $sumChildLimit > $parentColumn->limit)
{
dao::$errors['limit'] = $this->lang->kanban->error->childLimitNote;
return false;
}
}
}
$this->dao->update(TABLE_KANBANCOLUMN)->data($column)
->autoCheck()
->checkIF($data->limit != -1, 'limit', 'gt', 0)
->checkIF($column->limit != -1, 'limit', 'gt', 0)
->batchcheck($this->config->kanban->setwip->requiredFields, 'notempty')
->where('id')->eq($columnID)
->exec();