diff --git a/module/execution/control.php b/module/execution/control.php index d215edae8c..4afc3e895a 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1498,6 +1498,7 @@ class execution extends control } } + $this->app->loadLang('kanban'); $this->loadModel('user'); $poUsers = $this->user->getPairs('noclosed|nodeleted|pofirst', '', $this->config->maxCount); if(!empty($this->config->user->moreLink)) $this->config->moreLinks["PM"] = $this->config->user->moreLink; @@ -1700,6 +1701,7 @@ class execution extends control } $this->loadModel('user'); + $this->loadModel('kanban'); $poUsers = $this->user->getPairs('noclosed|nodeleted|pofirst', $execution->PO, $this->config->maxCount); if(!empty($this->config->user->moreLink)) $this->config->moreLinks["PM"] = $this->config->user->moreLink; @@ -1737,6 +1739,11 @@ class execution extends control $this->view->branchGroups = $this->execution->getBranchByProduct(array_keys($linkedProducts), $this->config->systemMode == 'new' ? $execution->project : 0, 'noclosed', $linkedBranchList); $this->view->teamMembers = $this->execution->getTeamMembers($executionID); if($this->config->systemMode == 'new') $this->view->allProjects = $this->project->getPairsByModel($project->model, 0, 'noclosed', $project->id); + + $this->view->laneCount = $this->kanban->getLaneCount($executionID, $execution->model); + $this->view->heightType = $execution->displayCards > 2 ? 'custom' : 'auto'; + $this->view->displayCards = $execution->displayCards ? $execution->displayCards : ''; + $this->display(); } diff --git a/module/execution/js/common.js b/module/execution/js/common.js index c1b03f5afa..8cb9bdc54c 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -274,3 +274,15 @@ $(function() adjustProductBoxMargin(); adjustPlanBoxMargin(); }); + +/** + * Set card count. + * + * @param string $heightType + * @access public + * @return void + */ +function setCardCount(heightType) +{ + heightType != 'custom' ? $('#cardBox').addClass('hidden') : $('#cardBox').removeClass('hidden'); +} diff --git a/module/execution/js/create.js b/module/execution/js/create.js index ae1df4888e..ea25bddc48 100644 --- a/module/execution/js/create.js +++ b/module/execution/js/create.js @@ -5,6 +5,9 @@ function setCopyProject(executionID) $(function() { + var heightType = $("[name='heightType']:checked").val(); + setCardCount(heightType); + $('#copyProjects a').click(function(){setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')}); $('#begin').on('change', function() { diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index 4d83a62253..d650459b98 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -37,6 +37,9 @@ $().ready(function() $(function() { + var heightType = $("[name='heightType']:checked").val(); + setCardCount(heightType); + /* If the story of the product which linked the execution under the project, you don't allow to remove the product. */ $("#productsBox select[name^='products']").each(function() { diff --git a/module/execution/model.php b/module/execution/model.php index 472d562746..6787b74c93 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -333,15 +333,27 @@ class executionModel extends model ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) ->setDefault('team', substr($this->post->name, 0, 30)) + ->setDefault('displayCards', 0) + ->setIF($this->post->heightType == 'auto', 'displayCards', 0) ->setIF(!isset($_POST['whitelist']), 'whitelist', '') ->setIF($this->config->systemMode == 'new', 'parent', $this->post->project) ->setIF($this->post->acl == 'open', 'whitelist', '') ->join('whitelist', ',') ->setDefault('type', $type) ->stripTags($this->config->execution->editor->create['id'], $this->config->allowedTags) - ->remove('products, workDays, delta, branch, uid, plans, teams, teamMembers, contactListMenu') + ->remove('products, workDays, delta, branch, uid, plans, teams, teamMembers, contactListMenu, heightType') ->get(); + if(isset($_POST['heightType']) and $this->post->heightType == 'custom') + { + if(!preg_match("/^-?\d+$/", $sprint->displayCards) or $sprint->displayCards < 3) + { + $this->app->loadLang('kanban'); + dao::$errors['displayCards'] = $this->lang->kanbanlane->error->mustBeInt; + return false; + } + } + /* Check the workload format and total. */ if(!empty($sprint->percent)) $this->checkWorkload('create', $sprint->percent); @@ -475,6 +487,8 @@ class executionModel extends model ->add('id', $executionID) ->setDefault('lastEditedBy', $this->app->user->account) ->setDefault('lastEditedDate', helper::now()) + ->setDefault('displayCards', 0) + ->setIF($this->post->heightType == 'auto', 'displayCards', 0) ->setIF(helper::isZeroDate($this->post->begin), 'begin', '') ->setIF(helper::isZeroDate($this->post->end), 'end', '') ->setIF(!isset($_POST['whitelist']), 'whitelist', '') @@ -483,9 +497,19 @@ class executionModel extends model ->setDefault('team', $this->post->name) ->join('whitelist', ',') ->stripTags($this->config->execution->editor->edit['id'], $this->config->allowedTags) - ->remove('products, branch, uid, plans, syncStories, contactListMenu, teamMembers') + ->remove('products, branch, uid, plans, syncStories, contactListMenu, teamMembers, heightType') ->get(); + if(isset($_POST['heightType']) and $this->post->heightType == 'custom') + { + if(!preg_match("/^-?\d+$/", $sprint->displayCards) or $sprint->displayCards < 3) + { + $this->app->loadLang('kanban'); + dao::$errors['displayCards'] = $this->lang->kanbanlane->error->mustBeInt; + return false; + } + } + if(in_array($execution->status, array('closed', 'suspended'))) $this->computeBurn($executionID); if($this->config->systemMode == 'new' and (empty($execution->project) or $execution->project == $oldExecution->project)) $this->checkBeginAndEndDate($oldExecution->project, $execution->begin, $execution->end); diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index a38a8e0500..b70e69b8de 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -219,6 +219,18 @@ execution->team;?> + + kanban->columnWidth;?> + kanbancolumn->fluidBoardList, 0));?> + + + kanban->laneHeight;?> + kanbanlane->heightTypeList, 'auto', "onclick='setCardCount(this.value);'"));?> + + + kanban->cardCount;?> + kanban->cardCountTip}' autocomplete='off'");?> + execution->execDesc : $lang->execution->desc;?> diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 6106f73c6d..5bdbe1ba99 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -193,6 +193,20 @@ execution->team;?> + + kanban->columnWidth;?> + kanbancolumn->fluidBoardList, $execution->fluidBoard));?> + + 1):?> + + kanban->laneHeight;?> + kanbanlane->heightTypeList, $heightType, "onclick='setCardCount(this.value);'"));?> + + + kanban->cardCount;?> + kanban->cardCountTip}' autocomplete='off'");?> + + execution->desc;?> desc), "rows='6' class='form-control kindeditor' hidefocus='true'");?> diff --git a/module/kanban/model.php b/module/kanban/model.php index 5cf84833c6..a875552cf6 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -2127,6 +2127,7 @@ class kanbanModel extends model ->setDefault('lastEditedDate', helper::now()) ->setDefault('displayCards', 0) ->setIF($this->post->import == 'off', 'object', '') + ->setIF($this->post->heightType == 'auto', 'displayCards', 0) ->join('whitelist', ',') ->join('team', ',') ->trim('name') @@ -3863,13 +3864,23 @@ class kanbanModel extends model */ public function getLaneCount($kanbanID, $type = 'common') { - return $this->dao->select('COUNT(t2.id) as count')->from(TABLE_KANBANREGION)->alias('t1') - ->leftJoin(TABLE_KANBANLANE)->alias('t2')->on('t1.id=t2.region') - ->where('t1.kanban')->eq($kanbanID) - ->andWhere('t1.deleted')->eq(0) - ->andWhere('t2.deleted')->eq(0) - ->beginIF($type == 'common')->andWhere('t2.type')->eq('common')->fi() - ->beginIF($type != 'common')->andWhere('t2.type')->ne('common')->fi() - ->fetch('count'); + if($type == 'common ' or $type == 'kanban') + { + return $this->dao->select('COUNT(t2.id) as count')->from(TABLE_KANBANREGION)->alias('t1') + ->leftJoin(TABLE_KANBANLANE)->alias('t2')->on('t1.id=t2.region') + ->where('t1.kanban')->eq($kanbanID) + ->andWhere('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->beginIF($type == 'common')->andWhere('t2.type')->eq('common')->fi() + ->beginIF($type != 'common')->andWhere('t2.type')->ne('common')->fi() + ->fetch('count'); + } + else + { + return $this->dao->select('COUNT(id) as count')->from(TABLE_KANBANLANE) + ->where('execution')->eq($kanbanID) + ->andWhere('deleted')->eq(0) + ->fetch('count'); + } } }