From 94193dc4f0b4ebe0629178fd94324ca0adb24395 Mon Sep 17 00:00:00 2001 From: wangyuting Date: Thu, 15 Jun 2023 15:59:21 +0800 Subject: [PATCH] * Finish testsuite link case page. the task #95479. --- module/testcase/ui/view.html.php | 8 ++-- module/testsuite/config/table.php | 17 ++++++++ module/testsuite/control.php | 2 +- module/testsuite/js/linkcase.ui.js | 60 +++++++++++++++++++++++++++ module/testsuite/ui/linkcase.html.php | 54 ++++++++++++++++++++++++ 5 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 module/testsuite/js/linkcase.ui.js create mode 100644 module/testsuite/ui/linkcase.html.php diff --git a/module/testcase/ui/view.html.php b/module/testcase/ui/view.html.php index 9fbfe3ae7c..81f9af00cd 100644 --- a/module/testcase/ui/view.html.php +++ b/module/testcase/ui/view.html.php @@ -325,6 +325,7 @@ foreach(explode(',', $case->reviewedBy) as $account) } $reviewedBy = trim($reviewedBy); +$isInModal = isAjaxRequest('modal'); detailHeader ( to::title @@ -336,7 +337,7 @@ detailHeader set::text($case->title) ) ), - to::suffix + !$isInModal ? to::suffix ( btn ( @@ -345,7 +346,7 @@ detailHeader set::text($lang->case->create), $canCreateCase ? set::url($this->createLink('testcase', 'create', "productID={$case->product}&branch={$case->branch}&moduleID={$case->module}")) : null ) - ) + ) : null ); detailBody @@ -512,5 +513,4 @@ detailBody ), ); -render(); - +render($isInModal ? 'modalDialog' : 'page'); diff --git a/module/testsuite/config/table.php b/module/testsuite/config/table.php index ef2ff6e74a..52adfc8453 100644 --- a/module/testsuite/config/table.php +++ b/module/testsuite/config/table.php @@ -64,6 +64,7 @@ $config->testsuite->dtable->fieldList['actions']['menu'] = array('linkCase global $app; $app->loadLang('testcase'); $app->loadLang('testtask'); +$app->loadModuleConfig('testcase'); $config->testsuite->testcase = new stdclass(); @@ -136,3 +137,19 @@ $config->testsuite->testcase->dtable->fieldList['actions']['title'] = $lang-> $config->testsuite->testcase->dtable->fieldList['actions']['sortType'] = false; $config->testsuite->testcase->dtable->fieldList['actions']['list'] = $config->testsuite->testcase->actionList; $config->testsuite->testcase->dtable->fieldList['actions']['menu'] = array(); + +$config->testsuite->linkcase = new stdclass(); +$config->testsuite->linkcase->dtable = new stdclass(); +$config->testsuite->linkcase->dtable->fieldList['id'] = $config->testcase->dtable->fieldList['id']; +$config->testsuite->linkcase->dtable->fieldList['title'] = $config->testcase->dtable->fieldList['title']; +$config->testsuite->linkcase->dtable->fieldList['pri'] = $config->testcase->dtable->fieldList['pri']; +$config->testsuite->linkcase->dtable->fieldList['type'] = $config->testcase->dtable->fieldList['type']; +$config->testsuite->linkcase->dtable->fieldList['status'] = $config->testcase->dtable->fieldList['status']; + +$config->testsuite->linkcase->dtable->fieldList['status']['name'] = 'version'; +$config->testsuite->linkcase->dtable->fieldList['status']['title'] = $lang->testsuite->linkVersion; +$config->testsuite->linkcase->dtable->fieldList['status']['type'] = 'text'; +$config->testsuite->linkcase->dtable->fieldList['status']['group'] = 'version'; + +$config->testsuite->linkcase->dtable->fieldList['openedBy'] = $config->testcase->dtable->fieldList['openedBy']; +unset($config->testsuite->linkcase->dtable->fieldList['title']['nestedToggle']); diff --git a/module/testsuite/control.php b/module/testsuite/control.php index fe2aaa54b8..450cdee245 100644 --- a/module/testsuite/control.php +++ b/module/testsuite/control.php @@ -317,7 +317,7 @@ class testsuite extends control if(!empty($_POST)) { $this->testsuite->linkCase($suiteID); - $this->locate(inlink('view', "suiteID=$suiteID")); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => inlink('view', "suiteID=$suiteID"))); } $suite = $this->testsuite->getById($suiteID); diff --git a/module/testsuite/js/linkcase.ui.js b/module/testsuite/js/linkcase.ui.js new file mode 100644 index 0000000000..71e484365a --- /dev/null +++ b/module/testsuite/js/linkcase.ui.js @@ -0,0 +1,60 @@ +$(document).off('click', '.batch-btn').on('click', '.batch-btn', function() +{ + const dtable = zui.DTable.query($(this).target); + const checkedList = dtable.$.getChecks(); + if(!checkedList.length) return; + + const url = $(this).data('url'); + const form = new FormData(); + checkedList.forEach((id) => + { + form.append('cases[]', id); + form.append('versions[' + id + ']', $('#versions' + id).val()); + }); + + if($(this).hasClass('ajax-btn')) + { + $.ajaxSubmit({url, data: form}); + } + else + { + postAndLoadPage(url, form); + } +}); + +/** + * 对列进行重定义。 + * Redefine the column. + * + * @param array result + * @param array info + * @access public + * @return string|array + */ +window.renderCell = function(result, info) +{ + if(info.col.name == 'title' && result[0]) + { + const testcase = info.row.data; + + let html = '('; + for(i = 1; i <= testcase.version; i++) + { + html += "#" + i + ""; + } + html += ')'; + result.push({html}); + } + if(info.col.name == 'version' && result[0]) + { + const testcase = info.row.data; + let html = ""; + result[0] = {html}; + } + return result; +} diff --git a/module/testsuite/ui/linkcase.html.php b/module/testsuite/ui/linkcase.html.php new file mode 100644 index 0000000000..c042cf491f --- /dev/null +++ b/module/testsuite/ui/linkcase.html.php @@ -0,0 +1,54 @@ + + * @package testsuite + * @link https://www.zentao.net + */ +namespace zin; + +detailHeader +( + to::title + ( + entityLabel(set(array('entityID' => $suite->id, 'level' => 3, 'text' => $suite->name))), + icon('angle-right'), + $lang->testsuite->linkCase, + div(searchToggle(set::open(true))) + ) +); + +$footToolbar = array('items' => array +( + array('text' => $lang->save, 'className' => 'batch-btn ajax-btn', 'data-url' => helper::createLink('testsuite', 'linkCase', "suiteID=$suiteID¶m=$param")) +), 'btnProps' => array('size' => 'sm', 'btnType' => 'secondary')); + +div +( + set('class', 'mb-2'), + icon('unlink'), + span + ( + set('class', 'font-semibold ml-2'), + $lang->testsuite->unlinkedCases . "({$pager->recTotal})" + ) +); +$cases = initTableData($cases, $config->testcase->dtable->fieldList, $this->testcase); +$data = array_values($cases); +dtable +( + set::userMap($users), + set::data($data), + set::cols($config->testsuite->linkcase->dtable->fieldList), + set::fixedLeftWidth('33%'), + set::checkable(true), + set::footToolbar($footToolbar), + set::onRenderCell(jsRaw('window.renderCell')), + set::footPager(usePager()), +); + +render(); +