* Finish task #59477.
This commit is contained in:
+22
-21
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
<td class='text-left' title='<?php echo $libModule?>'><?php echo $libModule;?></td>
|
||||
<td class='text-left' data-module='<?php echo $case->module?>' style='overflow:visible'>
|
||||
<?php if($i > 0) $modules['ditto'] = $lang->testcase->ditto;?>
|
||||
<?php echo html::select("module[{$case->id}]", $modules, $i == 0 ? 0 : 'ditto', "class='form-control chosen'");?>
|
||||
<?php $importedCaseModules = isset($importedModules[$case->id]) ? $importedModules[$case->id] : array();?>
|
||||
<?php echo html::select("module[{$case->id}]", array_diff_key($modules, $importedCaseModules), $i == 0 ? 0 : 'ditto', "class='form-control chosen'");?>
|
||||
</td>
|
||||
<td><?php echo zget($lang->testcase->typeList, $case->type);?></td>
|
||||
</tr>
|
||||
|
||||
@@ -359,6 +359,29 @@ class testsuiteModel extends model
|
||||
->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get imported case modules.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $libID
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getImportedModules($productID, $libID)
|
||||
{
|
||||
$importedModules = $this->dao->select('fromCaseID,module')->from(TABLE_CASE)
|
||||
->where('product')->eq($productID)
|
||||
->andWhere('lib')->eq($libID)
|
||||
->andWhere('fromCaseID')->ne('')
|
||||
->andWhere('deleted')->eq(0)
|
||||
->fetchGroup('fromCaseID', 'module');
|
||||
foreach($importedModules as $fromCaseID => $modules) $importedModules[$fromCaseID] = array_combine(array_keys($modules), array_keys($modules));
|
||||
|
||||
return $importedModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build testsuite menu.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user