* Add js for testcase::batchCreate, and modify ajax methods.
This commit is contained in:
@@ -1889,11 +1889,11 @@ class story extends control
|
||||
* @param string $type
|
||||
* @param bool $hasParent
|
||||
* @param int $executionID
|
||||
* @param int $number
|
||||
* @param int $isHTML
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetProductStories($productID, $branch = 0, $moduleID = 0, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1, $executionID = 0, $number = '')
|
||||
public function ajaxGetProductStories($productID, $branch = 0, $moduleID = 0, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1, $executionID = 0, $isHTML = 1)
|
||||
{
|
||||
if($moduleID)
|
||||
{
|
||||
@@ -1922,8 +1922,15 @@ class story extends control
|
||||
|
||||
if(!in_array($this->app->tab, array('execution', 'project')) and empty($stories)) $stories = $this->story->getProductStoryPairs($productID, $branch, 0, $storyStatus, 'id_desc', $limit, $type, 'story', $hasParent);
|
||||
|
||||
if($isHTML == 0)
|
||||
{
|
||||
$storyList = array();
|
||||
foreach($stories as $storyID => $storyName) $storyList[] = array('value' => $storyID, 'text' => $storyName);
|
||||
return $this->send($storyList);
|
||||
}
|
||||
|
||||
$storyID = isset($stories[$storyID]) ? $storyID : 0;
|
||||
$select = html::select('story' . $number, empty($stories) ? array('' => '') : $stories, $storyID, "class='form-control'");
|
||||
$select = html::select('story', empty($stories) ? array('' => '') : $stories, $storyID, "class='form-control'");
|
||||
|
||||
/* If only need options, remove select wrap. */
|
||||
if($onlyOption == 'true') return print(substr($select, strpos($select, '>') + 1, -10));
|
||||
|
||||
@@ -2696,18 +2696,20 @@ class testcase extends control
|
||||
public function ajaxGetScenesForBC($productID, $branch = 0, $moduleID = 0, $stype = 1, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1, $number = '', $currentScene = 0)
|
||||
{
|
||||
$optionMenu = $this->testcase->getSceneMenu($productID, $moduleID, 'case', 0, $branch, $currentScene);
|
||||
$optionMenu['ditto'] = $this->lang->testcase->ditto;
|
||||
|
||||
if($stype == 1)
|
||||
{
|
||||
$optionMenu['ditto'] = $this->lang->testcase->ditto;
|
||||
$output = html::select("parent", $optionMenu, "", "class='form-control'");
|
||||
return print($output);
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = html::select("scene" . $number, $optionMenu, array('' => ''), "class='form-control'");
|
||||
$scenes = array();
|
||||
foreach($optionMenu as $sceneID => $sceneName) $scenes[] = array('value' => $sceneID, 'text' => $sceneName);
|
||||
return $this->send($scenes);
|
||||
}
|
||||
|
||||
die($output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
function onModuleChanged(event)
|
||||
{
|
||||
const $target = $(event.target);
|
||||
const $currentRow = $target.closest('tr');
|
||||
const moduleID = $target.val();
|
||||
|
||||
loadStories(productID, moduleID, 0, $currentRow);
|
||||
loadScenes(productID, moduleID, $currentRow);
|
||||
}
|
||||
|
||||
function loadScenes(productID, moduleID, $currentRow)
|
||||
{
|
||||
let branchID = $currentRow.find('.form-batch-input[data-name="branch"]').val();
|
||||
let sceneLink = $.createLink('testcase', 'ajaxGetScenesForBC', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&stype=2&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1');
|
||||
$.getJSON(sceneLink, function(scenes)
|
||||
{
|
||||
if(!scenes) return;
|
||||
|
||||
let $row = $currentRow;
|
||||
while($row.length)
|
||||
{
|
||||
const $scene = $row.find('.form-batch-input[data-name="scene"]').empty();
|
||||
|
||||
$.each(scenes, function(index, scene)
|
||||
{
|
||||
$scene.append('<option value="' + scene.value + '">' + scene.text + '</option>');
|
||||
});
|
||||
|
||||
$row = $row.next('tr');
|
||||
|
||||
if(!$row.find('td[data-name="scene"][data-ditto="on"]').length || !$row.find('td[data-name="module"][data-ditto="on"]').length) break;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -27,29 +27,35 @@ $(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadStories(productID, moduleID, num)
|
||||
function loadStories(productID, moduleID, num, $currentRow = null)
|
||||
{
|
||||
var branchIDName = (config.currentMethod == 'batchcreate' || config.currentMethod == 'showimport') ? '#branch' : '#branches';
|
||||
var branchID = $(branchIDName + num).val();
|
||||
var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=0&type=full&hasParent=1&executionID=0&number=' + num);
|
||||
$.get(storyLink, function(stories)
|
||||
var branchID = config.currentMethod == 'batchcreate' ? $(branchIDName + '_' + num).val() : $(branchIDName + num).val();
|
||||
var storyLink = $.createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=0&type=full&hasParent=1&executionID=0&number=' + num);
|
||||
$.getJSON(storyLink, function(stories)
|
||||
{
|
||||
if(!stories) stories = '<select id="story' + num + '" name="story[' + num + ']" class="form-control"></select>';
|
||||
if(config.currentMethod == 'batchcreate')
|
||||
{
|
||||
for(var i = num; i <= rowIndex ; i ++)
|
||||
if(!stories) return;
|
||||
|
||||
let $row = $currentRow;
|
||||
while($row.length)
|
||||
{
|
||||
if(i != num && $('#module' + i).val() != 'ditto') break;
|
||||
var nowStories = stories.replaceAll('story' + num, 'story' + i);
|
||||
$('#story' + i).replaceWith(nowStories);
|
||||
$('#story' + i + "_chosen").remove();
|
||||
$('#story' + i).next('.picker').remove();
|
||||
$('#story' + i).attr('name', 'story[' + i + ']');
|
||||
$('#story' + i).picker();
|
||||
const $story = $row.find('.form-batch-input[data-name="story"]').empty();
|
||||
|
||||
$.each(stories, function(index, story)
|
||||
{
|
||||
$story.append('<option value="' + story.value + '">' + story.text + '</option>');
|
||||
});
|
||||
|
||||
$row = $row.next('tr');
|
||||
|
||||
if(!$row.find('td[data-name="story"][data-ditto="on"]').length || !$row.find('td[data-name="branch"][data-ditto="on"]').length) break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!stories) stories = '<select id="story' + num + '" name="story[' + num + ']" class="form-control"></select>';
|
||||
$('#story' + num).replaceWith(stories);
|
||||
$('#story' + num + "_chosen").remove();
|
||||
$('#story' + num).next('.picker').remove();
|
||||
@@ -58,3 +64,42 @@ function loadStories(productID, moduleID, num)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set modules.
|
||||
*
|
||||
* @param int $branchID
|
||||
* @param int $productID
|
||||
* @param int $num
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setModules(event)
|
||||
{
|
||||
const $target = $(event.target);
|
||||
const $currentRow = $target.closest('tr');
|
||||
const branchID = $target.val();
|
||||
const moduleID = $currentRow.find('.form-batch-input[data-name="module"]').val();
|
||||
|
||||
$.getJSON($.createLink('tree', 'ajaxGetModules', 'productID=' + productID + '&viewType=case&branch=' + branchID + '&number=0¤tModuleID=' + moduleID), function(data)
|
||||
{
|
||||
if(!data || !data.modules) return;
|
||||
|
||||
let $row = $currentRow;
|
||||
while($row.length)
|
||||
{
|
||||
const $module = $row.find('.form-batch-input[data-name="module"]').empty();
|
||||
|
||||
$.each(data.modules, function(index, module)
|
||||
{
|
||||
$module.append('<option value="' + module.value + '"' + (module.value == data.currentModuleID ? 'selected' : '') + '>' + module.text + '</option>');
|
||||
});
|
||||
|
||||
$row = $row.next('tr');
|
||||
|
||||
if(!$row.find('td[data-name="module"][data-ditto="on"]').length || !$row.find('td[data-name="branch"][data-ditto="on"]').length) break;
|
||||
}
|
||||
});
|
||||
|
||||
loadStories(productID, moduleID, 0, $currentRow);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ declare(strict_types=1);
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
jsVar('productID', $productID);
|
||||
|
||||
$visibleFields = array();
|
||||
$requiredFields = array();
|
||||
foreach(explode(',', $showFields) as $field)
|
||||
@@ -78,6 +80,34 @@ $items[] = array
|
||||
'ditto' => true,
|
||||
);
|
||||
|
||||
/* Field of type. */
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'type',
|
||||
'label' => $lang->testcase->type,
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->typeList,
|
||||
'value' => 1,
|
||||
'width' => '160px',
|
||||
'required' => true,
|
||||
'ditto' => true,
|
||||
);
|
||||
|
||||
/* Field of stage. */
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'stage',
|
||||
'label' => $lang->testcase->stage,
|
||||
'hidden' => zget($visibleFields, 'stage', true, false),
|
||||
'control' => array(
|
||||
'type' => 'select',
|
||||
'items' => $lang->testcase->stageList,
|
||||
'value' => '',
|
||||
'multiple' => true,
|
||||
),
|
||||
'width' => '160px',
|
||||
);
|
||||
|
||||
/* Field of story. */
|
||||
$items[] = array
|
||||
(
|
||||
@@ -100,19 +130,6 @@ $items[] = array
|
||||
'required' => true,
|
||||
);
|
||||
|
||||
/* Field of type. */
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'type',
|
||||
'label' => $lang->testcase->type,
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->typeList,
|
||||
'value' => 1,
|
||||
'width' => '160px',
|
||||
'required' => true,
|
||||
'ditto' => true,
|
||||
);
|
||||
|
||||
/* Field of pri. */
|
||||
$items[] = array
|
||||
(
|
||||
@@ -127,6 +144,19 @@ $items[] = array
|
||||
'ditto' => true,
|
||||
);
|
||||
|
||||
/* Field of review. */
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'review',
|
||||
'label' => $lang->testcase->review,
|
||||
'hidden' => zget($visibleFields, 'review', true, false),
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->reviewList,
|
||||
'value' => $needReview,
|
||||
'width' => '160px',
|
||||
'ditto' => true,
|
||||
);
|
||||
|
||||
/* Field of precondition. */
|
||||
$items[] = array
|
||||
(
|
||||
@@ -147,39 +177,11 @@ $items[] = array
|
||||
'required' => isset($requiredFields['keywords']),
|
||||
);
|
||||
|
||||
/* Field of stage. */
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'stage',
|
||||
'label' => $lang->testcase->stage,
|
||||
'hidden' => zget($visibleFields, 'stage', true, false),
|
||||
'control' => array(
|
||||
'type' => 'select',
|
||||
'items' => $lang->testcase->stageList,
|
||||
'value' => '',
|
||||
'multiple' => true,
|
||||
),
|
||||
'width' => '160px',
|
||||
);
|
||||
|
||||
/* Field of review. */
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'review',
|
||||
'label' => $lang->testcase->review,
|
||||
'hidden' => zget($visibleFields, 'review', true, false),
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->reviewList,
|
||||
'value' => $needReview,
|
||||
'width' => '160px',
|
||||
'ditto' => true,
|
||||
);
|
||||
|
||||
formBatchPanel
|
||||
(
|
||||
set::items($items),
|
||||
// on::change('[data-name="branch"]', 'setModules'),
|
||||
// on::change('[data-name="module"]', 'onModuleChanged'),
|
||||
on::change('[data-name="branch"]', 'setModules'),
|
||||
on::change('[data-name="module"]', 'onModuleChanged'),
|
||||
);
|
||||
|
||||
render();
|
||||
|
||||
@@ -658,7 +658,7 @@ class tree extends control
|
||||
$modules = $this->tree->getOptionMenu($productID, $viewType, $startModuleID = 0, $branchID);
|
||||
$modules = empty($modules) ? array('' => '/') : $modules;
|
||||
|
||||
if($viewType == 'bug')
|
||||
if($viewType == 'bug' || $viewType == 'case')
|
||||
{
|
||||
$moduleList = array();
|
||||
foreach($modules as $moduleID => $moduleName) $moduleList[] = array('value' => $moduleID, 'text' => $moduleName);
|
||||
|
||||
Reference in New Issue
Block a user