diff --git a/module/kanban/control.php b/module/kanban/control.php index 752d7cf2a5..389721337a 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -232,8 +232,9 @@ class kanban extends control if($_POST) { - $order = $position == 'left' ? $column->order : $column->order + 1; - $this->kanban->createColumn($column->region, null, $order); + $order = $position == 'left' ? $column->order : $column->order + 1; + $columnID = $this->kanban->createColumn($column->region, null, $order); + $this->loadModel('action')->create('kanbanColumn', $columnID, 'Created'); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent', 'callback' => 'closeModalAndUpdateKanban', 'callback_params' => $column->region)); diff --git a/module/kanban/js/createcolumn.js b/module/kanban/js/createcolumn.js index b2c16db86b..1752625ded 100644 --- a/module/kanban/js/createcolumn.js +++ b/module/kanban/js/createcolumn.js @@ -1,27 +1,24 @@ -$(document).ready(function() +$(function() { - $.setAjaxForm('#createColumnForm'); - initColorPicker(); - - $(document).on('click', '#noLimit', function() - { - if($(this).prop('checked')) - { - $(this).parents('td').find('input[name^=limit]').val(''); - $(this).parents('td').find('input[name^=limit]').attr('readonly', true); - } + $('#noLimit').click(function() + { + if($(this).attr('checked') == 'checked') + { + $('#WIPCount').val(''); + $('#WIPCount').attr('disabled', true); + } else - { - $(this).parents('td').find('input[name^=limit]').removeAttr('readonly'); - } - }); -}); + { + $('#WIPCount').removeAttr('disabled'); + } + }) +}) function setWIPLimit() { var count = $('#WIPCount').val(); - if($('#noLimit').attr('checked') == 'checked') count = -1;; + if($('#noLimit').attr('checked') == 'checked') count = -1; $('#limit').val(count); } diff --git a/module/kanban/model.php b/module/kanban/model.php index 8ae6f39666..34818c2514 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -209,6 +209,7 @@ class kanbanModel extends model ->add('region', $regionID) ->setIF($order, 'order', $order) ->setDefault('color', '#272E33') + ->remove('WIPCount,noLimit') ->get(); if(!$order) { @@ -220,9 +221,16 @@ class kanbanModel extends model } if(!$column->limit && empty($column->noLimit)) dao::$errors['limit'][] = sprintf($this->lang->error->notempty, $this->lang->kanban->WIP); + if(!preg_match("/^-?\d+$/", $column->limit)) + { + dao::$errors['limit'] = $this->lang->kanban->error->mustBeInt; + return false; + } if(dao::isError()) return false; - $limit = (int)$column->limit; + $column->limit = (int)$column->limit; + + $limit = $column->limit; if(!empty($column->parent)) { /* Create a child column. */ @@ -250,8 +258,6 @@ class kanbanModel extends model } } - $column->limit = (int)$column->limit; - if($order) { /* It means copy a column or insert a column before or after a column. */ @@ -273,8 +279,6 @@ class kanbanModel extends model $maxType = $this->dao->select('type')->from(TABLE_KANBANCOLUMN)->where('`group`')->eq($column->group)->orderBy('type_desc')->limit(1)->fetch('type'); $this->dao->update(TABLE_KANBANCOLUMN)->set('type')->eq($maxType + 1)->where('id')->eq($columnID)->exec(); - $this->loadModel('action')->create('kanbanColumn', $columnID, 'Created'); - return $columnID; } @@ -679,7 +683,7 @@ class kanbanModel extends model { $table = $this->config->objectTables[$objectType]; $objects = $this->dao->select('*')->from($table)->fetchAll('id'); - $spaceOwnerPairs = $this->dao->select('id,owner')->from(TABLE_KANBANSPACE)->fetchPairs(); + $spaceOwnerPairs = $objectType == 'kanban' ? $this->dao->select('id,owner')->from(TABLE_KANBANSPACE)->fetchPairs() : array(); if($this->app->user->admin) return array_keys($objects); diff --git a/module/kanban/view/createcolumn.html.php b/module/kanban/view/createcolumn.html.php index 2b10d66090..96c40056ea 100644 --- a/module/kanban/view/createcolumn.html.php +++ b/module/kanban/view/createcolumn.html.php @@ -30,10 +30,11 @@
- limit ? '' : "readonly"));?> + limit != -1 ? $column->limit : '', "class='form-control'" . ($column->limit > 0 ? '' : "disabled"));?> + limit, "class='form-control'");?>