* Refactor batch edit view.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
window.handleRenderRow = function($row, index, row)
|
||||
{
|
||||
/* Set the branches for the row. */
|
||||
let $branch = $row.find('.form-batch-input[data-name=branch]').empty();
|
||||
let currentProduct = productID ? productID : row.product;
|
||||
|
||||
if(products[currentProduct] != undefined && products[currentProduct].type != 'normal' && branchPairs[currentProduct] != undefined)
|
||||
{
|
||||
$branch.removeAttr('disabled');
|
||||
|
||||
let branches = branchPairs[currentProduct];
|
||||
$.each(branches, function(branchID, branchName){$branch.append('<option value="' + branchID + '">' + branchName + '</option>');});
|
||||
}
|
||||
else
|
||||
{
|
||||
$branch.attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
/* Set the modules for the row. */
|
||||
let $module = $row.find('.form-batch-input[data-name=module]').empty();
|
||||
let modules = modulePairs[row.id];
|
||||
$.each(modules, function(moduleID, moduleName){ $module.append('<option value="' + moduleID + '">' + moduleName + '</option>'); });
|
||||
|
||||
/* Set the scenes for the row. */
|
||||
let $scene = $row.find('.form-batch-input[data-name=scene]').empty();
|
||||
let scenes = scenePairs[row.id];
|
||||
$.each(scenes, function(sceneID, sceneName){ $scene.append('<option value="' + sceneID + '">' + sceneName + '</option>'); });
|
||||
}
|
||||
|
||||
function loadBranches()
|
||||
{
|
||||
const $target = $(event.target);
|
||||
const $currentRow = $target.closest('tr');
|
||||
const branch = $target.val();
|
||||
const caseID = $currentRow.find('.form-batch-input[data-name=caseIdList]').val();
|
||||
const product = productID ? productID : cases[caseID].product;
|
||||
console.log(cases);
|
||||
const oldBranch = cases[caseID].branch;
|
||||
|
||||
if(typeof(branch) == 'undefined') branch = 0;
|
||||
if(!branch) branch = 0;
|
||||
|
||||
var result = true;
|
||||
if(branch)
|
||||
{
|
||||
var endLoop = false;
|
||||
for(index in testtasks)
|
||||
{
|
||||
if(endLoop) break;
|
||||
if(index == caseID)
|
||||
{
|
||||
endLoop = true;
|
||||
for(taskID in testtasks[index])
|
||||
{
|
||||
if(branch != oldBranch && testtasks[index][taskID]['branch'] != branch)
|
||||
{
|
||||
var tip = confirmUnlinkTesttask.replace("%s", caseID);
|
||||
result = confirm(tip);
|
||||
if(!result) $('#branch' + caseID).val(oldBranch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(result)
|
||||
{
|
||||
var currentModuleID = $('#module' + caseID).val();
|
||||
moduleLink = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + product + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=' + caseID + '&needManage=false&extra=nodeleted¤tModuleID=' + currentModuleID);
|
||||
$('#module' + caseID).parent('td').load(moduleLink);
|
||||
|
||||
loadStories(product, 0, caseID);
|
||||
}
|
||||
}
|
||||
@@ -17,3 +17,44 @@ $(document).off('click', '.batch-btn').on('click', '.batch-btn', function()
|
||||
postAndLoadPage(url, form);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Set stories.
|
||||
*
|
||||
* @param int productID
|
||||
* @param int moduleID
|
||||
* @param int num
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadStories(productID, moduleID, num)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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(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();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#story' + num).replaceWith(stories);
|
||||
$('#story' + num + "_chosen").remove();
|
||||
$('#story' + num).next('.picker').remove();
|
||||
$('#story' + num).attr('name', 'story[' + num + ']');
|
||||
$('#story' + num).picker();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+20
-20
@@ -1102,47 +1102,47 @@ class testcaseModel extends model
|
||||
$allChanges = array();
|
||||
$now = helper::now();
|
||||
$data = fixer::input('post')->get();
|
||||
$caseIDList = $this->post->caseIDList;
|
||||
$caseIdList = array_keys($this->post->caseIdList);
|
||||
|
||||
/* Process data if the value is 'ditto'. */
|
||||
foreach($caseIDList as $caseID)
|
||||
foreach($caseIdList as $caseID)
|
||||
{
|
||||
if($data->pris[$caseID] == 'ditto') $data->pris[$caseID] = isset($prev['pri']) ? $prev['pri'] : 3;
|
||||
if($data->modules[$caseID] == 'ditto') $data->modules[$caseID] = isset($prev['module']) ? $prev['module'] : 0;
|
||||
if($data->pri[$caseID] == 'ditto') $data->pri[$caseID] = isset($prev['pri']) ? $prev['pri'] : 3;
|
||||
if($data->module[$caseID] == 'ditto') $data->module[$caseID] = isset($prev['module']) ? $prev['module'] : 0;
|
||||
if($data->scene[$caseID] == 'ditto') $data->scene[$caseID] = isset($prev['scene']) ? $prev['scene'] : 0;
|
||||
if($data->types[$caseID] == 'ditto') $data->types[$caseID] = isset($prev['type']) ? $prev['type'] : '';
|
||||
if($data->story[$caseID] == '') $data->story[$caseID] = 0;
|
||||
if($data->story[$caseID] == 'ditto') $data->story[$caseID] = isset($prev['story']) ? $prev['story'] : 0;
|
||||
if(isset($data->branches[$caseID]) and $data->branches[$caseID] == 'ditto') $data->branches[$caseID] = isset($prev['branch']) ? $prev['branch'] : 0;
|
||||
if($data->type[$caseID] == 'ditto') $data->type[$caseID] = isset($prev['type']) ? $prev['type'] : '';
|
||||
if($data->story[$caseID] == '') $data->story[$caseID] = 0;
|
||||
if($data->story[$caseID] == 'ditto') $data->story[$caseID] = isset($prev['story']) ? $prev['story'] : 0;
|
||||
if(isset($data->branch[$caseID]) and $data->branch[$caseID] == 'ditto') $data->branch[$caseID] = isset($prev['branch']) ? $prev['branch'] : 0;
|
||||
|
||||
$prev['pri'] = $data->pris[$caseID];
|
||||
$prev['type'] = $data->types[$caseID];
|
||||
$prev['pri'] = $data->pri[$caseID];
|
||||
$prev['type'] = $data->type[$caseID];
|
||||
$prev['story'] = $data->story[$caseID];
|
||||
$prev['module'] = $data->modules[$caseID];
|
||||
$prev['module'] = $data->module[$caseID];
|
||||
$prev['scene'] = $data->scene[$caseID];
|
||||
if(isset($data->branches)) $prev['branch'] = $data->branches[$caseID];
|
||||
if(isset($data->branch)) $prev['branch'] = $data->branch[$caseID];
|
||||
}
|
||||
|
||||
/* Initialize cases from the post data.*/
|
||||
$extendFields = $this->getFlowExtendFields();
|
||||
foreach($caseIDList as $caseID)
|
||||
foreach($caseIdList as $caseID)
|
||||
{
|
||||
$case = new stdclass();
|
||||
$case->id = $caseID;
|
||||
$case->lastEditedBy = $this->app->user->account;
|
||||
$case->lastEditedDate = $now;
|
||||
$case->pri = $data->pris[$caseID];
|
||||
$case->module = $data->modules[$caseID];
|
||||
$case->pri = $data->pri[$caseID];
|
||||
$case->module = $data->module[$caseID];
|
||||
$case->scene = $data->scene[$caseID];
|
||||
$case->status = $data->statuses[$caseID];
|
||||
$case->status = $data->status[$caseID];
|
||||
$case->story = $data->story[$caseID];
|
||||
$case->color = $data->color[$caseID];
|
||||
//$case->color = $data->color[$caseID];
|
||||
$case->title = $data->title[$caseID];
|
||||
$case->precondition = $data->precondition[$caseID];
|
||||
$case->keywords = $data->keywords[$caseID];
|
||||
$case->type = $data->types[$caseID];
|
||||
$case->stage = empty($data->stages[$caseID]) ? '' : implode(',', $data->stages[$caseID]);
|
||||
if(isset($data->branches[$caseID])) $case->branch = $data->branches[$caseID];
|
||||
$case->type = $data->type[$caseID];
|
||||
$case->stage = empty($data->stage[$caseID]) ? '' : implode(',', $data->stage[$caseID]);
|
||||
if(isset($data->branch[$caseID])) $case->branch = $data->branch[$caseID];
|
||||
|
||||
foreach($extendFields as $extendField)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The batch edit view file of testcase module of ZenTaoPMS.
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Tingting Dai <daitingting@easycorp.ltd>
|
||||
* @package testcase
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
jsVar('modulePairs', $modulePairs);
|
||||
jsVar('scenePairs', $scenePairs);
|
||||
jsVar('branchPairs', $branchTagOption);
|
||||
jsVar('productID', $productID);
|
||||
jsVar('products', $products);
|
||||
jsVar('cases', $cases);
|
||||
|
||||
if(isset($suhosinInfo))
|
||||
{
|
||||
div
|
||||
(
|
||||
set::class('alert warning'),
|
||||
$suhosinInfo
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$visibleFields = array();
|
||||
$requiredFields = array();
|
||||
foreach(explode(',', $showFields) as $field)
|
||||
{
|
||||
if(!$field) continue;
|
||||
$visibleFields[$field] = $field;
|
||||
}
|
||||
|
||||
foreach(explode(',', $config->testcase->edit->requiredFields) as $field)
|
||||
{
|
||||
if(!$field) continue;
|
||||
|
||||
$requiredFields[$field] = $field;
|
||||
|
||||
if(strpos(",{$config->testcase->customBatchEditFields},", ",{$field},") !== false) $visibleFields[$field] = $field;
|
||||
}
|
||||
|
||||
$items = array();
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'caseIdList',
|
||||
'label' => $lang->idAB,
|
||||
'control' => 'hidden',
|
||||
'hidden' => true,
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'id',
|
||||
'label' => $lang->idAB,
|
||||
'control' => 'index',
|
||||
'width' => '50px',
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'pri',
|
||||
'label' => $lang->priAB,
|
||||
'width' => '100px',
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->priList,
|
||||
'ditto' => true,
|
||||
'hidden' => !isset($visibleFields['pri']),
|
||||
'required' => isset($requiredFields['pri']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'status',
|
||||
'label' => $lang->statusAB,
|
||||
'width' => '80px',
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->statusList,
|
||||
'hidden' => !isset($visibleFields['status']),
|
||||
'required' => isset($requiredFields['status']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'branch',
|
||||
'label' => $lang->testcase->branch,
|
||||
'width' => '180px',
|
||||
'control' => 'select',
|
||||
'items' => array(),
|
||||
'hidden' => !$branchProduct,
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'module',
|
||||
'label' => $lang->testcase->module,
|
||||
'width' => '180px',
|
||||
'control' => 'select',
|
||||
'items' => array(),
|
||||
'hidden' => !isset($visibleFields['module']),
|
||||
'required' => isset($requiredFields['module']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'scene',
|
||||
'label' => $lang->testcase->scene,
|
||||
'width' => '180px',
|
||||
'control' => 'select',
|
||||
'items' => array(),
|
||||
'hidden' => ($isLibCase || !isset($visibleFields['scene'])),
|
||||
'required' => isset($requiredFields['scene']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'story',
|
||||
'label' => $lang->testcase->story,
|
||||
'control' => 'select',
|
||||
'width' => '180px',
|
||||
'items' => $stories,
|
||||
'hidden' => !isset($visibleFields['story']),
|
||||
'required' => isset($requiredFields['story']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'title',
|
||||
'label' => $lang->testcase->title,
|
||||
'control' => 'input',
|
||||
'required' => true,
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'type',
|
||||
'label' => $lang->testcase->type,
|
||||
'width' => '140px',
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->typeList,
|
||||
'ditto' => true,
|
||||
'required' => true,
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'precondition',
|
||||
'label' => $lang->testcase->precondition,
|
||||
'control' => 'editor',
|
||||
'hidden' => !isset($visibleFields['precondition']),
|
||||
'required' => isset($requiredFields['precondition']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'keywords',
|
||||
'label' => $lang->testcase->keywords,
|
||||
'control' => 'input',
|
||||
'hidden' => !isset($visibleFields['keywords']),
|
||||
'required' => isset($requiredFields['keywords']),
|
||||
);
|
||||
$items[] = array
|
||||
(
|
||||
'name' => 'stage',
|
||||
'label' => $lang->testcase->stage,
|
||||
'width' => '120px',
|
||||
'control' => 'select',
|
||||
'items' => $lang->testcase->stageList,
|
||||
'hidden' => !isset($visibleFields['stage']),
|
||||
'required' => isset($requiredFields['stage']),
|
||||
);
|
||||
|
||||
formBatchPanel
|
||||
(
|
||||
on::change('[data-name=branch]', 'loadBranches'),
|
||||
set::mode('edit'),
|
||||
set::data(array_values($cases)),
|
||||
set::items($items),
|
||||
set::onRenderRow(jsRaw('handleRenderRow')),
|
||||
);
|
||||
}
|
||||
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user