From 988bb5c7740de925b2c4fdc7f2bb747de49106d2 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Fri, 5 Nov 2021 17:25:27 +0800 Subject: [PATCH 1/6] * Code for task#44028. --- module/branch/config.php | 7 ++++++ module/branch/control.php | 17 ++++++++++++++ module/branch/model.php | 23 +++++++++++++++++-- module/branch/view/create.html.php | 36 ++++++++++++++++++++++++++++++ module/branch/view/manage.html.php | 4 ++-- 5 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 module/branch/config.php create mode 100644 module/branch/view/create.html.php diff --git a/module/branch/config.php b/module/branch/config.php new file mode 100644 index 0000000000..2e2bf710e3 --- /dev/null +++ b/module/branch/config.php @@ -0,0 +1,7 @@ +branch = new stdclass(); +$config->branch->create = new stdclass(); +$config->branch->edit = new stdclass(); + +$config->branch->create->requiredFields = 'name'; +$config->branch->edit->requiredFields = 'name'; diff --git a/module/branch/control.php b/module/branch/control.php index e96b1fc105..7e48fcb47e 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -42,6 +42,23 @@ class branch extends control $this->display(); } + /** + * Create a branch. + * + * @param int $productID + * @access public + * @return void + */ + public function create($productID) + { + if($_POST) + { + $this->branch->create($productID); + } + + $this->display(); + } + /** * Sort branch. * diff --git a/module/branch/model.php b/module/branch/model.php index e2a4b000ad..b10d39905b 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -124,11 +124,30 @@ class branchModel extends model } /** - * Manage branch + * Create a branch. * * @param int $productID * @access public - * @return bool + * @return void + */ + public function create($productID) + { + $branch = fixer::input('post') + ->setDefault('product', $productID) + ->setDefault('createdDate', helper::today()) + ->setDefault('status', 'active') + ->get(); + + $this->dao->insert(TABLE_BRANCH)->data($branch)->exec(); + if(dao::isError()) return false; + } + + /** + * Manage branch. + * + * @param int $productID + * @access public + * @return bool|array */ public function manage($productID) { diff --git a/module/branch/view/create.html.php b/module/branch/view/create.html.php new file mode 100644 index 0000000000..f20a620db9 --- /dev/null +++ b/module/branch/view/create.html.php @@ -0,0 +1,36 @@ + + * @package branch + * @version $Id$ + * @link https://www.zentao.net + */ +?> + +
+
+

branch->create;?>

+
+
+ + + + + + + + + + + + +
branch->name;?>
branch->desc;?>
+ +
+
+
+ diff --git a/module/branch/view/manage.html.php b/module/branch/view/manage.html.php index c087c8b364..23b359ee7a 100644 --- a/module/branch/view/manage.html.php +++ b/module/branch/view/manage.html.php @@ -27,7 +27,7 @@
- " . $lang->branch->create, '', "class='btn btn-primary'");?> + " . $lang->branch->create, '', "class='btn btn-primary iframe'", true, true);?>
@@ -35,7 +35,7 @@

branch->noData;?> - createLink('branch', 'create', "productID=$productID"), " " . $lang->branch->create, '', "class='btn btn-info'");?> + createLink('branch', 'create', "productID=$productID", '', true), " " . $lang->branch->create, '', "class='btn btn-info iframe'");?>

From 8f902ccf2db9cffdaf78aee1ede1e5c8a8879833 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Sun, 7 Nov 2021 13:44:24 +0800 Subject: [PATCH 2/6] * Code fot task#44028. --- module/action/config.php | 2 +- module/action/lang/en.php | 1 + module/action/lang/zh-cn.php | 1 + module/action/lang/zh-tw.php | 1 + module/action/model.php | 7 ++++++- module/branch/control.php | 6 +++++- module/branch/model.php | 19 +++++++++++++------ module/branch/view/create.html.php | 4 +--- module/group/lang/resource.php | 6 ++++-- 9 files changed, 33 insertions(+), 14 deletions(-) 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(); From f94e0ecb081a15086c266c1785120ef3ec32f053 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Sun, 7 Nov 2021 16:05:02 +0800 Subject: [PATCH 3/6] * Code for task#44028. --- module/branch/config.php | 2 +- module/branch/control.php | 22 +++++++++++++++++ module/branch/lang/de.php | 8 +++++-- module/branch/lang/en.php | 11 +++++---- module/branch/lang/fr.php | 8 +++++-- module/branch/lang/vi.php | 8 +++++-- module/branch/lang/zh-cn.php | 11 +++++---- module/branch/lang/zh-tw.php | 8 +++++-- module/branch/model.php | 30 ++++++++++++++++++++++- module/branch/view/edit.html.php | 38 ++++++++++++++++++++++++++++++ module/branch/view/manage.html.php | 2 +- module/group/lang/resource.php | 6 +++-- 12 files changed, 131 insertions(+), 23 deletions(-) create mode 100644 module/branch/view/edit.html.php diff --git a/module/branch/config.php b/module/branch/config.php index 2e2bf710e3..6fe739dea0 100644 --- a/module/branch/config.php +++ b/module/branch/config.php @@ -4,4 +4,4 @@ $config->branch->create = new stdclass(); $config->branch->edit = new stdclass(); $config->branch->create->requiredFields = 'name'; -$config->branch->edit->requiredFields = 'name'; +$config->branch->edit->requiredFields = 'name,status'; diff --git a/module/branch/control.php b/module/branch/control.php index 9eaf7de5b3..d372597381 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -63,6 +63,28 @@ class branch extends control $this->display(); } + /** + * Edit a branch. + * + * @param int $branchID + * @access public + * @return void + */ + public function edit($branchID) + { + if($_POST) + { + $changes = $this->branch->update($branchID); + if(dao::isError()) die(js::error(dao::getError())); + + if($changes) $this->loadModel('action')->create('branch', $branchID, 'Edited'); + die(js::reload('parent.parent')); + } + + $this->view->branch = $this->branch->getById($branchID, 0, true); + $this->display(); + } + /** * Sort branch. * diff --git a/module/branch/lang/de.php b/module/branch/lang/de.php index c6f2b3f294..4aa0b38d52 100644 --- a/module/branch/lang/de.php +++ b/module/branch/lang/de.php @@ -9,8 +9,12 @@ $lang->branch->manageTitle = '%s Management'; $lang->branch->all = 'Alle '; $lang->branch->main = 'Main'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->active = 'Active'; +$lang->branch->close = 'Close'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Produkt'; diff --git a/module/branch/lang/en.php b/module/branch/lang/en.php index 53ee04c8c7..009390678c 100644 --- a/module/branch/lang/en.php +++ b/module/branch/lang/en.php @@ -9,11 +9,12 @@ $lang->branch->manageTitle = '%s Management'; $lang->branch->all = 'All '; $lang->branch->main = 'Main'; -$lang->branch->edit = 'Edit'; -$lang->branch->active = 'Active'; -$lang->branch->close = 'Close'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->active = 'Active'; +$lang->branch->close = 'Close'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Product'; diff --git a/module/branch/lang/fr.php b/module/branch/lang/fr.php index 30f348ca2d..8c241acae3 100644 --- a/module/branch/lang/fr.php +++ b/module/branch/lang/fr.php @@ -9,8 +9,12 @@ $lang->branch->manageTitle = 'Gestion %s'; $lang->branch->all = 'Tous'; $lang->branch->main = 'Main'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->active = 'Active'; +$lang->branch->close = 'Close'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Product'; diff --git a/module/branch/lang/vi.php b/module/branch/lang/vi.php index f387b569ad..2a65268681 100644 --- a/module/branch/lang/vi.php +++ b/module/branch/lang/vi.php @@ -9,8 +9,12 @@ $lang->branch->manageTitle = 'Quản lý %s'; $lang->branch->all = 'Tất cả '; $lang->branch->main = 'Main'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->active = 'Active'; +$lang->branch->close = 'Close'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Sản phẩm'; diff --git a/module/branch/lang/zh-cn.php b/module/branch/lang/zh-cn.php index c0066b6be3..d2f3a544d0 100644 --- a/module/branch/lang/zh-cn.php +++ b/module/branch/lang/zh-cn.php @@ -9,11 +9,12 @@ $lang->branch->manageTitle = '%s管理'; $lang->branch->all = '所有'; $lang->branch->main = '主干'; -$lang->branch->edit = '编辑'; -$lang->branch->active = '激活'; -$lang->branch->close = '关闭'; -$lang->branch->create = '新增分支'; -$lang->branch->merge = '合并'; +$lang->branch->edit = '编辑'; +$lang->branch->editAction = '编辑分支'; +$lang->branch->active = '激活'; +$lang->branch->close = '关闭'; +$lang->branch->create = '新增分支'; +$lang->branch->merge = '合并'; $lang->branch->id = 'ID'; $lang->branch->product = '所属产品'; diff --git a/module/branch/lang/zh-tw.php b/module/branch/lang/zh-tw.php index beac1988dc..4b502fe030 100644 --- a/module/branch/lang/zh-tw.php +++ b/module/branch/lang/zh-tw.php @@ -8,8 +8,12 @@ $lang->branch->add = '添加'; $lang->branch->manageTitle = '%s管理'; $lang->branch->all = '所有'; -$lang->branch->create = '新增分支'; -$lang->branch->merge = '合併'; +$lang->branch->edit = '編輯'; +$lang->branch->editAction = '編輯分支'; +$lang->branch->active = '啟動'; +$lang->branch->close = '關閉'; +$lang->branch->create = '新增分支'; +$lang->branch->merge = '合併'; $lang->branch->id = '編號'; $lang->branch->product = '所屬產品'; diff --git a/module/branch/model.php b/module/branch/model.php index 603298ea41..07a21d8d8b 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -15,10 +15,12 @@ class branchModel extends model * Get name by id. * * @param int $branchID + * @param int $productID + * @param bool $queryAll * @access public * @return string */ - public function getById($branchID, $productID = 0) + public function getById($branchID, $productID = 0, $queryAll = false) { if(empty($branchID)) { @@ -27,6 +29,9 @@ class branchModel extends model if(empty($product) or !isset($this->lang->product->branchName[$product->type])) return false; return $this->lang->branch->main; } + + if($queryAll) return $this->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch(); + return htmlspecialchars_decode($this->dao->select('*')->from(TABLE_BRANCH)->where('id')->eq($branchID)->fetch('name')); } @@ -149,6 +154,29 @@ class branchModel extends model return false; } + /** + * Update branch. + * + * @param int $branchID + * @access public + * @return array|bool + */ + public function update($branchID) + { + $oldBranch = $this->getById($branchID, 0, true); + + $newBranch = fixer::input('post')->get(); + $newBranch->closedDate = $newBranch->status == 'closed' ? helper::today() : ''; + + $this->dao->update(TABLE_BRANCH)->data($newBranch) + ->where('id')->eq($branchID) + ->batchCheck($this->config->branch->edit->requiredFields, 'notempty') + ->exec(); + + if(!dao::isError()) return common::createChanges($oldBranch, $newBranch); + return false; + } + /** * Manage branch. * diff --git a/module/branch/view/edit.html.php b/module/branch/view/edit.html.php new file mode 100644 index 0000000000..751cf45344 --- /dev/null +++ b/module/branch/view/edit.html.php @@ -0,0 +1,38 @@ + + * @package branch + * @version $Id$ + * @link https://www.zentao.net + */ +?> + +
+
+

branch->create;?>

+
+
+ + + + + + + + + + + + + + + + +
branch->name;?>name, "class='form-control'");?>
branch->status;?>branch->statusList, $branch->status, "class='form-control chosen'");?>
branch->desc;?>desc, "class='form-control'");?>
+
+
+ diff --git a/module/branch/view/manage.html.php b/module/branch/view/manage.html.php index 23b359ee7a..843b86c879 100644 --- a/module/branch/view/manage.html.php +++ b/module/branch/view/manage.html.php @@ -75,7 +75,7 @@ id == BRANCH_MAIN ? 'disabled' : ''; - common::printIcon('branch', 'edit', "branchID=$branch->id", $branch, 'list', '', '', $disabled); + common::printIcon('branch', 'edit', "branchID=$branch->id", $branch, 'list', '', '', "$disabled iframe", true); if($branch->status == 'active') { common::printIcon('branch', 'close', "branchID=$branch->id", $branch, 'list', 'off', '', $disabled); diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 9b2024adc3..2a9958d82f 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -422,13 +422,15 @@ $lang->product->methodOrder[105] = 'unbindWhitelist'; $lang->resource->branch = new stdclass(); $lang->resource->branch->manage = 'manage'; $lang->resource->branch->create = 'create'; +$lang->resource->branch->edit = 'editAction'; $lang->resource->branch->sort = 'sort'; $lang->resource->branch->delete = 'delete'; $lang->branch->methodOrder[0] = 'manage'; $lang->branch->methodOrder[5] = 'create'; -$lang->branch->methodOrder[10] = 'sort'; -$lang->branch->methodOrder[15] = 'delete'; +$lang->branch->methodOrder[10] = 'edit'; +$lang->branch->methodOrder[15] = 'sort'; +$lang->branch->methodOrder[20] = 'delete'; /* Story. */ $lang->resource->story = new stdclass(); From f22b3ea149a01d51bbde1a47dc8739b8b582828d Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Sun, 7 Nov 2021 18:12:57 +0800 Subject: [PATCH 4/6] * Code for task#43902. --- module/action/lang/en.php | 2 +- module/action/lang/zh-cn.php | 2 +- module/action/lang/zh-tw.php | 2 +- module/branch/control.php | 50 ++++++++++++++++++++++++++++++ module/branch/lang/de.php | 22 +++++++------ module/branch/lang/en.php | 22 +++++++------ module/branch/lang/fr.php | 22 +++++++------ module/branch/lang/vi.php | 22 +++++++------ module/branch/lang/zh-cn.php | 22 +++++++------ module/branch/lang/zh-tw.php | 22 +++++++------ module/branch/model.php | 32 +++++++++++++++++++ module/branch/view/manage.html.php | 4 +-- module/group/lang/resource.php | 18 ++++++----- 13 files changed, 176 insertions(+), 66 deletions(-) diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 8962c2c22d..c47966431b 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -506,7 +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'; +$lang->action->label->branch = 'Branch|branch|manage|prouctID=%s&browseType=all'; /* Object type. */ $lang->action->search = new stdclass(); diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 7f8632dd35..57af0a4424 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -506,7 +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'; +$lang->action->label->branch = '分支|branch|manage|productID=%s&browseType=all'; /* Object type. */ $lang->action->search = new stdclass(); diff --git a/module/action/lang/zh-tw.php b/module/action/lang/zh-tw.php index b7a7bd390e..93f8d1a424 100755 --- a/module/action/lang/zh-tw.php +++ b/module/action/lang/zh-tw.php @@ -506,7 +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'; +$lang->action->label->branch = '分支|branch|manage|productID=%s&browseType=all'; /* Object type. */ $lang->action->search = new stdclass(); diff --git a/module/branch/control.php b/module/branch/control.php index d372597381..02c80b9940 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -85,6 +85,56 @@ class branch extends control $this->display(); } + /** + * Close a branch. + * + * @param int $branchID + * @param string $confirm + * @access public + * @return void + */ + public function close($branchID, $confirm = 'no') + { + $this->app->loadLang('product'); + $productType = $this->branch->getProductType($branchID); + + if($confirm == 'no') + { + die(js::confirm(str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->confirmClose), inlink('close', "branchID=$branchID&confirm=yes"))); + } + + $this->branch->close($branchID); + if(dao::isError()) die(js::error(dao::getError())); + + $this->loadModel('action')->create('branch', $branchID, 'Closed'); + die(js::reload('parent')); + } + + /** + * Activate a branch. + * + * @param int $branchID + * @param string $confirm + * @access public + * @return void + */ + public function activate($branchID, $confirm = 'no') + { + $this->app->loadLang('product'); + $productType = $this->branch->getProductType($branchID); + + if($confirm == 'no') + { + die(js::confirm(str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->confirmActivate), inlink('activate', "branchID=$branchID&confirm=yes"))); + } + + $this->branch->activate($branchID); + if(dao::isError()) die(js::error(dao::getError())); + + $this->loadModel('action')->create('branch', $branchID, 'Activated'); + die(js::reload('parent')); + } + /** * Sort branch. * diff --git a/module/branch/lang/de.php b/module/branch/lang/de.php index 4aa0b38d52..77b32e7b57 100644 --- a/module/branch/lang/de.php +++ b/module/branch/lang/de.php @@ -9,12 +9,14 @@ $lang->branch->manageTitle = '%s Management'; $lang->branch->all = 'Alle '; $lang->branch->main = 'Main'; -$lang->branch->edit = 'Edit'; -$lang->branch->editAction = 'Edit Branch'; -$lang->branch->active = 'Active'; -$lang->branch->close = 'Close'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->activate = 'Activate'; +$lang->branch->activateAction = 'Activate Branch'; +$lang->branch->close = 'Close'; +$lang->branch->closeAction = 'Close Branch'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Produkt'; @@ -26,9 +28,11 @@ $lang->branch->desc = 'Desc'; $lang->branch->order = 'Sortierung'; $lang->branch->deleted = 'Löscht'; -$lang->branch->confirmDelete = 'Möchten Sie diesen @branch@ löschen?'; -$lang->branch->canNotDelete = 'Es sind Daten im @branch@ vorhanden. Löschen nicht möglich.'; -$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmDelete = 'Möchten Sie diesen @branch@ löschen?'; +$lang->branch->canNotDelete = 'Es sind Daten im @branch@ vorhanden. Löschen nicht möglich.'; +$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmClose = 'Do you want to close this @branch@?'; +$lang->branch->confirmActivate = 'Do you want to activate this @branch@?'; $lang->branch->noData = 'No branches.'; $lang->branch->mainBranch = 'The default main branch of the product.'; diff --git a/module/branch/lang/en.php b/module/branch/lang/en.php index 009390678c..c0ff485766 100644 --- a/module/branch/lang/en.php +++ b/module/branch/lang/en.php @@ -9,12 +9,14 @@ $lang->branch->manageTitle = '%s Management'; $lang->branch->all = 'All '; $lang->branch->main = 'Main'; -$lang->branch->edit = 'Edit'; -$lang->branch->editAction = 'Edit Branch'; -$lang->branch->active = 'Active'; -$lang->branch->close = 'Close'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->activate = 'Activate'; +$lang->branch->activateAction = 'Activate Branch'; +$lang->branch->close = 'Close'; +$lang->branch->closeAction = 'Close Branch'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Product'; @@ -26,9 +28,11 @@ $lang->branch->desc = 'Desc'; $lang->branch->order = 'Order'; $lang->branch->deleted = 'Delete'; -$lang->branch->confirmDelete = 'Do you want to delete this @branch@?'; -$lang->branch->canNotDelete = 'There is data in @branch@. It cannot be deleted.'; -$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmDelete = 'Do you want to delete this @branch@?'; +$lang->branch->canNotDelete = 'There is data in @branch@. It cannot be deleted.'; +$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmClose = 'Do you want to close this @branch@?'; +$lang->branch->confirmActivate = 'Do you want to activate this @branch@?'; $lang->branch->noData = 'No branches.'; $lang->branch->mainBranch = 'The default main branch of the product.'; diff --git a/module/branch/lang/fr.php b/module/branch/lang/fr.php index 8c241acae3..49cb669d98 100644 --- a/module/branch/lang/fr.php +++ b/module/branch/lang/fr.php @@ -9,12 +9,14 @@ $lang->branch->manageTitle = 'Gestion %s'; $lang->branch->all = 'Tous'; $lang->branch->main = 'Main'; -$lang->branch->edit = 'Edit'; -$lang->branch->editAction = 'Edit Branch'; -$lang->branch->active = 'Active'; -$lang->branch->close = 'Close'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->activate = 'Activate'; +$lang->branch->activateAction = 'Activate Branch'; +$lang->branch->close = 'Close'; +$lang->branch->closeAction = 'Close Branch'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Product'; @@ -26,9 +28,11 @@ $lang->branch->desc = 'Desc'; $lang->branch->order = 'Ordre'; $lang->branch->deleted = 'Delete'; -$lang->branch->confirmDelete = "Voulez-vous vraiment supprimer l'établissement @branch@ ?"; -$lang->branch->canNotDelete = 'Attention ! Il y a des données dans @branch@. Suppression impossible !'; -$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmDelete = "Voulez-vous vraiment supprimer l'établissement @branch@ ?"; +$lang->branch->canNotDelete = 'Attention ! Il y a des données dans @branch@. Suppression impossible !'; +$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmClose = 'Do you want to close this @branch@?'; +$lang->branch->confirmActivate = 'Do you want to activate this @branch@?'; $lang->branch->noData = 'No branches.'; $lang->branch->mainBranch = 'The default main branch of the product.'; diff --git a/module/branch/lang/vi.php b/module/branch/lang/vi.php index 2a65268681..30d16d179c 100644 --- a/module/branch/lang/vi.php +++ b/module/branch/lang/vi.php @@ -9,12 +9,14 @@ $lang->branch->manageTitle = 'Quản lý %s'; $lang->branch->all = 'Tất cả '; $lang->branch->main = 'Main'; -$lang->branch->edit = 'Edit'; -$lang->branch->editAction = 'Edit Branch'; -$lang->branch->active = 'Active'; -$lang->branch->close = 'Close'; -$lang->branch->create = 'Create Branch'; -$lang->branch->merge = 'Merge'; +$lang->branch->edit = 'Edit'; +$lang->branch->editAction = 'Edit Branch'; +$lang->branch->activate = 'Activate'; +$lang->branch->activateAction = 'Activate Branch'; +$lang->branch->close = 'Close'; +$lang->branch->closeAction = 'Close Branch'; +$lang->branch->create = 'Create Branch'; +$lang->branch->merge = 'Merge'; $lang->branch->id = 'ID'; $lang->branch->product = 'Sản phẩm'; @@ -26,9 +28,11 @@ $lang->branch->desc = 'Desc'; $lang->branch->order = 'Sắp xếp'; $lang->branch->deleted = 'Xóa'; -$lang->branch->confirmDelete = 'Bạn có muốn xóa @branch@ này?'; -$lang->branch->canNotDelete = 'Có dữ liệu trong @branch@. Nó không thể bị xóa.'; -$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmDelete = 'Bạn có muốn xóa @branch@ này?'; +$lang->branch->canNotDelete = 'Có dữ liệu trong @branch@. Nó không thể bị xóa.'; +$lang->branch->nameNotEmpty = 'Name must not be empty!'; +$lang->branch->confirmClose = 'Do you want to close this @branch@?'; +$lang->branch->confirmActivate = 'Do you want to activate this @branch@?'; $lang->branch->noData = 'No branches.'; $lang->branch->mainBranch = 'The default main branch of the product.'; diff --git a/module/branch/lang/zh-cn.php b/module/branch/lang/zh-cn.php index d2f3a544d0..12672f6102 100644 --- a/module/branch/lang/zh-cn.php +++ b/module/branch/lang/zh-cn.php @@ -9,12 +9,14 @@ $lang->branch->manageTitle = '%s管理'; $lang->branch->all = '所有'; $lang->branch->main = '主干'; -$lang->branch->edit = '编辑'; -$lang->branch->editAction = '编辑分支'; -$lang->branch->active = '激活'; -$lang->branch->close = '关闭'; -$lang->branch->create = '新增分支'; -$lang->branch->merge = '合并'; +$lang->branch->edit = '编辑'; +$lang->branch->editAction = '编辑分支'; +$lang->branch->activate = '激活'; +$lang->branch->activateAction = '激活分支'; +$lang->branch->close = '关闭'; +$lang->branch->closeAction = '关闭分支'; +$lang->branch->create = '新增分支'; +$lang->branch->merge = '合并'; $lang->branch->id = 'ID'; $lang->branch->product = '所属产品'; @@ -26,9 +28,11 @@ $lang->branch->desc = '分支描述'; $lang->branch->order = '排序'; $lang->branch->deleted = '已删除'; -$lang->branch->confirmDelete = '是否删除该@branch@?'; -$lang->branch->canNotDelete = '该@branch@下已经有数据,不能删除!'; -$lang->branch->nameNotEmpty = '名称不能为空!'; +$lang->branch->confirmDelete = '是否删除该@branch@?'; +$lang->branch->canNotDelete = '该@branch@下已经有数据,不能删除!'; +$lang->branch->nameNotEmpty = '名称不能为空!'; +$lang->branch->confirmClose = '是否关闭该@branch@?'; +$lang->branch->confirmActivate = '是否激活该@branch@?'; $lang->branch->noData = '暂时没有分支。'; $lang->branch->mainBranch = '产品默认主干分支。'; diff --git a/module/branch/lang/zh-tw.php b/module/branch/lang/zh-tw.php index 4b502fe030..679c34eb1a 100644 --- a/module/branch/lang/zh-tw.php +++ b/module/branch/lang/zh-tw.php @@ -8,12 +8,14 @@ $lang->branch->add = '添加'; $lang->branch->manageTitle = '%s管理'; $lang->branch->all = '所有'; -$lang->branch->edit = '編輯'; -$lang->branch->editAction = '編輯分支'; -$lang->branch->active = '啟動'; -$lang->branch->close = '關閉'; -$lang->branch->create = '新增分支'; -$lang->branch->merge = '合併'; +$lang->branch->edit = '編輯'; +$lang->branch->editAction = '編輯分支'; +$lang->branch->activate = '啟動'; +$lang->branch->activateAction = '啟動分支'; +$lang->branch->close = '關閉'; +$lang->branch->closeAction = '關閉分支'; +$lang->branch->create = '新增分支'; +$lang->branch->merge = '合併'; $lang->branch->id = '編號'; $lang->branch->product = '所屬產品'; @@ -25,9 +27,11 @@ $lang->branch->desc = '分支描述'; $lang->branch->order = '排序'; $lang->branch->deleted = '已刪除'; -$lang->branch->confirmDelete = '是否刪除該@branch@?'; -$lang->branch->canNotDelete = '該@branch@下已經有數據,不能刪除!'; -$lang->branch->nameNotEmpty = '名稱不能為空!'; +$lang->branch->confirmDelete = '是否刪除該@branch@?'; +$lang->branch->canNotDelete = '該@branch@下已經有數據,不能刪除!'; +$lang->branch->nameNotEmpty = '名稱不能為空!'; +$lang->branch->confirmClose = '是否關閉该@branch@?'; +$lang->branch->confirmActivate = '是否啟動该@branch@?'; $lang->branch->noData = '暫時沒有分支。'; $lang->branch->mainBranch = '產品默認主幹分支。'; diff --git a/module/branch/model.php b/module/branch/model.php index 07a21d8d8b..d0c0be2e22 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -177,6 +177,38 @@ class branchModel extends model return false; } + /** + * Close a branch. + * + * @param int $branchID + * @access public + * @return void + */ + public function close($branchID) + { + $this->dao->update(TABLE_BRANCH) + ->set('status')->eq('closed') + ->set('closedDate')->eq(helper::today()) + ->where('id')->eq($branchID) + ->exec(); + } + + /** + * Activate a branch. + * + * @param int $branchID + * @access public + * @return void + */ + public function activate($branchID) + { + $this->dao->update(TABLE_BRANCH) + ->set('status')->eq('active') + ->set('closedDate')->eq('') + ->where('id')->eq($branchID) + ->exec(); + } + /** * Manage branch. * diff --git a/module/branch/view/manage.html.php b/module/branch/view/manage.html.php index 843b86c879..46d6e6c0a8 100644 --- a/module/branch/view/manage.html.php +++ b/module/branch/view/manage.html.php @@ -78,11 +78,11 @@ common::printIcon('branch', 'edit', "branchID=$branch->id", $branch, 'list', '', '', "$disabled iframe", true); if($branch->status == 'active') { - common::printIcon('branch', 'close', "branchID=$branch->id", $branch, 'list', 'off', '', $disabled); + common::printIcon('branch', 'close', "branchID=$branch->id", $branch, 'list', 'off', 'hiddenwin', $disabled); } else { - common::printIcon('branch', 'active', "branchID=$branch->id", $branch, 'list', 'active', '', $disabled); + common::printIcon('branch', 'activate', "branchID=$branch->id", $branch, 'list', 'active', 'hiddenwin', $disabled); } ?> diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php index 2a9958d82f..26a85ea898 100644 --- a/module/group/lang/resource.php +++ b/module/group/lang/resource.php @@ -420,17 +420,21 @@ $lang->product->methodOrder[105] = 'unbindWhitelist'; /* Branch. */ $lang->resource->branch = new stdclass(); -$lang->resource->branch->manage = 'manage'; -$lang->resource->branch->create = 'create'; -$lang->resource->branch->edit = 'editAction'; -$lang->resource->branch->sort = 'sort'; -$lang->resource->branch->delete = 'delete'; +$lang->resource->branch->manage = 'manage'; +$lang->resource->branch->create = 'create'; +$lang->resource->branch->edit = 'editAction'; +$lang->resource->branch->close = 'closeAction'; +$lang->resource->branch->activate = 'activateAction'; +$lang->resource->branch->sort = 'sort'; +$lang->resource->branch->delete = 'delete'; $lang->branch->methodOrder[0] = 'manage'; $lang->branch->methodOrder[5] = 'create'; $lang->branch->methodOrder[10] = 'edit'; -$lang->branch->methodOrder[15] = 'sort'; -$lang->branch->methodOrder[20] = 'delete'; +$lang->branch->methodOrder[15] = 'close'; +$lang->branch->methodOrder[20] = 'activate'; +$lang->branch->methodOrder[25] = 'sort'; +$lang->branch->methodOrder[30] = 'delete'; /* Story. */ $lang->resource->story = new stdclass(); From acf5b15c06a93f6c746fa239ceedfcdc4310786d Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 8 Nov 2021 09:20:57 +0800 Subject: [PATCH 5/6] * Code for task#43902. --- module/branch/model.php | 3 +++ module/story/control.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/module/branch/model.php b/module/branch/model.php index d0c0be2e22..5865a56f07 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -86,6 +86,7 @@ class branchModel extends model $branches = $this->dao->select('*')->from(TABLE_BRANCH) ->where('deleted')->eq(0) ->beginIF($productID)->andWhere('product')->eq($productID)->fi() + ->beginIF(strpos($params, 'active') !== false)->andWhere('status')->eq('active')->fi() ->orderBy('`order`') ->fetchPairs('id', 'name'); foreach($branches as $branchID => $branchName) $branches[$branchID] = htmlspecialchars_decode($branchName); @@ -97,6 +98,8 @@ class branchModel extends model $branches = array('all' => $this->lang->branch->all, '0' => $this->lang->branch->main) + $branches; } + + if(strpos($params, 'noall') !== false) unset($branches['all']); return $branches; } diff --git a/module/story/control.php b/module/story/control.php index 90da967309..ba35b872d5 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -313,7 +313,7 @@ class story extends control $this->view->color = $color; $this->view->pri = $pri; $this->view->branch = $branch; - $this->view->branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID) : array(); + $this->view->branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID, 'active|noall') : array(); $this->view->productID = $productID; $this->view->product = $product; $this->view->objectID = $objectID; @@ -627,7 +627,7 @@ class story extends control $this->view->users = $users; $this->view->product = $product; $this->view->products = $myProducts + $othersProducts; - $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product); + $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product, 'noall'); $this->view->reviewers = implode(',', $reviewerList); $this->view->reviewedReviewer = $reviewedReviewer; $this->view->isShowReviewer = $isShowReviewer; From 866c7adc7526a657ca2a731ecf57faa178c43e65 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Mon, 8 Nov 2021 13:53:16 +0800 Subject: [PATCH 6/6] * Code for task#43902. --- module/branch/model.php | 2 -- module/story/control.php | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/module/branch/model.php b/module/branch/model.php index 5865a56f07..5bdf3d6d17 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -98,8 +98,6 @@ class branchModel extends model $branches = array('all' => $this->lang->branch->all, '0' => $this->lang->branch->main) + $branches; } - - if(strpos($params, 'noall') !== false) unset($branches['all']); return $branches; } diff --git a/module/story/control.php b/module/story/control.php index ba35b872d5..d6053a3823 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -313,7 +313,7 @@ class story extends control $this->view->color = $color; $this->view->pri = $pri; $this->view->branch = $branch; - $this->view->branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID, 'active|noall') : array(); + $this->view->branches = $product->type != 'normal' ? $this->loadModel('branch')->getPairs($productID, 'active') : array(); $this->view->productID = $productID; $this->view->product = $product; $this->view->objectID = $objectID; @@ -627,7 +627,7 @@ class story extends control $this->view->users = $users; $this->view->product = $product; $this->view->products = $myProducts + $othersProducts; - $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product, 'noall'); + $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($story->product); $this->view->reviewers = implode(',', $reviewerList); $this->view->reviewedReviewer = $reviewedReviewer; $this->view->isShowReviewer = $isShowReviewer;