From 6d35ded99e098cdff1f04c7bc9e1ff1a2e6983a3 Mon Sep 17 00:00:00 2001 From: daitingting Date: Tue, 27 Jun 2023 07:00:34 +0000 Subject: [PATCH] * Refactor the createscene view. --- module/testcase/control.php | 9 +-- module/testcase/js/createscene.ui.js | 51 +++++++++++++ module/testcase/ui/createscene.html.php | 98 +++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 module/testcase/js/createscene.ui.js create mode 100644 module/testcase/ui/createscene.html.php diff --git a/module/testcase/control.php b/module/testcase/control.php index 121b06a52b..755c24ee73 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -2639,7 +2639,7 @@ class testcase extends control else { $changeFunc = ''; - if($viewType == 'bug' or $viewType == 'case') $changeFunc = "onchange='loadModuleRelatedNew()'"; + if($viewType == 'bug') $changeFunc = "onchange='loadModuleRelatedNew()'"; if($viewType == 'task') $changeFunc = ""; $field = $fieldID ? "modules[$fieldID]" : 'module'; @@ -2649,10 +2649,9 @@ class testcase extends control $output = html::select("$field", $optionMenu, $currentModuleID, "class='form-control' $changeFunc"); if(count($optionMenu) == 1 and $needManage) { - $output .= ""; - $output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType¤tModuleID=0&branch=$branch", '', true), $this->lang->tree->manage, '', "class='text-primary' data-toggle='modal' data-type='iframe' data-width='95%'"); - $output .= '  '; - $output .= html::a("javascript:void(0)", $this->lang->refreshIcon, '', "class='refresh' onclick='loadProductModulesNew($rootID)'"); + $output .= "
"; + $output .= html::a($this->createLink('tree', 'browse', "rootID=$rootID&view=$viewType¤tModuleID=0&branch=$branch", '', true), $this->lang->tree->manage, '', "class='btn' data-toggle='modal'"); + $output .= html::a("javascript:;", $this->lang->refresh, '', "class='refresh btn' onclick='loadProductModule($rootID)'"); $output .= ''; } } diff --git a/module/testcase/js/createscene.ui.js b/module/testcase/js/createscene.ui.js new file mode 100644 index 0000000000..d6381b2f6a --- /dev/null +++ b/module/testcase/js/createscene.ui.js @@ -0,0 +1,51 @@ +function loadProductBranch() +{ + $('#branch').remove(); + + var productID = $('#product').val(); + var param = "productID=" + productID + "&oldBranch=0" + "¶m=all"; + $.get($.createLink('branch', 'ajaxGetBranches', param), function(data) + { + if(data) $('#product').closest('.input-group').append(data); + + loadProductModule(); + }) +} + +function loadProductModule() +{ + var productID = $('#product').val(); + var branch = $('#branch').val(); + if(!branch) branch = 0; + + link = $.createLink('testcase', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case&branch=' + branch + '&rootModuleID=0&returnType=html&fieldID=&needManage=true&extra=¤tModuleID=0'); + $('#moduleIdBox').load(link, function() + { + $('#moduleIdBox').prepend("" + caseModule + ""); + }); + + setScenes(); +} + +function loadModuleRelatedNew() +{ + setScenes(); +} + +function setScenes() +{ + moduleID = $('#module').val(); + productID = $('#product').val(); + branch = $('#branch').val(); + if(typeof(branch) == 'undefined') branch = 0; + + link = $.createLink('testcase', 'ajaxGetModuleScenes', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&stype=1&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1'); + $.get(link, function(data) + { + if(data) + { + $('#parent').remove(); + $('#sceneIdBox').append(data); + } + }) +} diff --git a/module/testcase/ui/createscene.html.php b/module/testcase/ui/createscene.html.php new file mode 100644 index 0000000000..ed6176b1ab --- /dev/null +++ b/module/testcase/ui/createscene.html.php @@ -0,0 +1,98 @@ + + * @package testcase + * @link https://www.zentao.net + */ +namespace zin; + +jsVar('tab', $this->app->tab); +jsVar('caseModule', $lang->testcase->module); + +formPanel +( + set::title($lang->testcase->createScene), + + on::change('#product', 'loadProductBranch'), + on::change('#branch', 'loadProductModule'), + on::change('#module', 'loadModuleRelatedNew'), + on::click('.refresh', 'loadProductModule'), + formRow + ( + formGroup + ( + set::label($lang->testcase->product), + set::width('1/2'), + inputGroup + ( + select + ( + set::name('product'), + set::items($products), + set::value($productID), + ), + isset($product->type) && $product->type != 'normal' ? select + ( + zui::width('120px'), + set::name('branch'), + set::items($branches), + set::value($branch) + ) : null + ) + ), + formGroup + ( + inputGroup + ( + $lang->testcase->module, + set::id('moduleIdBox'), + select + ( + set::name('module'), + set::items($moduleOptionMenu), + set::value($currentModuleID), + ), + count($moduleOptionMenu) == 1 ? div + ( + set::class('input-group-btn flex'), + a + ( + $lang->tree->manage, + set('href', createLink('tree', 'browse', "rootId=$productID&view=case¤tModuleID=0&branch=$branch")), + set('class', 'btn'), + set('data-toggle', 'mdoal'), + ), + a + ( + $lang->refresh, + set('href', 'javascript:;'), + set('class', 'btn refresh') + ) + ) : null + ) + ) + ), + formGroup + ( + set::label($lang->testcase->parentScene), + set::id('sceneIdBox'), + select + ( + set::name('parent'), + set::items($sceneOptionMenu), + set::value($currentParentID), + ) + ), + formGroup + ( + set::label($lang->testcase->sceneTitle), + set::required(true), + set::name('title') + ) +); + +render();