* Finish task #107886,#107887.
This commit is contained in:
@@ -312,6 +312,7 @@ $config->openMethods[] = 'system.editdomain';
|
||||
$config->openMethods[] = 'doc.uploaddocs';
|
||||
$config->openMethods[] = 'cron.schedule';
|
||||
$config->openMethods[] = 'cron.consume';
|
||||
$config->openMethods[] = 'caselib.importfromlib';
|
||||
|
||||
$config->openModules = array();
|
||||
$config->openModules[] = 'install';
|
||||
|
||||
@@ -560,6 +560,28 @@ class caselib extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Import case from lib to caseLib.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param int $libID
|
||||
* @param string $orderBy
|
||||
* @param string $browseType
|
||||
* @param int $queryID
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @param int $projectID
|
||||
* @param bool $toLib
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function importFromLib($productID, $branch = 0, $libID = 0, $orderBy = 'id_desc', $browseType = '', $queryID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0, $toLib = true)
|
||||
{
|
||||
echo $this->fetch('testcase', 'importFromLib', "productID=$productID&libID=$libID&branch=$branch&orderBy=$orderBy&browseType=$browseType&queryID=$queryID&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID&projectID=$projectID&toLib=$toLib");
|
||||
}
|
||||
|
||||
/**
|
||||
* Show import case.
|
||||
*
|
||||
|
||||
@@ -59,7 +59,17 @@ js::set('flow', $config->global->flow);
|
||||
?>
|
||||
<div class='btn-group'>
|
||||
<?php common::printLink('caselib', 'exportTemplate', "libID=$libID", "<i class='icon icon-export muted'> </i> " . $lang->caselib->exportTemplate, '', "class='btn btn-link export' data-width='40%'");?>
|
||||
<?php common::printLink('caselib', 'import', "libID=$libID", "<i class='icon muted icon-import'> </i> " . $lang->testcase->fileImport, '', "class='btn btn-link export'");?>
|
||||
<div class='btn-group'>
|
||||
<button type='button' class='btn btn-link dropdown-toggle' data-toggle='dropdown' id='importAction'><i class='icon icon-import muted'></i> <span class='caret'></span></button>
|
||||
<ul class='dropdown-menu pull-right' id='importActionMenu'>
|
||||
<?php
|
||||
if(common::hasPriv('caselib', 'import')) echo "<li>" . html::a($this->createlink('caselib', 'import', "libID=$libID"), $lang->testcase->fileImport, '', "class='export' data-app={$app->tab}") . "</li>";
|
||||
|
||||
$link = $this->createLink('caselib', 'importFromLib', "productID=0&branch=0&libID=0&orderBy=id_desc&browseType=&queryID=10");
|
||||
if(common::hasPriv('testcase', 'importFromLib')) echo "<li>" . html::a($link, $lang->testcase->importFromLib, '', "data-app={$app->tab}") . "</li>";
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo html::a($this->createLink('caselib', 'create'), "<i class='icon icon-plus'> </i> " . $lang->caselib->create, '', 'class="btn btn-secondary"');?>
|
||||
<div class='btn-group dropdown'>
|
||||
|
||||
@@ -244,6 +244,12 @@ class testcase extends control
|
||||
}
|
||||
}
|
||||
|
||||
$sceneCases = array_merge($scenes, $cases);
|
||||
if($browseType == 'bysearch')
|
||||
{
|
||||
$sceneCases = $this->testcase->processSearchedData($scenes, $cases);
|
||||
}
|
||||
|
||||
/* Assign. */
|
||||
$tree = $moduleID ? $this->tree->getByID($moduleID) : '';
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->common;
|
||||
@@ -266,7 +272,7 @@ class testcase extends control
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->param = $param;
|
||||
$this->view->caseType = $caseType;
|
||||
$this->view->cases = array_merge($scenes, $cases);
|
||||
$this->view->cases = $sceneCases;
|
||||
$this->view->branch = (!empty($product) and $product->type != 'normal') ? $branch : 0;
|
||||
$this->view->branchOption = $branchOption;
|
||||
$this->view->branchTagOption = $branchTagOption;
|
||||
@@ -2064,7 +2070,7 @@ class testcase extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* Import case from lib.
|
||||
* Import case from lib to cases or to caseLib.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
@@ -2073,21 +2079,27 @@ class testcase extends control
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @param bool $toLib
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function importFromLib($productID, $branch = 0, $libID = 0, $orderBy = 'id_desc', $browseType = '', $queryID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0)
|
||||
public function importFromLib($productID, $branch = 0, $libID = 0, $orderBy = 'id_desc', $browseType = '', $queryID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0, $toLib = false)
|
||||
{
|
||||
$browseType = strtolower($browseType);
|
||||
$queryID = (int)$queryID;
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
$product = $productID ? $this->loadModel('product')->getById($productID) : 0;
|
||||
$branches = array();
|
||||
if($branch == '') $branch = 0;
|
||||
|
||||
$this->loadModel('branch');
|
||||
if($product->type != 'normal') $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $this->branch->getPairs($productID, 'active', $projectID);
|
||||
if(!$toLib && $product->type != 'normal') $branches = array(BRANCH_MAIN => $this->lang->branch->main) + $this->branch->getPairs($productID, 'active', $projectID);
|
||||
|
||||
$libraries = $this->loadModel('caselib')->getLibraries();
|
||||
if($toLib)
|
||||
{
|
||||
$currentLib = $this->session->caseLib;
|
||||
unset($libraries[$currentLib]);
|
||||
}
|
||||
if(empty($libraries))
|
||||
{
|
||||
echo js::alert($this->lang->testcase->noLibrary);
|
||||
@@ -2097,14 +2109,14 @@ class testcase extends control
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$this->testcase->importFromLib($productID, $libID, $branch);
|
||||
$this->testcase->importFromLib($productID, $libID, $branch, $toLib ? $currentLib : 0);
|
||||
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");
|
||||
$actionURL = $this->createLink($toLib ? 'caselib' : 'testcase', 'importFromLib', "productID=$productID&branch=$branch&libID=$libID&orderBy=$orderBy&browseType=bySearch&queryID=myQueryID");
|
||||
$this->config->testcase->search['module'] = 'testsuite';
|
||||
$this->config->testcase->search['onMenuBar'] = 'no';
|
||||
$this->config->testcase->search['actionURL'] = $actionURL;
|
||||
@@ -2119,7 +2131,7 @@ class testcase extends control
|
||||
|
||||
$this->loadModel('testsuite');
|
||||
foreach($branches as $branchID => $branchName) $canImportModules[$branchID] = $this->testsuite->getCanImportModules($productID, $libID, $branchID);
|
||||
if(empty($branches)) $canImportModules[0] = $this->testsuite->getCanImportModules($productID, $libID, 0);
|
||||
if(empty($branches)) $canImportModules[0] = $this->testsuite->getCanImportModules($productID, $libID, 0, $toLib ? $currentLib : 0);
|
||||
|
||||
/* Load pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -2141,6 +2153,7 @@ class testcase extends control
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->queryID = $queryID;
|
||||
$this->view->canImportModules = $canImportModules;
|
||||
$this->view->toLib = $toLib;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ $(function()
|
||||
*/
|
||||
function reload(libID)
|
||||
{
|
||||
link = createLink('testcase','importFromLib','productID='+ productID + '&branch=' + branch + '&libID='+libID);
|
||||
link = createLink(module,'importFromLib','productID='+ productID + '&branch=' + branch + '&libID='+libID);
|
||||
location.href = link;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@ $lang->testcase->reviewList[0] = 'Nein';
|
||||
$lang->testcase->reviewList[1] = 'Ja';
|
||||
|
||||
$lang->testcase->autoList = array();
|
||||
$lang->testcase->autoList[''] = '';
|
||||
$lang->testcase->autoList['auto'] = 'Yes';
|
||||
$lang->testcase->autoList['no'] = 'No';
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@ $lang->testcase->reviewList[0] = 'NO';
|
||||
$lang->testcase->reviewList[1] = 'YES';
|
||||
|
||||
$lang->testcase->autoList = array();
|
||||
$lang->testcase->autoList[''] = '';
|
||||
$lang->testcase->autoList['auto'] = 'Yes';
|
||||
$lang->testcase->autoList['no'] = 'No';
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@ $lang->testcase->reviewList[0] = 'NON';
|
||||
$lang->testcase->reviewList[1] = 'OUI';
|
||||
|
||||
$lang->testcase->autoList = array();
|
||||
$lang->testcase->autoList[''] = '';
|
||||
$lang->testcase->autoList['auto'] = 'Yes';
|
||||
$lang->testcase->autoList['no'] = 'No';
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@ $lang->testcase->reviewList[0] = '否';
|
||||
$lang->testcase->reviewList[1] = '是';
|
||||
|
||||
$lang->testcase->autoList = array();
|
||||
$lang->testcase->autoList[''] = '';
|
||||
$lang->testcase->autoList['auto'] = '是';
|
||||
$lang->testcase->autoList['no'] = '否';
|
||||
|
||||
|
||||
@@ -666,7 +666,7 @@ class testcaseModel extends model
|
||||
->beginIF($this->app->tab == 'project' and $this->config->systemMode == 'new')->andWhere('t2.project')->eq($this->session->project)->fi()
|
||||
->beginIF($this->app->tab == 'project' and !empty($productID) and $queryProductID != 'all')->andWhere('t2.product')->eq($productID)->fi()
|
||||
->beginIF($this->app->tab != 'project' and !empty($productID) and $queryProductID != 'all')->andWhere('t1.product')->eq($productID)->fi()
|
||||
->beginIF($auto != 'unit')->andWhere('t1.auto')->ne('unit')->fi()
|
||||
->beginIF($auto != 'unit' && strpos($caseQuery, "`auto` = '") === false)->andWhere('t1.auto')->ne('unit')->fi()
|
||||
->beginIF($auto == 'unit')->andWhere('t1.auto')->eq('unit')->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy($orderBy)->page($pager)->fetchAll('id');
|
||||
@@ -1899,10 +1899,11 @@ class testcaseModel extends model
|
||||
* @param int $productID
|
||||
* @param int $libID
|
||||
* @param int $branch
|
||||
* @param int $toLib
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function importFromLib($productID, $libID, $branch)
|
||||
public function importFromLib($productID, $libID, $branch, $toLib = 0)
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
|
||||
@@ -1927,7 +1928,7 @@ class testcaseModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
$caseModules[$branch] = $this->loadModel('testsuite')->getCanImportModules($productID, $libID, $branch);
|
||||
$caseModules[$branch] = $this->loadModel('testsuite')->getCanImportModules($productID, $libID, $branch, $toLib);
|
||||
}
|
||||
|
||||
$libCases = $this->dao->select('*')->from(TABLE_CASE)->where('deleted')->eq(0)->andWhere('id')->in($data->caseIdList)->fetchAll('id');
|
||||
@@ -1951,6 +1952,7 @@ class testcaseModel extends model
|
||||
continue;
|
||||
}
|
||||
|
||||
if($toLib) $case->lib = $toLib;
|
||||
$this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->exec();
|
||||
if(dao::isError()) continue;
|
||||
|
||||
@@ -4318,4 +4320,47 @@ class testcaseModel extends model
|
||||
// Return node as array
|
||||
return array($xml->getName() => $propertiesArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process searched data.
|
||||
*
|
||||
* @param array $scenes
|
||||
* @param array $cases
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function processSearchedData($scenes, $cases)
|
||||
{
|
||||
$casePairs = array();
|
||||
foreach($cases as $case) $casePairs[$case->id] = $case;
|
||||
|
||||
$this->processScenes($scenes, $casePairs);
|
||||
|
||||
foreach($cases as $key => $case)
|
||||
{
|
||||
if($case->scene) unset($cases[$key]);
|
||||
}
|
||||
|
||||
return array_merge($scenes, $cases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process searched scenes data.
|
||||
*
|
||||
* @param int $scenes
|
||||
* @param int $casePairs
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function processScenes($scenes, $casePairs)
|
||||
{
|
||||
foreach($scenes as $scene)
|
||||
{
|
||||
foreach($scene->cases as $key => $value)
|
||||
{
|
||||
if(!isset($casePairs[$key])) unset($scene->cases[$key]);
|
||||
}
|
||||
if(!empty($scene->children)) $this->processScenes($scene->children, $casePairs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<?php js::set('flow', $config->global->flow);?>
|
||||
<?php js::set('ditto', $lang->testcase->ditto);?>
|
||||
<?php js::set('canImportModules', $canImportModules);?>
|
||||
<?php js::set('module', $this->app->rawModule);?>
|
||||
<div id='mainMenu' class='clearfix'>
|
||||
<div class='btn-toolbar pull-left'>
|
||||
<div class='input-group w-300px'>
|
||||
@@ -35,7 +36,7 @@
|
||||
</div>
|
||||
<?php common::printOrderLink('id', $orderBy, $vars, $lang->idAB);?>
|
||||
</th>
|
||||
<?php if($product->type != 'normal'):?>
|
||||
<?php if(!$toLib && $product->type != 'normal'):?>
|
||||
<th class='c-branch'><?php echo $lang->testcase->branch ?></th>
|
||||
<?php endif;?>
|
||||
<th class='c-pri' title=<?php echo $lang->pri;?>><?php common::printOrderLink('pri', $orderBy, $vars, $lang->priAB);?></th>
|
||||
@@ -49,16 +50,23 @@
|
||||
<?php $i = 0;?>
|
||||
<?php foreach($cases as $id => $case):?>
|
||||
<?php
|
||||
$caseBranches = $branches;
|
||||
$caseBranch = ($branch == 'all' or empty($branch)) ? 0 : $branch;
|
||||
foreach($caseBranches as $branchID => $branchName)
|
||||
if(!$toLib)
|
||||
{
|
||||
if(empty($canImportModules[$branchID][$case->id]))
|
||||
$caseBranches = $branches;
|
||||
$caseBranch = ($branch == 'all' or empty($branch)) ? 0 : $branch;
|
||||
foreach($caseBranches as $branchID => $branchName)
|
||||
{
|
||||
unset($caseBranches[$branchID]);
|
||||
if($caseBranch == $branchID) $caseBranch = key($caseBranches);
|
||||
if(empty($canImportModules[$branchID][$case->id]))
|
||||
{
|
||||
unset($caseBranches[$branchID]);
|
||||
if($caseBranch == $branchID) $caseBranch = key($caseBranches);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$caseBranch = 0;
|
||||
}
|
||||
?>
|
||||
<tr id='<?php echo $case->id;?>'>
|
||||
<td class='c-id'>
|
||||
@@ -68,7 +76,7 @@
|
||||
</div>
|
||||
<?php printf('%03d', $case->id);?>
|
||||
</td>
|
||||
<?php if($product->type != 'normal'):?>
|
||||
<?php if(!$toLib && $product->type != 'normal'):?>
|
||||
<td><?php echo html::select("branch[{$case->id}]", $caseBranches, $caseBranch, "class='form-control' onchange='updateModules($productID, this.value, $case->id)'")?></td>
|
||||
<?php endif;?>
|
||||
<td><span class='label-pri <?php echo 'label-pri-' . $case->pri;?>' title='<?php echo zget($lang->testcase->priList, $case->pri, $case->pri);?>'><?php echo $case->pri == '0' ? '' : zget($lang->testcase->priList, $case->pri, $case->pri);?></span></td>
|
||||
@@ -77,7 +85,7 @@
|
||||
<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) unset($canImportModules[$caseBranch][$case->id]['ditto']);?>
|
||||
<?php echo html::select("module[{$case->id}]", $canImportModules[$caseBranch][$case->id], $i == 0 ? 0 : 'ditto', "class='form-control chosen'");?>
|
||||
<?php echo html::select("module[{$case->id}]", isset($canImportModules[$caseBranch][$case->id]) ? $canImportModules[$caseBranch][$case->id] : array(), $i == 0 ? 0 : 'ditto', "class='form-control chosen'");?>
|
||||
</td>
|
||||
<td><?php echo zget($lang->testcase->typeList, $case->type);?></td>
|
||||
</tr>
|
||||
|
||||
@@ -354,10 +354,11 @@ class testsuiteModel extends model
|
||||
|
||||
|
||||
$this->loadModel('branch');
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
$branches = $product->type != 'normal' ? array(BRANCH_MAIN => $this->lang->branch->main) + $this->branch->getPairs($productID, 'active') : array(0);
|
||||
$product = $productID ? $this->loadModel('product')->getById($productID) : 0;
|
||||
$branches = ($productID && $product->type != 'normal') ? array(BRANCH_MAIN => $this->lang->branch->main) + $this->branch->getPairs($productID, 'active') : array(0);
|
||||
$canImport = array();
|
||||
foreach($branches as $branchID => $branchName) $canImport += $this->getCanImportModules($productID, $libID, $branchID);
|
||||
if(!$productID && !$branch) $canImport = $this->getCanImportModules($productID, $libID, $branchID);
|
||||
|
||||
return $this->dao->select('*')->from(TABLE_CASE)->where('deleted')->eq(0)
|
||||
->beginIF($browseType != 'bysearch')->andWhere('lib')->eq($libID)->fi()
|
||||
@@ -375,14 +376,15 @@ class testsuiteModel extends model
|
||||
* @param int $productID
|
||||
* @param int $libID
|
||||
* @param int $branch
|
||||
* @param int $toLib
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getCanImportModules($productID, $libID, $branch)
|
||||
public function getCanImportModules($productID, $libID, $branch, $toLib = 0)
|
||||
{
|
||||
$importedModules = $this->dao->select('fromCaseID,module')->from(TABLE_CASE)
|
||||
->where('product')->eq($productID)
|
||||
->andWhere('lib')->eq($libID)
|
||||
->andWhere('lib')->eq($toLib ? $toLib : $libID)
|
||||
->andWhere('branch')->eq($branch)
|
||||
->andWhere('fromCaseID')->ne('')
|
||||
->andWhere('deleted')->eq(0)
|
||||
@@ -391,7 +393,14 @@ class testsuiteModel extends model
|
||||
|
||||
$libCases = $this->loadModel('caselib')->getLibCases($libID, 'all');
|
||||
|
||||
$modules = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch);
|
||||
if(empty($toLib))
|
||||
{
|
||||
$modules = $this->loadModel('tree')->getOptionMenu($productID, 'case', 0, $branch);
|
||||
}
|
||||
else
|
||||
{
|
||||
$modules = $this->loadModel('tree')->getOptionMenu($toLib, 'caselib');
|
||||
}
|
||||
|
||||
$canImportModules = array();
|
||||
foreach($libCases as $caseID => $case)
|
||||
|
||||
Reference in New Issue
Block a user