From 133d4de28dafbc1a78a40457feeb368342cc4c7e Mon Sep 17 00:00:00 2001 From: wangyuting Date: Fri, 14 Jul 2023 13:12:10 +0800 Subject: [PATCH] * Finish data table on groupcase page. --- module/testcase/config/table.php | 16 +++++-- module/testcase/js/groupcase.ui.js | 66 ++++++++++++++++++++------- module/testcase/ui/groupcase.html.php | 1 + 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/module/testcase/config/table.php b/module/testcase/config/table.php index 70dd160ecf..832cfb2a1d 100644 --- a/module/testcase/config/table.php +++ b/module/testcase/config/table.php @@ -126,14 +126,21 @@ $config->testcase->dtable->fieldList['actions']['group'] = 7; $config->testcase->group = new stdclass(); $config->testcase->group->dtable = new stdclass(); $config->testcase->group->dtable->fieldList['storyTitle']['title'] = $lang->testcase->story; -$config->testcase->group->dtable->fieldList['storyTitle']['type'] = 'desc'; -$config->testcase->group->dtable->fieldList['storyTitle']['fixed'] = 'left'; +$config->testcase->group->dtable->fieldList['storyTitle']['width'] = 'auto'; +$config->testcase->group->dtable->fieldList['storyTitle']['type'] = 'title'; +$config->testcase->group->dtable->fieldList['storyTitle']['fixed'] = false; $config->testcase->group->dtable->fieldList['storyTitle']['sortType'] = true; -$config->testcase->group->dtable->fieldList['storyTitle']['group'] = '1'; +$config->testcase->group->dtable->fieldList['storyTitle']['group'] = 'story'; + $config->testcase->group->dtable->fieldList['id'] = $config->testcase->dtable->fieldList['id']; -$config->testcase->group->dtable->fieldList['id']['type'] = 'id'; +$config->testcase->group->dtable->fieldList['id']['type'] = 'id'; +$config->testcase->group->dtable->fieldList['id']['fixed'] = false; + $config->testcase->group->dtable->fieldList['title'] = $config->testcase->dtable->fieldList['title']; +$config->testcase->group->dtable->fieldList['title']['width'] = 'auto'; $config->testcase->group->dtable->fieldList['title']['nestedToggle'] = false; +$config->testcase->group->dtable->fieldList['title']['fixed'] = false; + $config->testcase->group->dtable->fieldList['pri'] = $config->testcase->dtable->fieldList['pri']; $config->testcase->group->dtable->fieldList['status'] = $config->testcase->dtable->fieldList['status']; $config->testcase->group->dtable->fieldList['lastRunResult'] = $config->testcase->dtable->fieldList['lastRunResult']; @@ -144,6 +151,7 @@ $config->testcase->group->dtable->fieldList['stepNumber'] = $config->testcase $config->testcase->group->dtable->fieldList['lastRunner'] = $config->testcase->dtable->fieldList['lastRunner']; $config->testcase->group->dtable->fieldList['lastRunDate'] = $config->testcase->dtable->fieldList['lastRunDate']; $config->testcase->group->dtable->fieldList['actions'] = $config->testcase->dtable->fieldList['actions']; +$config->testcase->group->dtable->fieldList['actions']['fixed'] = false; $config->testcase->bug = new stdclass(); $config->testcase->bug->dtable = new stdclass(); diff --git a/module/testcase/js/groupcase.ui.js b/module/testcase/js/groupcase.ui.js index f1ad6029cd..31b63c1bb3 100644 --- a/module/testcase/js/groupcase.ui.js +++ b/module/testcase/js/groupcase.ui.js @@ -17,7 +17,14 @@ window.onRenderCell = function(result, {row, col}) { if(result && col.name == 'storyTitle') { - result.unshift({html: ''}); + if(row.data.hidden) + { + result.unshift({html: ''}); + } + else + { + result.unshift({html: ''}); + } } return result; @@ -33,39 +40,64 @@ window.onRenderCell = function(result, {row, col}) */ window.getCellSpan = function(cell) { - if(cell.col.name == 'storyTitle') + if(cell.col.name == 'storyTitle' && cell.row.data.rowspan) { - if(cell.row.data.rowspan) - { - return {rowSpan: cell.row.data.rowspan}; - } + return {rowSpan: cell.row.data.rowspan}; + } + if(cell.col.name == 'id' && cell.row.data.colspan) + { + return {colSpan: cell.row.data.colspan}; } } window.deformation = function(event) { - const options = zui.DTable.query().options; - const story = $(event.target).parent().data('story'); - let newOptions; + let newData = []; + const options = zui.DTable.query().options; + const story = $(event.target).closest('a').data('story'); + const oldOptions = $.extend(true, {}, initialOptions); - if($(event.target).hasClass('is-collapsed')) + + if($(event.target).closest('a').find('span').hasClass('is-collapsed')) { - newOptions = $.extend(true, {}, initialOptions); - $(event.target).removeClass('is-collapsed').addClass('is-expanded'); + console.log(initialOptions.data); + $.each(options.data, function(index) + { + if(!options.data[index]) return; + if(options.data[index].story == story) + { + $.each(oldOptions.data, function(key) + { + if(!oldOptions.data[key]) return; + if(oldOptions.data[key].story == story) newData.push(oldOptions.data[key]); + }); + } + else + { + newData.push(options.data[index]); + } + }); + options.data = newData; + $(event.target).closest('a').find('span').removeClass('is-collapsed').addClass('is-expanded'); + $('#groupCaseTable').zui('dtable').render(options); } else { - options.data = options.data.filter(function(option){return option.story != story || option.rowspan != 0;}); + options.data = options.data.filter(function(option) + { + return option.story != story || option.rowspan != 0; + }); $.each(options.data, function(index) { if(options.data[index] && options.data[index].story == story) { + options.data[index].id = allTestcases + ' ' + options.data[index].rowspan; options.data[index].rowspan = 1; + options.data[index].colspan = 12; + options.data[index].hidden = 1; } }); - $(event.target).removeClass('is-expanded').addClass('is-collapsed'); - newOptions = options; + $(event.target).closest('a').find('span').removeClass('is-expanded').addClass('is-collapsed'); + $('#groupCaseTable').zui('dtable').render(); } - console.log(newOptions); - $('#groupCaseTable').zui('dtable').render(newOptions); } diff --git a/module/testcase/ui/groupcase.html.php b/module/testcase/ui/groupcase.html.php index 84af5997e0..8eaa64958c 100644 --- a/module/testcase/ui/groupcase.html.php +++ b/module/testcase/ui/groupcase.html.php @@ -9,6 +9,7 @@ declare(strict_types=1); * @link https://www.zentao.net */ namespace zin; +jsVar('allTestcases', $lang->testcase->allTestcases); include 'header.html.php';