diff --git a/module/kanban/control.php b/module/kanban/control.php index ab43874dc2..51302e7071 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -447,6 +447,13 @@ class kanban extends control */ public function splitColumn($columnID) { + if(!empty($_POST['name'])) + { + $this->kanban->splitColumn($columnID); + if(dao::isError()) $this->send(array('message' => dao::getError(), 'result' => 'fail')); + $this->send(array('message' => $this->lang->saveSuccess, 'result' => 'success', 'locate' => 'parent')); + } + $this->display(); } diff --git a/module/kanban/js/splitcolumn.js b/module/kanban/js/splitcolumn.js index ab1bf6adf8..068d6de8ab 100644 --- a/module/kanban/js/splitcolumn.js +++ b/module/kanban/js/splitcolumn.js @@ -1,29 +1,27 @@ -$(function() +$(document).on('click', "[id^='noLimit']", function() { - $("[id^='noLimit']").click(function() + var index = $(this).attr('id').slice(7); + if($(this).attr('checked') == 'checked') { - var index = $(this).attr('id').slice(7); - if($(this).attr('checked') == 'checked') - { - $('#WIPCount' + index).val(''); - $('#WIPCount' + index).attr('disabled', true); - } - else - { - $('#WIPCount' + index).removeAttr('disabled'); - } - }); -}) + $('#WIPCount' + index).val(''); + $('#WIPCount' + index).attr('disabled', true); + } + else + { + $('#WIPCount' + index).removeAttr('disabled'); + } +}); function addItem(obj) { var item = $('#addItem').html().replace(/%i%/g, i); $(obj).closest('tr').after('' + item + ''); - i ++; + i++; } function deleteItem(obj) { + if($('#columnForm .table tbody').children('tr').length < 4) return false; $(obj).closest('tr').remove(); } diff --git a/module/kanban/model.php b/module/kanban/model.php index 68801de276..bb3657a82b 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -310,6 +310,69 @@ class kanbanModel extends model return $columnID; } + /** + * Split column. + * + * @param int $columnID + * @access public + * @return void + */ + public function splitColumn($columnID) + { + $this->loadModel('action'); + $data = fixer::input('post')->get(); + $column = $this->getColumnByID($columnID); + $maxOrder = $this->dao->select('MAX(`order`) AS maxOrder')->from(TABLE_KANBANCOLUMN)->where('`group`')->eq($column->group)->fetch('maxOrder'); + $order = $maxOrder + 1; + $sumChildLimit = $this->dao->select('SUM(`limit`) AS sumChildLimit')->from(TABLE_KANBANCOLUMN)->where('parent')->eq($columnID)->fetch('sumChildLimit'); + + $childrenColumn = array(); + foreach($data->name as $i => $name) + { + $childColumn = new stdclass(); + $childColumn->lane = $column->lane; + $childColumn->parent = $column->id; + $childColumn->region = $column->region; + $childColumn->group = $column->group; + $childColumn->name = $name; + $childColumn->color = $data->color[$i]; + $childColumn->limit = isset($data->noLimit[$i]) ? -1 : $data->WIPCount[$i]; + $childColumn->order = $order; + + if(!preg_match("/^-?\d+$/", $childColumn->limit) or (!isset($data->noLimit[$i]) and $childColumn->limit <= 0)) + { + dao::$errors['limit'] = $this->lang->kanban->error->mustBeInt; + return false; + } + + $sumChildLimit += $childColumn->limit; + if($column->limit != -1 and ($childColumn->limit == -1 or ($column->limit < $sumChildLimit))) + { + dao::$errors['limit'] = $this->lang->kanban->error->parentLimitNote; + return false; + } + + $order ++; + $childrenColumn[$i] = $childColumn; + } + + foreach($childrenColumn as $i => $childColumn) + { + $this->dao->insert(TABLE_KANBANCOLUMN)->data($childColumn) + ->autoCheck() + ->batchCheck($this->config->kanban->splitcolumn->requiredFields, 'notempty') + ->exec(); + + if(dao::isError()) return false; + if(!dao::isError()) + { + $childColumnID = $this->dao->lastInsertID(); + $this->dao->update(TABLE_KANBANCOLUMN)->set('type')->eq("column{$childColumnID}")->where('id')->eq($childColumnID)->exec(); + $this->action->create('kanbanColumn', $childColumnID, 'created'); + } + } + } + /** * Create a kanban card. * diff --git a/module/kanban/view/space.html.php b/module/kanban/view/space.html.php index ccb900c5da..22e736eae5 100644 --- a/module/kanban/view/space.html.php +++ b/module/kanban/view/space.html.php @@ -91,7 +91,7 @@ 3):?> - …';?> + 4) echo '…';?>
$usersAvatar[end($teamPairs)], 'account' => $member)); ?>
diff --git a/module/kanban/view/splitcolumn.html.php b/module/kanban/view/splitcolumn.html.php index 6deef102fe..ac4503aab6 100644 --- a/module/kanban/view/splitcolumn.html.php +++ b/module/kanban/view/splitcolumn.html.php @@ -16,15 +16,15 @@

kanban->splitColumn;?>

-
+ - + - + +
kanbancolumn->childName;?> kanbancolumn->childColor;?> kanban->WIPCount;?>
@@ -33,7 +33,7 @@
- +
@@ -55,7 +55,7 @@
- +
@@ -66,6 +66,7 @@
@@ -94,7 +95,7 @@
- +
diff --git a/module/project/view/browsebycard.html.php b/module/project/view/browsebycard.html.php index a71c16e9ec..57e22c4437 100644 --- a/module/project/view/browsebycard.html.php +++ b/module/project/view/browsebycard.html.php @@ -162,7 +162,7 @@ teamCount > 3):?> - …';?> + teamCount > 4) echo '…';?> ' title=""> $usersAvatar[end($project->teamMembers)], 'account' => $member)); ?>