* Fix dynamic table cell width,bug#38980.
This commit is contained in:
@@ -30,7 +30,7 @@ class count_of_daily_resolved_bug_in_product extends baseCalc
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
if($row->status != 'resolved' || empty($row->resolvedDate)) return false;
|
||||
if($row->status == 'active' || empty($row->resolvedDate)) return false;
|
||||
|
||||
$date = substr($row->resolvedDate, 0, 10);
|
||||
list($year, $month, $day) = explode('-', $date);
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
.chart-multiple {height: 290px; width: 100%;}
|
||||
.chart-type {width: 30%; padding-left: 50px;}
|
||||
|
||||
.table-and-chart .table-side {flex: 0 0 400px; overflow-x: hidden;}
|
||||
.table-and-chart .chart-side {flex: 0 0 calc(100% - 400px);}
|
||||
.table-and-chart .table-side {flex: 0 0 480px; overflow-x: hidden;}
|
||||
.table-and-chart .chart-side {flex: 0 0 calc(100% - 480px);}
|
||||
.table-and-chart .chart-center {display:flex; justify-content: center; align-items: center;}
|
||||
|
||||
.icon-18 {font-size: 18px;}
|
||||
|
||||
@@ -394,10 +394,32 @@ window.renderChart = function(metricID = current.id, header = resultHeader, data
|
||||
window.initDTable = function($obj, head, data)
|
||||
{
|
||||
var height = 310;
|
||||
var width = 480;
|
||||
if(viewType == 'single') height = $('.table-side').height();
|
||||
if(!head || !data) return;
|
||||
|
||||
var commonWidth = 140;
|
||||
var commonWidth = {
|
||||
scope: 160,
|
||||
date: 96,
|
||||
value: 96,
|
||||
calcTime: 128,
|
||||
};
|
||||
|
||||
var cols = head.map(function(col){ return col.name; });
|
||||
|
||||
var cellWidth = {};
|
||||
cols.forEach(function(col) {
|
||||
if(commonWidth[col]) {
|
||||
cellWidth[col] = commonWidth[col];
|
||||
}
|
||||
});
|
||||
|
||||
colsWidth = Object.values(cellWidth).reduce((a, b) => a + b, 0);
|
||||
Object.keys(cellWidth).forEach(function(col) {
|
||||
cellWidth[col] = Math.floor(cellWidth[col] / colsWidth * width);
|
||||
});
|
||||
|
||||
console.log(cellWidth);
|
||||
|
||||
new zui.DTable($obj,{
|
||||
responsive: true,
|
||||
@@ -410,30 +432,8 @@ window.initDTable = function($obj, head, data)
|
||||
// footer: ['pager'],
|
||||
onRenderCell: function(result, {row, col})
|
||||
{
|
||||
var colCount = Object.keys(row.data).length;
|
||||
if(colCount == 3) commonWidth = 86;
|
||||
if(colCount == 4) commonWidth = 64;
|
||||
|
||||
if(col.name != 'calcTime')
|
||||
{
|
||||
var html = `<span class="cell-ellipsis" style="width: ${commonWidth}px;" title="${row.data[col.name]}">${row.data[col.name]}</span>`;
|
||||
result[0] = {html: html};
|
||||
}
|
||||
|
||||
if(colCount == 4)
|
||||
{
|
||||
if(col.name == 'date')
|
||||
{
|
||||
var html = `<span class="cell-ellipsis" style="width: 75px;" title="${row.data[col.name]}">${row.data[col.name]}</span>`;
|
||||
result[0] = {html: html};
|
||||
}
|
||||
|
||||
if(col.name == 'value')
|
||||
{
|
||||
var html = `<span class="cell-ellipsis" style="width: 53px;" title="${row.data[col.name]}">${row.data[col.name]}</span>`;
|
||||
result[0] = {html: html};
|
||||
}
|
||||
}
|
||||
var html = `<span class="cell-ellipsis" style="width: ${cellWidth[col.name] - 24}px;" title="${row.data[col.name]}">${row.data[col.name]}</span>`;
|
||||
result[0] = {html: html};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -359,10 +359,10 @@ class metricZen extends metric
|
||||
$scope = current($scopeList);
|
||||
|
||||
$header = array();
|
||||
if(!empty($scopeList)) $header[] = array('name' => 'scope', 'title' => $this->lang->metric->scopeList[$scope] . $this->lang->metric->name);
|
||||
if(!empty($dateList)) $header[] = array('name' => 'date', 'title' => $this->lang->metric->date);
|
||||
$header[] = array('name' => 'value', 'title' => $this->lang->metric->value);
|
||||
if(in_array('date', $fieldList)) $header[] = array('name' => 'calcTime', 'title' => $this->lang->metric->calcTime, 'width' => 150);
|
||||
if(!empty($scopeList)) $header[] = array('name' => 'scope', 'title' => $this->lang->metric->scopeList[$scope] . $this->lang->metric->name, 'width' => 160);
|
||||
if(!empty($dateList)) $header[] = array('name' => 'date', 'title' => $this->lang->metric->date, 'width' => 96);
|
||||
$header[] = array('name' => 'value', 'title' => $this->lang->metric->value, 'width' => 96);
|
||||
if(in_array('date', $fieldList)) $header[] = array('name' => 'calcTime', 'title' => $this->lang->metric->calcTime, 'width' => 128);
|
||||
|
||||
return $header;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ class metricZen extends metric
|
||||
$row->scopeID = $record[$scope];
|
||||
}
|
||||
$row->value = is_numeric($record['value']) ? round((float)$record['value'], 2) : $record['value'];
|
||||
if(isset($record['date'])) $row->calcTime = $record['date'];
|
||||
if(isset($record['date'])) $row->calcTime = date("Y-m-d H:m", strtotime($record['date']));
|
||||
|
||||
$tableData[] = $row;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user