diff --git a/module/action/config.php b/module/action/config.php index 58d0f4a69c..a032f196ab 100755 --- a/module/action/config.php +++ b/module/action/config.php @@ -46,5 +46,5 @@ $config->action->majorList['project'] = array('opened', 'edited'); $config->action->majorList['execution'] = array('opened', 'edited'); $config->action->needGetProjectType = 'build,task,bug,case,testcase,caselib,testtask,testsuite,testreport,doc,issue,release,risk,design,opportunity,trainplan,gapanalysis,researchplan,researchreport,'; -$config->action->needGetRelateField = ',story,productplan,release,task,build,bug,case,testtask,testreport,doc,doclib,issue,risk,opportunity,trainplan,gapanalysis,team,whitelist,researchplan,researchreport,meeting,'; +$config->action->needGetRelateField = ',story,productplan,release,task,build,bug,case,testtask,testreport,doc,doclib,issue,risk,opportunity,trainplan,gapanalysis,team,whitelist,researchplan,researchreport,meeting,branch,'; $config->action->noLinkModules = ',doclib,module,webhook,gitlab,pipeline,jenkins,'; diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 65c117cd60..8962c2c22d 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -506,6 +506,7 @@ $lang->action->label->issue = 'Issue|issue|view|issueID=%s'; $lang->action->label->design = 'Design|design|view|designID=%s'; $lang->action->label->stakeholder = 'Stakeholder|stakeholder|view|userID=%s'; $lang->action->label->api = 'Interface|api|index|libID=%s&moduleID=%s&apiID=%s'; +$lang->action->label->branch = 'Branch|branch|manage|prouctID=%s'; /* Object type. */ $lang->action->search = new stdclass(); diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index b957726aae..7f8632dd35 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -506,6 +506,7 @@ $lang->action->label->issue = '问题|issue|view|issueID=%s'; $lang->action->label->design = '设计|design|view|designID=%s'; $lang->action->label->stakeholder = '干系人|stakeholder|view|userID=%s'; $lang->action->label->api = '接口|api|index|libID=%s&moduleID=%s&apiID=%s'; +$lang->action->label->branch = '分支|branch|manage|productID=%s'; /* Object type. */ $lang->action->search = new stdclass(); diff --git a/module/action/lang/zh-tw.php b/module/action/lang/zh-tw.php index 2d10a38721..b7a7bd390e 100755 --- a/module/action/lang/zh-tw.php +++ b/module/action/lang/zh-tw.php @@ -506,6 +506,7 @@ $lang->action->label->issue = '問題|issue|view|issueID=%s'; $lang->action->label->design = '設計|design|view|designID=%s'; $lang->action->label->stakeholder = '干係人|stakeholder|view|userID=%s'; $lang->action->label->api = '介面|api|index|libID=%s&moduleID=%s&apiID=%s'; +$lang->action->label->branch = '分支|branch|manage|productID=%s'; /* Object type. */ $lang->action->search = new stdclass(); diff --git a/module/action/model.php b/module/action/model.php index 7a18b7d1db..e867ba5d54 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -188,7 +188,7 @@ class actionModel extends model /* Set fields to fetch. */ $fields = '*'; - if(strpos('story, productplan, case', $objectType) !== false) $fields = 'product'; + if(strpos('story, productplan, case, branch', $objectType) !== false) $fields = 'product'; if(strpos('build, bug, testtask, doc', $objectType) !== false) $fields = 'product, project, execution'; if(strpos('case, repo', $objectType) !== false) $fields = 'execution'; if($objectType == 'release') $fields = 'product, build'; @@ -1177,6 +1177,11 @@ class actionModel extends model $api = $this->dao->select('id,lib,module')->from(TABLE_API)->where('id')->eq($action->objectID)->fetch(); $params = sprintf($vars, $api->lib, $api->module, $api->id); } + elseif($action->objectType == 'branch') + { + $productID = $this->dao->select('product')->from(TABLE_BRANCH)->where('id')->eq($action->objectID)->fetch('product'); + $params = sprintf($vars, $productID); + } else { $params = sprintf($vars, $action->objectID); diff --git a/module/branch/control.php b/module/branch/control.php index 7e48fcb47e..9eaf7de5b3 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -53,7 +53,11 @@ class branch extends control { if($_POST) { - $this->branch->create($productID); + $branchID = $this->branch->create($productID); + if(dao::isError()) die(js::error(dao::getError())); + + $this->loadModel('action')->create('branch', $branchID, 'Opened'); + die(js::reload('parent.parent')); } $this->display(); diff --git a/module/branch/model.php b/module/branch/model.php index b10d39905b..603298ea41 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -128,18 +128,25 @@ class branchModel extends model * * @param int $productID * @access public - * @return void + * @return int|bool */ public function create($productID) { $branch = fixer::input('post') - ->setDefault('product', $productID) - ->setDefault('createdDate', helper::today()) - ->setDefault('status', 'active') + ->add('product', $productID) + ->add('createdDate', helper::today()) + ->add('status', 'active') ->get(); - $this->dao->insert(TABLE_BRANCH)->data($branch)->exec(); - if(dao::isError()) return false; + $lastOrder = (int)$this->dao->select('`order`')->from(TABLE_BRANCH)->where('product')->eq($productID)->orderBy('order_desc')->limit(1)->fetch('order'); + $branch->order = empty($lastOrder) ? 1 : $lastOrder + 1; + + $this->dao->insert(TABLE_BRANCH)->data($branch) + ->batchCheck($this->config->branch->create->requiredFields, 'notempty') + ->exec(); + + if(!dao::isError()) return $this->dao->lastInsertID(); + return false; } /** diff --git a/module/branch/view/create.html.php b/module/branch/view/create.html.php index f20a620db9..db3a449ecc 100644 --- a/module/branch/view/create.html.php +++ b/module/branch/view/create.html.php @@ -26,9 +26,7 @@ - - - + diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 28f1996d28..9b2024adc3 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -421,12 +421,14 @@ $lang->product->methodOrder[105] = 'unbindWhitelist'; /* Branch. */ $lang->resource->branch = new stdclass(); $lang->resource->branch->manage = 'manage'; +$lang->resource->branch->create = 'create'; $lang->resource->branch->sort = 'sort'; $lang->resource->branch->delete = 'delete'; $lang->branch->methodOrder[0] = 'manage'; -$lang->branch->methodOrder[5] = 'sort'; -$lang->branch->methodOrder[10] = 'delete'; +$lang->branch->methodOrder[5] = 'create'; +$lang->branch->methodOrder[10] = 'sort'; +$lang->branch->methodOrder[15] = 'delete'; /* Story. */ $lang->resource->story = new stdclass();