From 84aedf92655f76deafa7435ba0bf09f1d43b138d Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 17 Feb 2025 09:34:43 +0000 Subject: [PATCH] * [bug#59554,done,4h] Get checked rows. --- module/bug/js/browse.ui.js | 17 ++++++++++++++--- module/bug/ui/browse.html.php | 1 + module/caselib/js/browse.ui.js | 17 ++++++++++++++--- module/caselib/ui/browse.html.php | 1 + module/execution/js/story.ui.js | 17 ++++++++++++++--- module/execution/js/task.ui.js | 17 ++++++++++++++--- module/execution/ui/story.html.php | 3 +++ module/execution/ui/task.html.php | 1 + module/product/js/browse.ui.js | 17 ++++++++++++++--- module/product/ui/browse.html.php | 1 + module/productplan/js/browse.ui.js | 17 ++++++++++++++--- module/productplan/js/bug.ui.js | 17 ++++++++++++++--- module/productplan/js/story.ui.js | 17 ++++++++++++++--- module/productplan/ui/browsebylist.html.php | 1 + module/productplan/ui/bug.html.php | 3 ++- module/productplan/ui/story.html.php | 3 ++- module/projectstory/js/story.ui.js | 17 ++++++++++++++--- module/projectstory/ui/story.html.php | 1 + module/release/js/browse.ui.js | 17 ++++++++++++++--- module/release/ui/browse.html.php | 1 + module/testcase/js/browse.ui.js | 17 ++++++++++++++--- module/testcase/ui/browse.html.php | 1 + 22 files changed, 169 insertions(+), 35 deletions(-) diff --git a/module/bug/js/browse.ui.js b/module/bug/js/browse.ui.js index 566fb2327b..c6ae96032e 100644 --- a/module/bug/js/browse.ui.js +++ b/module/bug/js/browse.ui.js @@ -64,14 +64,25 @@ window.onRenderCell = function(result, {row, col}) return result; } +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#bugs')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=bug&blockID=${blockID}`); diff --git a/module/bug/ui/browse.html.php b/module/bug/ui/browse.html.php index 6cc20fb169..4476340839 100644 --- a/module/bug/ui/browse.html.php +++ b/module/bug/ui/browse.html.php @@ -285,6 +285,7 @@ dtable set::footPager(usePager()), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), !$isFromDoc ? null : set::height(400), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), $isFromDoc ? null : set::customCols(true), $isFromDoc ? null : set::sortLink(inlink('browse', "product={$product->id}&branch={$branch}&browseType={$browseType}¶m={$param}&orderBy={name}_{sortType}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}")), set::onRenderCell(jsRaw('window.onRenderCell')), diff --git a/module/caselib/js/browse.ui.js b/module/caselib/js/browse.ui.js index cb1f23859e..686781aaf5 100644 --- a/module/caselib/js/browse.ui.js +++ b/module/caselib/js/browse.ui.js @@ -60,14 +60,25 @@ window.toggleCheckRows = function(idList) dtable.$.toggleCheckRows(idList.split(','), true); } +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#caselib')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=caselib&blockID=${blockID}`); diff --git a/module/caselib/ui/browse.html.php b/module/caselib/ui/browse.html.php index b278826e0d..693370cb99 100644 --- a/module/caselib/ui/browse.html.php +++ b/module/caselib/ui/browse.html.php @@ -260,6 +260,7 @@ dtable $isFromDoc ? null : set::createTip($lang->testcase->create), $isFromDoc ? null : set::createLink($canCreateCase ? createLink('caselib', 'createCase', "libID={$libID}&moduleID={$moduleID}") : ''), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400) ); diff --git a/module/execution/js/story.ui.js b/module/execution/js/story.ui.js index fcdc5e21cd..6e31d7e418 100644 --- a/module/execution/js/story.ui.js +++ b/module/execution/js/story.ui.js @@ -173,14 +173,25 @@ window.setShowGrades = function() $.get(link, function() { loadCurrentPage(); }); } +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#table-execution-story')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=executionStory&blockID=${blockID}`); diff --git a/module/execution/js/task.ui.js b/module/execution/js/task.ui.js index 449dfa6e70..74cc87d7c1 100644 --- a/module/execution/js/task.ui.js +++ b/module/execution/js/task.ui.js @@ -198,14 +198,25 @@ $(document).off('click', '.switchButton').on('click', '.switchButton', function( loadCurrentPage(); }); +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#tasks')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=task&blockID=${blockID}`); diff --git a/module/execution/ui/story.html.php b/module/execution/ui/story.html.php index db8d61d3eb..0417c03f90 100644 --- a/module/execution/ui/story.html.php +++ b/module/execution/ui/story.html.php @@ -570,6 +570,8 @@ foreach($stories as $story) if(!isset($story->children)) continue; } +if($isFromDoc) $footToolbar = array(array('text' => $lang->doc->insertText, 'data-on' => 'click', 'data-call' => "insertListToDoc")); + jsVar('cases', $storyCases); jsVar('summary', $summary); jsVar('checkedSummary', $lang->product->checkedAllSummary); @@ -593,6 +595,7 @@ dtable ))), set::emptyTip($lang->execution->noStory), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400), $isFromDoc ? null : set::customCols(array('url' => createLink('datatable', 'ajaxcustom', "module={$app->moduleName}&method={$app->methodName}&extra={$storyType}"), 'globalUrl' => createLink('datatable', 'ajaxsaveglobal', "module={$app->moduleName}&method={$app->methodName}&extra={$storyType}"))), $isFromDoc ? null : set::sortLink(createLink('execution', 'story', "executionID={$execution->id}&storyType={$storyType}&orderBy={name}_{sortType}&type={$type}¶m={$param}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&page={$pager->pageID}")), diff --git a/module/execution/ui/task.html.php b/module/execution/ui/task.html.php index de1f41bc87..abd1113d47 100644 --- a/module/execution/ui/task.html.php +++ b/module/execution/ui/task.html.php @@ -334,6 +334,7 @@ dtable 'linkCreator' => helper::createLink('execution', 'task', "executionID={$execution->id}&status={$status}¶m={$param}&orderBy=$orderBy&recTotal={$pager->recTotal}&recPerPage={recPerPage}&page={page}") . "#app={$app->tab}" ))), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400), $isFromDoc ? null : set::customCols(true), $isFromDoc ? null : set::sortLink(createLink('execution', 'task', "executionID={$execution->id}&status={$status}¶m={$param}&orderBy={name}_{sortType}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}")), diff --git a/module/product/js/browse.ui.js b/module/product/js/browse.ui.js index 0cd9663cb7..60ff514410 100644 --- a/module/product/js/browse.ui.js +++ b/module/product/js/browse.ui.js @@ -200,14 +200,25 @@ window.importToLib = function() $('#storyIdList').val(storyIdList); } +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#stories')); - const checkedList = Object.keys(dtable.$.state.checkedRows); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; let blockType = 'productStory'; diff --git a/module/product/ui/browse.html.php b/module/product/ui/browse.html.php index e795bc3c09..0d4f6c29d3 100644 --- a/module/product/ui/browse.html.php +++ b/module/product/ui/browse.html.php @@ -540,6 +540,7 @@ dtable set::emptyTip($emptyTip), set::footToolbar($footToolbar), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400), $isFromDoc ? null : set::customCols(array('url' => createLink('datatable', 'ajaxcustom', "module={$app->moduleName}&method={$app->methodName}&extra={$storyType}"), 'globalUrl' => createLink('datatable', 'ajaxsaveglobal', "module={$app->moduleName}&method={$app->methodName}&extra={$storyType}"), 'resetUrl' => createLink('datatable', 'ajaxreset', "module={$app->moduleName}&method={$app->methodName}&system=0&confirm=no&extra={$storyType}"), 'resetGlobalUrl' => createLink('datatable', 'ajaxreset', "module={$app->moduleName}&method={$app->methodName}&system=1&confirm=no&extra={$storyType}"))), $isFromDoc ? null : set::sortLink($sortLink), diff --git a/module/productplan/js/browse.ui.js b/module/productplan/js/browse.ui.js index 2ffd4ecade..77c165cf33 100644 --- a/module/productplan/js/browse.ui.js +++ b/module/productplan/js/browse.ui.js @@ -350,14 +350,25 @@ window.getPlanID = function(event) $('[name=planID]').val(planID); } +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#productPlans')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=productPlan&blockID=${blockID}`); diff --git a/module/productplan/js/bug.ui.js b/module/productplan/js/bug.ui.js index bfde9fe841..0fda990b2f 100644 --- a/module/productplan/js/bug.ui.js +++ b/module/productplan/js/bug.ui.js @@ -1,11 +1,22 @@ +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#bugs')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; let blockType = 'planBug'; diff --git a/module/productplan/js/story.ui.js b/module/productplan/js/story.ui.js index 8f3d859acf..ae053f6935 100644 --- a/module/productplan/js/story.ui.js +++ b/module/productplan/js/story.ui.js @@ -12,14 +12,25 @@ window.renderStoryCell = function(result, info) return result; }; +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#stories')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; let blockType = 'planStory'; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=${blockType}&blockID=${blockID}`); diff --git a/module/productplan/ui/browsebylist.html.php b/module/productplan/ui/browsebylist.html.php index a73e4dd3f9..ddc68d4fc1 100644 --- a/module/productplan/ui/browsebylist.html.php +++ b/module/productplan/ui/browsebylist.html.php @@ -214,6 +214,7 @@ dtable usePager(array('linkCreator' => createLink($app->rawModule, 'browse', "productID={$productID}&branch={$branch}&browseType={$browseType}&queryID={$queryID}&orderBy={$orderBy}&recTotal={$pager->recTotal}&recPerPage={recPerPage}&pageID={page}&from=$from&blockID=$blockID"))), ), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400), $isFromDoc ? null : set::customCols(true), $isFromDoc ? null : set::sortLink($sortLink), diff --git a/module/productplan/ui/bug.html.php b/module/productplan/ui/bug.html.php index a0b3458a4c..1bb4e75135 100644 --- a/module/productplan/ui/bug.html.php +++ b/module/productplan/ui/bug.html.php @@ -104,7 +104,8 @@ dtable set::emptyTip($lang->bug->notice->noBug), set::footToolbar($footToolbar), set::height(400), - set::afterRender(jsCallback()->call('toggleCheckRows', $idList)) + set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + set::onCheckChange(jsRaw('window.checkedChange')) ); render(); diff --git a/module/productplan/ui/story.html.php b/module/productplan/ui/story.html.php index a53c5a1e38..37bbac62f0 100644 --- a/module/productplan/ui/story.html.php +++ b/module/productplan/ui/story.html.php @@ -115,7 +115,8 @@ dtable set::emptyTip($lang->story->noStory), set::footToolbar($footToolbar), set::height(400), - set::afterRender(jsCallback()->call('toggleCheckRows', $idList)) + set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + set::onCheckChange(jsRaw('window.checkedChange')) ); render(); diff --git a/module/projectstory/js/story.ui.js b/module/projectstory/js/story.ui.js index 1caa7b7d85..8c0d8e7a51 100644 --- a/module/projectstory/js/story.ui.js +++ b/module/projectstory/js/story.ui.js @@ -28,14 +28,25 @@ window.renderCell = function(result, info) return result; }; +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#stories')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const blockType = 'projectStory'; diff --git a/module/projectstory/ui/story.html.php b/module/projectstory/ui/story.html.php index e6152b6c38..c880d54f6f 100644 --- a/module/projectstory/ui/story.html.php +++ b/module/projectstory/ui/story.html.php @@ -125,6 +125,7 @@ dtable set::emptyTip($lang->story->noStory), set::footToolbar($footToolbar), set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + set::onCheckChange(jsRaw('window.checkedChange')), set::height(400) ); diff --git a/module/release/js/browse.ui.js b/module/release/js/browse.ui.js index ef677878c8..3b96ec1676 100644 --- a/module/release/js/browse.ui.js +++ b/module/release/js/browse.ui.js @@ -47,14 +47,25 @@ window.getCellSpan = function(cell) } } +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#releases')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const blockType = 'productRelease'; diff --git a/module/release/ui/browse.html.php b/module/release/ui/browse.html.php index 33f189e865..418e6350d1 100644 --- a/module/release/ui/browse.html.php +++ b/module/release/ui/browse.html.php @@ -143,6 +143,7 @@ dtable set::checkable($isFromDoc), $isFromDoc ? set::footToolbar(array(array('text' => $lang->doc->insertText, 'data-on' => 'click', 'data-call' => 'insertListToDoc'))) : set::footer([jsRaw("function(){return {html: '{$pageSummary}'};}"), 'flex', 'pager']), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400), $isFromDoc ? null : set::customCols(true), $isFromDoc ? null : set::sortLink(createLink('release', 'browse', "productID={$product->id}&branch={$branch}&type={$type}&orderBy={name}_{sortType}¶m=$param&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}")), diff --git a/module/testcase/js/browse.ui.js b/module/testcase/js/browse.ui.js index 0db97f4be6..f3c5fd67e4 100644 --- a/module/testcase/js/browse.ui.js +++ b/module/testcase/js/browse.ui.js @@ -296,14 +296,25 @@ $('#dragModal').on('click', '[data-dismiss=modal]', function() loadCurrentPage({cache: false}); }); +window.checkedChange = function(changes) +{ + if(!this._checkedRows) this._checkedRows = {}; + Object.keys(changes).forEach((rowID) => + { + const row = this.getRowInfo(rowID); + this._checkedRows[rowID] = row.data; + }); +} + window.insertListToDoc = function() { const dtable = zui.DTable.query($('#testcases')); - const checkedList = dtable.$.getChecks(); + const myTable = dtable.$; + const checkedList = Object.keys(myTable.state.checkedRows); if(!checkedList.length) return; - let {cols, data} = dtable.options; - data = data.filter((item) => checkedList.includes(item.id + '')); + let {cols} = dtable.options; + const data = checkedList.map(rowID => myTable._checkedRows[rowID]); const docID = getDocApp()?.docID; const url = $.createLink('doc', 'buildZentaoList', `docID=${docID}&type=productCase&blockID=${blockID}`); diff --git a/module/testcase/ui/browse.html.php b/module/testcase/ui/browse.html.php index cd0848f87d..a0e6da4e54 100644 --- a/module/testcase/ui/browse.html.php +++ b/module/testcase/ui/browse.html.php @@ -162,6 +162,7 @@ div( set::onSortEnd(strpos($orderBy, 'sort_asc') !== false ? jsRaw('window.onSortEnd') : null), set::canSortTo(strpos($orderBy, 'sort_asc') !== false ? jsRaw('window.canSortTo') : null), !$isFromDoc ? null : set::afterRender(jsCallback()->call('toggleCheckRows', $idList)), + !$isFromDoc ? null : set::onCheckChange(jsRaw('window.checkedChange')), !$isFromDoc ? null : set::height(400), $isFromDoc || $isOnlyScene ? null : set::customCols(true), $isFromDoc ? null : set::sortLink(createLink($app->rawModule, $app->rawMethod, $linkParams)),