diff --git a/module/testcase/control.php b/module/testcase/control.php index cceae4588f..ea29edeb1f 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -99,6 +99,7 @@ class testcase extends control $this->view->position[] = $this->lang->testcase->common; $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; + $this->view->modules = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch); $this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'case', $startModuleID = 0, array('treeModel', 'createCaseLink'), '', $branch); $this->view->moduleID = $moduleID; $this->view->pager = $pager; @@ -110,6 +111,7 @@ class testcase extends control $this->view->branch = $branch; $this->view->branches = $this->loadModel('branch')->getPairs($productID); + $this->display(); } @@ -607,6 +609,32 @@ class testcase extends control } } + /** + * Batch change the module of case. + * + * @param int $moduleID + * @access public + * @return void + */ + public function batchChangeModule($moduleID) + { + if($this->post->caseIDList) + { + $caseIDList = $this->post->caseIDList; + unset($_POST['caseIDList']); + $allChanges = $this->testcase->batchChangeModule($caseIDList, $moduleID); + if(dao::isError()) die(js::error(dao::getError())); + foreach($allChanges as $caseID => $changes) + { + $this->loadModel('action'); + $actionID = $this->action->create('case', $caseID, 'Edited'); + $this->action->logHistory($actionID, $changes); + } + } + + die(js::locate($this->session->caseList, 'parent')); + } + /** * Batch delete cases. * diff --git a/module/testcase/css/browse.css b/module/testcase/css/browse.css index a83175e923..c83a2d9874 100644 --- a/module/testcase/css/browse.css +++ b/module/testcase/css/browse.css @@ -1 +1,7 @@ .w-220px{width:220px} + +.dropdown-menu.with-search {padding-bottom: 34px; min-width: 150px; overflow: hidden; max-height: 305px} +.dropdown-menu > .menu-search {padding: 0; position: absolute; z-index: 0; bottom: 0; left: 0; right: 0} +.dropdown-menu > .menu-search .input-group {width:100%;} +.dropdown-menu > .menu-search .input-group-addon {position: absolute; right: 10px; top: 0; z-index: 10; background: none; border: none; color: #666} +.pl-5px{padding-left:5px;} diff --git a/module/testcase/js/browse.js b/module/testcase/js/browse.js index 170ee55ff8..12e1902f6f 100644 --- a/module/testcase/js/browse.js +++ b/module/testcase/js/browse.js @@ -29,5 +29,21 @@ $(document).ready(function() setTimeout(function(){fixedTfootAction('#batchForm')}, 100); setTimeout(function(){fixedTheadOfList('#caseList')}, 100); + $('.dropdown-menu .with-search .menu-search').click(function(e) + { + e.stopPropagation(); + return false; + }).on('keyup change paste', 'input', function() + { + var val = $(this).val().toLowerCase(); + var $options = $(this).closest('ul.dropdown-menu.with-search').find('.option'); + if(val == '') return $options.removeClass('hide'); + $options.each(function() + { + var $option = $(this); + $option.toggleClass('hide', $option.text().toString().toLowerCase().indexOf(val) < 0 && $option.data('key').toString().toLowerCase().indexOf(val) < 0); + }); + }); + setModal4List('runCase', 'caseList'); }); diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php index 637ff6d58f..19fa9f4b65 100644 --- a/module/testcase/lang/en.php +++ b/module/testcase/lang/en.php @@ -12,6 +12,7 @@ $lang->testcase->id = 'ID'; $lang->testcase->product = $lang->productCommon; $lang->testcase->module = 'Module'; +$lang->testcase->moduleAB = 'Module'; $lang->testcase->story = 'Story'; $lang->testcase->title = 'Title'; $lang->testcase->precondition = 'precondition'; diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index cb0da94946..49c59fe10f 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -12,6 +12,7 @@ $lang->testcase->id = '用例编号'; $lang->testcase->product = "所属{$lang->productCommon}"; $lang->testcase->module = '所属模块'; +$lang->testcase->moduleAB = '模块'; $lang->testcase->story = '相关需求'; $lang->testcase->title = '用例标题'; $lang->testcase->precondition = '前置条件'; diff --git a/module/testcase/model.php b/module/testcase/model.php index 3d5af55060..71fbb016f7 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -216,6 +216,21 @@ class testcaseModel extends model return $case; } + /** + * Get case list. + * + * @param int|array|string $caseIDList + * @access public + * @return array + */ + public function getByList($caseIDList = 0) + { + return $this->dao->select('*')->from(TABLE_CASE) + ->where('deleted')->eq(0) + ->beginIF($caseIDList)->andWhere('id')->in($caseIDList)->fi() + ->fetchAll('id'); + } + /** * Get test cases. * @@ -579,6 +594,34 @@ class testcaseModel extends model return $allChanges; } + /** + * Batch change the module of case. + * + * @param array $caseIDList + * @param int $moduleID + * @access public + * @return array + */ + public function batchChangeModule($caseIDList, $moduleID) + { + $now = helper::now(); + $allChanges = array(); + $oldCases = $this->getByList($caseIDList); + foreach($caseIDList as $caseID) + { + $oldCase = $oldCases[$caseID]; + if($moduleID == $oldCase->module) continue; + + $case = new stdclass(); + $case->lastEditedBy = $this->app->user->account; + $case->lastEditedDate = $now; + $case->module = $moduleID; + + $this->dao->update(TABLE_CASE)->data($case)->autoCheck()->where('id')->eq((int)$caseID)->exec(); + if(!dao::isError()) $allChanges[$caseID] = common::createChanges($oldCase, $case); + } + return $allChanges; + } /** * Join steps to a string, thus can diff them. diff --git a/module/testcase/view/browse.html.php b/module/testcase/view/browse.html.php index 3798de5771..69c9d57777 100644 --- a/module/testcase/view/browse.html.php +++ b/module/testcase/view/browse.html.php @@ -36,45 +36,65 @@ js::set('batchDelete', $lang->testcase->confirmBatchDelete);
-moduleName . $this->methodName; -$useDatatable = (isset($this->config->datatable->$datatableId->mode) and $this->config->datatable->$datatableId->mode == 'datatable'); -$vars = "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; -include $useDatatable ? dirname(__FILE__) . '/datatabledata.html.php' : dirname(__FILE__) . '/browsedata.html.php'; -?> - - - - - -
- -
- createLink('testcase', 'batchEdit', "productID=$productID&branch=$branch"); - $misc = common::hasPriv('testcase', 'batchEdit') ? "onclick=\"setFormAction('$actionLink')\"" : "disabled='disabled'"; - echo html::commonButton($lang->edit, $misc); - ?> - - +
+
+ +
show();?>
+ + +