+ Add sort, statistics and pager for release view.

This commit is contained in:
caoyanyi
2023-06-06 16:24:41 +08:00
parent 4380c246bb
commit b2eb3bb723
2 changed files with 88 additions and 4 deletions
+76
View File
@@ -12,3 +12,79 @@ $(document).off('click','.dtable-footer .batch-btn').on('click', '.dtable-footer
data: postData
});
});
/**
* 计算表格任务信息的统计。
* set task summary for table footer.
*
* @param element element
* @param array checkedidlist
* @access public
* @return object
*/
window.setStoryStatistics = function(element, checkedIDList)
{
const checkedTotal = checkedIDList.length;
if(checkedTotal == 0) return {html: summary};
let checkedEstimate = 0;
let checkedCase = 0;
let rateCount = checkedTotal;
const rows = element.layout.allRows;
rows.forEach((row) => {
if(checkedIDList.includes(row.id))
{
const story = row.data;
const cases = storyCases[row.id];
checkedEstimate += story.estimate;
if(cases > 0)
{
checkedCase ++;
}
else if(story.children != undefined && story.children > 0)
{
rateCount --;
}
}
})
let rate = '0%';
if(rateCount) rate = Math.round(checkedCase / rateCount * 100) + '%';
return {
html: checkedSummary.replace('%total%', checkedTotal).replace('%estimate%', checkedEstimate.toFixed(1)).replace('%rate%', rate)
};
}
/**
* 生成列表的排序链接。
* Create sort link for table.
*
* @param object col
* @access public
* @return string
*/
window.createSortLink = function(col)
{
var sort = col.name + '_asc';
if(sort == orderBy) sort = col.name + '_desc';
return sortLink.replace('{orderBy}', sort);
}
/**
* 移除关联的需求。
* Remove linked story.
*
* @param int storyID
* @access public
* @return void
*/
window.unlinkStory = function(storyID)
{
if(window.confirm(confirmUnlinkStory))
{
$.ajaxSubmit({url: unlinkStoryUrl.replace('%s', storyID)});
}
}
+12 -4
View File
@@ -19,13 +19,21 @@ detailHeader
);
jsVar('type', $type);
jsVar('orderBy', $orderBy);
jsVar('sortLink', helper::createLink('release', 'view', "releaseID={$release->id}&type={$type}&link={$link}&param={$param}&orderBy={orderBy}"));
jsVar('storyCases', $storyCases);
jsVar('summary', $summary);
jsVar('checkedSummary', str_replace('%storyCommon%', $lang->SRCommon, $lang->product->checkedSummary));
/* Table data and setting for finished story tab. */
$storyFootToolbar = array();
$storyTableData = initTableData($stories, $config->release->dtable->story->fieldList, $this->release);
jsVar('confirmUnlinkStory', $lang->release->confirmUnlinkStory);
jsVar('unlinkStoryUrl', helper::createLink('release', 'unlinkStory', "releaseID={$release->id}&story=%s"));
$storyTableData = initTableData($stories, $config->release->dtable->story->fieldList, $this->release);
$canBatchUnlinkStory = common::hasPriv('release', 'batchUnlinkStory');
$canBatchCloseStory = common::hasPriv('story', 'batchClose');
$storyFootToolbar = array();
if($canBatchUnlinkStory) $storyFootToolbar['items'][] = array('class' => 'btn primary size-sm batch-btn', 'text' => $lang->release->batchUnlink, 'btnType' => 'primary', 'data-url' => inlink('batchUnlinkStory', "release={$release->id}"));
if($canBatchCloseStory) $storyFootToolbar['items'][] = array('class' => 'btn primary size-sm batch-btn', 'text' => $lang->story->batchClose, 'btnType' => 'primary', 'data-url' => createLink('story', 'batchClose', "productID={$release->product}"));
@@ -45,7 +53,7 @@ detailBody
set::cols(array_values($config->release->dtable->story->fieldList)),
set::data($storyTableData),
set::checkable(true),
//set::sortLink(jsRaw('createSortLink')),
set::sortLink(jsRaw('createSortLink')),
set::footToolbar($storyFootToolbar),
set::footPager(
usePager(null, 'storyPager'),
@@ -53,7 +61,7 @@ detailBody
set::recTotal($storyPager->recTotal),
set::linkCreator(helper::createLink('release', 'view', "releaseID={$release->id}&type={$type}&link={$link}&param={$param}&orderBy={$orderBy}&recTotal={$storyPager->recTotal}&recPerPage={recPerPage}&page={page}"))
),
//set::checkInfo(jsRaw('function(checkedIDList){return window.setStatistics(this, checkedIDList);}'))
set::checkInfo(jsRaw('function(checkedIDList){return window.setStoryStatistics(this, checkedIDList);}'))
)
),
)