diff --git a/module/build/config.php b/module/build/config.php index 350e441a74..3d5c761e9a 100644 --- a/module/build/config.php +++ b/module/build/config.php @@ -8,3 +8,20 @@ $config->build->edit->requiredFields = 'product,project,name,builder,date'; $config->build->editor = new stdclass(); $config->build->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); $config->build->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); + +global $lang; +$config->build->search['module'] = 'build'; +$config->build->search['fields']['name'] = $lang->build->name; +$config->build->search['fields']['id'] = $lang->build->id; +$config->build->search['fields']['product'] = '所属' . $lang->build->product; +$config->build->search['fields']['scmPath'] = $lang->build->scmPath; +$config->build->search['fields']['filePath'] = $lang->build->filePath; +$config->build->search['fields']['date'] = $lang->build->date; +$config->build->search['fields']['builder'] = $lang->build->builder; + +$config->build->search['params']['name'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->build->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => 'products'); +$config->build->search['params']['scmPath'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->build->search['params']['filePath'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); +$config->build->search['params']['date'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); +$config->build->search['params']['builder'] = array('operator' => '=', 'control' => 'select', 'values' => 'users'); diff --git a/module/build/model.php b/module/build/model.php index 889b55c75b..85f0619bf5 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -52,11 +52,13 @@ class buildModel extends model /** * Get builds of a project. * - * @param int $projectID + * @param int $projectID + * @param string $type all|product|bysearch + * @param int|string $param productID|buildQuery * @access public * @return array */ - public function getProjectBuilds($projectID) + public function getProjectBuilds($projectID, $type, $param) { return $this->dao->select('t1.*, t2.name as projectName, t3.name as productName, t4.name as branchName') ->from(TABLE_BUILD)->alias('t1') @@ -65,10 +67,53 @@ class buildModel extends model ->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id') ->where('t1.project')->eq((int)$projectID) ->andWhere('t1.deleted')->eq(0) + ->beginIF($type == 'product' and $param)->andWhere('t1.product')->eq($param)->fi() + ->beginIF($type == 'bysearch')->andWhere($param)->fi() ->orderBy('t1.date DESC, t1.id desc') ->fetchAll('id'); } + /** + * Get builds of a project by search. + * + * @param int $projectID + * @param int $queryID + * @access public + * @return array + */ + public function getProjectBuildsBySearch($projectID, $queryID) + { + /* If there are saved query conditions, reset the session. */ + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set('projectBuildQuery', $query->sql); + $this->session->set('projectBuildForm', $query->form); + } + } + + $allProduct = "`product` = 'all'"; + $buildQuery = $this->session->projectBuildQuery; + if(strpos($this->session->projectBuildQuery, $allProduct) !== false) + { + $buildQuery = str_replace($allProduct, '1', $this->session->projectBuildQuery); + } + + /* Distinguish between repeated fields. */ + $fields = array('id' => '`id`', 'name' => '`name`', 'product' => '`product`'); + foreach($fields as $field) + { + if(strpos($this->session->projectBuildQuery, $field) !== false) + { + $buildQuery = str_replace($field, "t1." . $field, $buildQuery); + } + } + + return $this->getProjectBuilds($projectID, 'bysearch', $buildQuery); + } + /** * Get builds of a project in pairs. * diff --git a/module/project/control.php b/module/project/control.php index 0e41a83346..b9fd97b993 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -856,33 +856,59 @@ class project extends control * Browse builds of a project. * * @param int $projectID + * @param string $type all|product|bysearch + * @param int $param * @access public * @return void */ - public function build($projectID = 0) + public function build($projectID = 0, $type = 'all', $param = 0) { + /* Load module and set session. */ $this->loadModel('testtask'); $this->session->set('buildList', $this->app->getURI(true)); $project = $this->commonAction($projectID); $projectID = $project->id; - /* Header and position. */ - $this->view->title = $project->name . $this->lang->colon . $this->lang->project->build; - $this->view->position[] = html::a(inlink('browse', "projectID=$projectID"), $project->name); - $this->view->position[] = $this->lang->project->build; + /* Get products' list. */ + $products = $this->loadModel('product')->getPairs('nocode'); + $products = array($this->lang->company->product) + $products; - $builds = $this->loadModel('build')->getProjectBuilds((int)$projectID); + /* Build the search form. */ + $type = strtolower($type); + $queryID = ($type == 'bysearch') ? (int)$param : 0; + $actionURL = $this->createLink('project', 'build', "projectID=$projectID&type=bysearch&queryID=myQueryID"); + $this->project->buildVersionSearchForm($products, $queryID, $actionURL); + + /* Get builds. */ + if($type == 'bysearch') + { + $builds = $this->loadModel('build')->getProjectBuildsBySearch((int)$projectID, $param); + } + else + { + $builds = $this->loadModel('build')->getProjectBuilds((int)$projectID, $type, $param); + } + + /* Set project builds. */ $projectBuilds = array(); if(!empty($builds)) { foreach($builds as $build) $projectBuilds[$build->product][] = $build; } - /* Get builds. */ + /* Header and position. */ + $this->view->title = $project->name . $this->lang->colon . $this->lang->project->build; + $this->view->position[] = html::a(inlink('browse', "projectID=$projectID"), $project->name); + $this->view->position[] = $this->lang->project->build; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); $this->view->buildsTotal = count($builds); $this->view->projectBuilds = $projectBuilds; + $this->view->projectID = $projectID; + $this->view->product = $type == 'product' ? $param : 'all'; + $this->view->products = $products; + $this->view->type = $type; $this->display(); } diff --git a/module/project/js/build.js b/module/project/js/build.js new file mode 100644 index 0000000000..63c872731a --- /dev/null +++ b/module/project/js/build.js @@ -0,0 +1,12 @@ +/** + * Change product. + * + * @param int $productID + * @access public + * @return void + */ +function changeProduct(productID) +{ + link = createLink('project', 'build', 'projectID=' + projectID + '&type=product¶m=' + productID); + location.href = link; +} diff --git a/module/project/model.php b/module/project/model.php index 8a19254d58..bdc89857bf 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -2485,6 +2485,31 @@ class projectModel extends model $this->loadModel('search')->setSearchParams($this->config->project->search); } + /** + * Build version search form. + * + * @param array $products + * @param int $queryID + * @param string $actionURL + * @access public + * @return void + */ + public function buildVersionSearchForm($products, $queryID, $actionURL) + { + /* Load model and set products. */ + $this->loadModel('build'); + $products['0'] = ''; + $products['all'] = $this->lang->product->allProduct; + + /* Set search param. */ + $this->config->build->search['module'] = 'projectBuild'; + $this->config->build->search['actionURL'] = $actionURL; + $this->config->build->search['queryID'] = $queryID; + $this->config->build->search['params']['product']['values'] = $products; + + $this->loadModel('search')->setSearchParams($this->config->build->search); + } + /** * Get Kanban tasks * diff --git a/module/project/view/build.html.php b/module/project/view/build.html.php index b7323a9376..b6b52bea86 100644 --- a/module/project/view/build.html.php +++ b/module/project/view/build.html.php @@ -12,18 +12,28 @@ ?> build->confirmDelete)?> +
+