diff --git a/module/bug/model.php b/module/bug/model.php index 7756aeb3f4..db95f9254d 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -24,7 +24,7 @@ class bugModel extends model public function setMenu($products, $productID) { $this->loadModel('product')->setMenu($products, $productID); - $selectHtml = html::select('productID', $products, $productID, "onchange=\"switchProduct(this.value, 'bug', 'browse');\""); + $selectHtml = $this->product->select($products, $productID, 'bug', 'browse'); foreach($this->lang->bug->menu as $key => $menu) { $replace = ($key == 'product') ? $selectHtml . $this->lang->arrow : $productID; diff --git a/module/common/lang/en.php b/module/common/lang/en.php index a84619b76c..ec8b553665 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -42,7 +42,7 @@ $lang->save = 'Save'; $lang->confirm = 'Confirm'; $lang->preview = 'Preview'; $lang->goback = 'Back'; -$lang->go = 'GO!'; +$lang->go = 'GO'; $lang->more = 'More'; $lang->actions = 'Actions'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index f08b6cc5e7..0029886b83 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -42,7 +42,7 @@ $lang->save = '保存'; $lang->confirm = '确认'; $lang->preview = '预览'; $lang->goback = '返回'; -$lang->go = 'GO!'; +$lang->go = 'GO'; $lang->more = '更多'; $lang->actions = '操作'; diff --git a/module/common/model.php b/module/common/model.php index 91c8af5b73..5dc9dc5b26 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -242,7 +242,7 @@ class commonModel extends model echo ""; echo "\n"; } diff --git a/module/doc/control.php b/module/doc/control.php index 28e8890aaf..f01ded2f48 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -275,7 +275,7 @@ class doc extends control elseif($from == 'project') { $this->lang->doc->menu = $this->lang->project->menu; - $this->project->setMenu($this->project->getPairs(), $projectID); + $this->project->setMenu($this->project->getPairs('nocode'), $projectID); $this->lang->set('menugroup.doc', 'project'); } else diff --git a/module/product/model.php b/module/product/model.php index 87718c94e0..95476b44f4 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -38,7 +38,7 @@ class productModel extends model if($currentModule == 'story') $currentModule = 'product'; if($currentMethod == 'report') $currentMethod = 'browse'; - $selectHtml = html::select('productID', $products, $productID, "onchange=\"switchProduct(this.value, '$currentModule', '$currentMethod', '$extra');\""); + $selectHtml = $this->select($products, $productID, $currentModule, $currentMethod, $extra); foreach($this->lang->product->menu as $key => $menu) { $replace = $key == 'list' ? $selectHtml . $this->lang->arrow : $productID; @@ -46,6 +46,34 @@ class productModel extends model } } + /** + * Create the select code of products. + * + * @param array $products + * @param int $productID + * @param string $currentModule + * @param string $currentMethod + * @param string $extra + * @access public + * @return string + */ + public function select($products, $productID, $currentModule, $currentMethod, $extra = '') + { + /** + * 1. if user selected by mouse, reload it. + * 2. if the user select by keyboard, save the event.keyCode, thus the switchProduct() can judge whether reload or not. + * 3. if user press enter key in the select, reload it. + * 4. if user click the go button, reload it. + * */ + $switchCode = "switchProduct($('#productID').val(), '$currentModule', '$currentMethod', '$extra');"; + $onchange = "onchange=\"$switchCode\""; + $onkeypress = "onkeypress=\"eventKeyCode=event.keyCode; if(eventKeyCode == 13) $switchCode\""; + $onclick = "onclick=\"eventKeyCode = 13; $switchCode\""; + $selectHtml = html::select('productID', $products, $productID, "tabindex=2 $onchange $onkeypress"); + $selectHtml .= html::commonButton($this->lang->go, "id='productSwitcher' tabindex=3 $onclick"); + return $selectHtml; + } + /** * Save the product id user last visited to session. * @@ -134,12 +162,11 @@ class productModel extends model /** * Get product pairs. * - * @access public + * @param string $mode * @return array */ - public function getPairs() + public function getPairs($mode = 'noclosed') { - $mode = $this->cookie->productMode ? $this->cookie->productMode : 'noclosed'; $products = $this->dao->select('*') ->from(TABLE_PRODUCT) ->where('deleted')->eq(0) @@ -148,7 +175,11 @@ class productModel extends model $pairs = array(); foreach($products as $product) { - if($this->checkPriv($product)) $pairs[$product->id] = $product->name; + if($this->checkPriv($product)) + { + if(strpos($mode, 'nocode') === false and $product->code) $product->name = $product->code . ':' . $product->name; + $pairs[$product->id] = $product->name; + } } return $pairs; } diff --git a/module/testcase/model.php b/module/testcase/model.php index 46329e08ee..a5741ace22 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -24,7 +24,7 @@ class testcaseModel extends model public function setMenu($products, $productID) { $this->loadModel('product')->setMenu($products, $productID); - $selectHtml = html::select('productID', $products, $productID, "onchange=\"switchProduct(this.value, 'testcase', 'browse');\""); + $selectHtml = $this->product->select($products, $productID, 'testcase', 'browse'); foreach($this->lang->testcase->menu as $key => $menu) { $replace = ($key == 'product') ? $selectHtml . $this->lang->arrow : $productID; diff --git a/module/testtask/model.php b/module/testtask/model.php index 7a6eba2343..e45c0c0962 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -23,7 +23,8 @@ class testtaskModel extends model */ public function setMenu($products, $productID) { - $selectHtml = html::select('productID', $products, $productID, "onchange=\"switchProduct(this.value, 'testtask', 'browse');\""); + $this->loadModel('product')->setMenu($products, $productID); + $selectHtml = $this->product->select($products, $productID, 'testtask', 'browse'); foreach($this->lang->testtask->menu as $key => $value) { $replace = ($key == 'product') ? $selectHtml . $this->lang->arrow: $productID; diff --git a/module/tree/model.php b/module/tree/model.php index c1da999996..777c7a9a81 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -169,7 +169,7 @@ class treeModel extends model public function getProductDocTreeMenu() { $menu = "