Commit e17b1548 by slqgsm

Release there were some issues with the way removing columns was being implemented.

So I decided to scrap that, and go for just having a hidden column style. This is what
@madshall did in his enhanced table pull request, so this is basically the hidden
column style feature form his pull request.
parent 93cb08d9
......@@ -39,6 +39,7 @@ export class TablePanelEditorCtrl {
{text: 'Number', value: 'number'},
{text: 'String', value: 'string'},
{text: 'Date', value: 'date'},
{text: 'Hidden', value: 'hidden'}
];
this.fontSizes = ['80%', '90%', '100%', '110%', '120%', '130%', '150%', '160%', '180%', '200%', '220%', '250%'];
this.dateFormats = [
......
......@@ -4,7 +4,7 @@
<table class="table-panel-table">
<thead>
<tr>
<th ng-repeat="col in ctrl.table.columns">
<th ng-repeat="col in ctrl.table.columns" ng-hide="col.hidden">
<div class="table-panel-table-header-inner pointer" ng-click="ctrl.toggleColumnSort(col, $index)">
{{col.text}}
<span class="table-panel-table-header-controls" ng-if="col.sort">
......
......@@ -94,7 +94,6 @@ class TablePanelCtrl extends MetricsPanelCtrl {
onDataReceived(dataList) {
this.dataRaw = dataList;
this.pageIndex = 0;
this.panel.columns = [];
// automatically correct transform mode based on data
if (this.dataRaw && this.dataRaw.length) {
......
......@@ -45,6 +45,12 @@ export class TableRenderer {
return this.defaultCellFormater;
}
if (style.type === 'hidden') {
return v => {
return undefined;
};
}
if (style.type === 'date') {
return v => {
if (_.isArray(v)) { v = v[0]; }
......@@ -119,6 +125,13 @@ export class TableRenderer {
widthHack = '<div class="table-panel-width-hack">' + this.table.columns[columnIndex].text + '</div>';
}
if (value === undefined) {
style = ' style="display:none;"';
this.table.columns[columnIndex].hidden = true;
} else {
this.table.columns[columnIndex].hidden = false;
}
return '<td' + style + '>' + value + widthHack + '</td>';
}
......
......@@ -142,7 +142,6 @@ transformers['table'] = {
if (!data || data.length === 0) {
return [];
}
return data[0].columns;
},
transform: function(data, panel, model) {
if (!data || data.length === 0) {
......@@ -153,27 +152,8 @@ transformers['table'] = {
throw {message: 'Query result is not in table format, try using another transform.'};
}
var i,j,k, entry;
if (panel.columns.length === 0) {
for (i = 0; i < data[0].columns.length; i++) {
panel.columns.push({ text: data[0].columns[i].text, value : data[0].columns[i].text});
}
}
var indices = [];
for (i = 0; i < panel.columns.length; i++) {
var column = _.findWhere(data[0].columns, { "text" : panel.columns[i].text });
indices.push(_.indexOf(data[0].columns, column));
model.columns.push(column);
}
for (i = 0; i < data[0].rows.length; i++) {
entry = [];
for (j = 0; j < indices.length; j++) {
entry.push(data[0].rows[i][indices[j]]);
}
model.rows.push(entry);
}
model.columns = data[0].columns;
model.rows = data[0].rows;
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment