From 9bd03f59761c80451d04de30c7dbef62bfc67b1c Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 26 Oct 2015 14:15:25 +0800 Subject: [PATCH] * finish task #2353. --- module/build/control.php | 17 +++++++++++++---- module/build/js/common.js | 13 +++++++++++++ module/build/lang/zh-cn.php | 1 + module/build/model.php | 2 +- module/build/view/create.html.php | 9 ++++++++- module/build/view/edit.html.php | 7 ++++++- module/build/view/view.html.php | 8 +++++++- 7 files changed, 49 insertions(+), 8 deletions(-) diff --git a/module/build/control.php b/module/build/control.php index aaeac97b4b..6d96297e92 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -39,11 +39,16 @@ class build extends control $orderBy = 'status_asc, stage_asc, id_desc'; /* Assign. */ - $project = $this->loadModel('project')->getById($projectID); + $project = $this->loadModel('project')->getById($projectID); + $products = $this->project->getProducts($projectID, false); + $product = $this->loadModel('product')->getById(key($products)); + $this->view->title = $project->name . $this->lang->colon . $this->lang->build->create; $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$projectID"), $project->name); $this->view->position[] = $this->lang->build->create; - $this->view->products = $this->project->getProducts($projectID); + $this->view->products = $products; + $this->view->product = $product; + $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($product->id); $this->view->projectID = $projectID; $this->view->lastBuild = $this->build->getLast($projectID); $this->view->users = $this->user->getPairs('nodeleted'); @@ -86,11 +91,14 @@ class build extends control $orderBy = 'status_asc, stage_asc, id_desc'; /* Assign. */ - $project = $this->loadModel('project')->getById($build->project); + $project = $this->loadModel('project')->getById($build->project); + $products = $this->project->getProducts($build->project, false); + $this->view->title = $project->name . $this->lang->colon . $this->lang->build->edit; $this->view->position[] = html::a($this->createLink('project', 'task', "projectID=$build->project"), $project->name); $this->view->position[] = $this->lang->build->edit; - $this->view->products = $this->project->getProducts($build->project); + $this->view->products = $products; + $this->view->branches = $build->productType == 'normal' ? array() : $this->loadModel('branch')->getPairs($build->product); $this->view->build = $build; $this->view->users = $this->loadModel('user')->getPairs('nodeleted', $build->builder); $this->view->orderBy = $orderBy; @@ -138,6 +146,7 @@ class build extends control $this->view->type = $type; $this->view->link = $link; $this->view->param = $param; + $this->view->branchName = $build->productType == 'normal' ? '' : $this->loadModel('branch')->getById($build->branch); $this->display(); } diff --git a/module/build/js/common.js b/module/build/js/common.js index 1f3ddf85b3..2aa47df802 100644 --- a/module/build/js/common.js +++ b/module/build/js/common.js @@ -2,3 +2,16 @@ $(document).ready(function() { $("a.preview").modalTrigger({width:1000, type:'iframe'}); }) + +function loadBranches(productID) +{ + $('#branch').remove(); + $.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID), function(data) + { + if(data) + { + $('#product').closest('.input-group').append(data); + $('#branch').css('width', '100px'); + } + }); +} diff --git a/module/build/lang/zh-cn.php b/module/build/lang/zh-cn.php index eae5c871d1..34221b8a84 100644 --- a/module/build/lang/zh-cn.php +++ b/module/build/lang/zh-cn.php @@ -31,6 +31,7 @@ $lang->build->basicInfo = '基本信息'; $lang->build->id = 'ID'; $lang->build->product = $lang->productCommon; +$lang->build->branch = '所属分支'; $lang->build->project = $lang->projectCommon; $lang->build->name = '名称编号'; $lang->build->date = '打包日期'; diff --git a/module/build/model.php b/module/build/model.php index 3f8844207f..77ddde7c01 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -23,7 +23,7 @@ class buildModel extends model */ public function getByID($buildID, $setImgSize = false) { - $build = $this->dao->select('t1.*, t2.name as projectName, t3.name as productName') + $build = $this->dao->select('t1.*, t2.name as projectName, t3.name as productName, t3.type as productType') ->from(TABLE_BUILD)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id') ->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product = t3.id') diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index ba39e5d197..271e7e2fe1 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -24,7 +24,14 @@ - + diff --git a/module/build/view/edit.html.php b/module/build/view/edit.html.php index 2459fb2816..c554b68742 100644 --- a/module/build/view/edit.html.php +++ b/module/build/view/edit.html.php @@ -25,7 +25,12 @@
build->product;?> + +
+ id, "onchange='loadBranches(this.value);' class='form-control chosen'");?> + type != 'normal') echo html::select('branch', $branches, '', "class='form-control' style='width:100px'");?> +
+ +
build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID"));?>
- + diff --git a/module/build/view/view.html.php b/module/build/view/view.html.php index 81e620559f..dd78563438 100644 --- a/module/build/view/view.html.php +++ b/module/build/view/view.html.php @@ -222,10 +222,16 @@ + productType != 'normal'):?> + + + + + - +
build->product;?>product, "class='form-control chosen'");?> +
+ product, "onchange='loadBranches(this.value);' class='form-control chosen'");?> + productType != 'normal') echo html::select('branch', $branches, $build->branch, "class='form-control' style='width:100px'");?> +
+
build->name;?>build->product;?> productName;?>
build->branch;?>
build->name;?> name;?>
build->builder;?> builder];?>