diff --git a/module/testcase/control.php b/module/testcase/control.php index ec1599aa1b..8ccdf7d6ee 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -1860,14 +1860,6 @@ class testcase extends control $this->loadModel('branch'); if($product->type != 'normal') $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $this->branch->getPairs($productID, 'active', $projectID); - if($_POST) - { - $this->testcase->importFromLib($productID); - return print(js::reload('parent')); - } - - $this->app->tab == 'project' ? $this->loadModel('project')->setMenu($this->session->project) : $this->testcase->setMenu($this->products, $productID, $branch); - $libraries = $this->loadModel('caselib')->getLibraries(); if(empty($libraries)) { @@ -1876,6 +1868,14 @@ class testcase extends control } if(empty($libID) or !isset($libraries[$libID])) $libID = key($libraries); + if($_POST) + { + $this->testcase->importFromLib($productID, $libID); + return print(js::reload('parent')); + } + + $this->app->tab == 'project' ? $this->loadModel('project')->setMenu($this->session->project) : $this->testcase->setMenu($this->products, $productID, $branch); + /* Build the search form. */ $actionURL = $this->createLink('testcase', 'importFromLib', "productID=$productID&branch=$branch&libID=$libID&orderBy=$orderBy&browseType=bySearch&queryID=myQueryID"); $this->config->testcase->search['module'] = 'testsuite'; @@ -1897,19 +1897,20 @@ class testcase extends control $this->view->title = $this->lang->testcase->common . $this->lang->colon . $this->lang->testcase->importFromLib; $this->view->position[] = $this->lang->testcase->importFromLib; - $this->view->libraries = $libraries; - $this->view->libID = $libID; - $this->view->product = $product; - $this->view->productID = $productID; - $this->view->branch = $branch; - $this->view->cases = $this->loadModel('testsuite')->getLibCases($productID, $libID, $orderBy, $pager, $browseType, $queryID); - $this->view->modules = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch === 'all' ? 0 : (int)$branch); - $this->view->libModules = $this->tree->getOptionMenu($libID, 'caselib'); - $this->view->pager = $pager; - $this->view->orderBy = $orderBy; - $this->view->branches = $branches; - $this->view->browseType = $browseType; - $this->view->queryID = $queryID; + $this->view->libraries = $libraries; + $this->view->libID = $libID; + $this->view->product = $product; + $this->view->productID = $productID; + $this->view->branch = $branch; + $this->view->cases = $this->loadModel('testsuite')->getLibCases($productID, $libID, $orderBy, $pager, $browseType, $queryID); + $this->view->modules = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch === 'all' ? 0 : (int)$branch); + $this->view->libModules = $this->tree->getOptionMenu($libID, 'caselib'); + $this->view->pager = $pager; + $this->view->orderBy = $orderBy; + $this->view->branches = $branches; + $this->view->browseType = $browseType; + $this->view->queryID = $queryID; + $this->view->importedModules = $this->testsuite->getImportedModules($productID, $libID); $this->display(); } diff --git a/module/testcase/model.php b/module/testcase/model.php index 169ab985b3..714f46cfa4 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -1576,19 +1576,22 @@ class testcaseModel extends model * Import case from Lib. * * @param int $productID + * @param int $libID * @access public * @return void */ - public function importFromLib($productID) + public function importFromLib($productID, $libID = 0) { $data = fixer::input('post')->get(); - $prevModule = 0; - $prevBranch = 0; + $prevModule = 0; + $prevBranch = 0; + $importedModules = $this->loadModel('testsuite')->getImportedModules($productID, $libID); foreach($data->module as $i => $module) { if($module != 'ditto') $prevModule = $module; if($module == 'ditto') $data->module[$i] = $prevModule; + if(isset($importedModules[$i][$data->module[$i]])) unset($data->caseIdList[$i]); } if(isset($data->branch)) diff --git a/module/testcase/view/importfromlib.html.php b/module/testcase/view/importfromlib.html.php index f25864f2ab..8ee1c69919 100644 --- a/module/testcase/view/importfromlib.html.php +++ b/module/testcase/view/importfromlib.html.php @@ -65,7 +65,8 @@