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 { ...@@ -39,6 +39,7 @@ export class TablePanelEditorCtrl {
{text: 'Number', value: 'number'}, {text: 'Number', value: 'number'},
{text: 'String', value: 'string'}, {text: 'String', value: 'string'},
{text: 'Date', value: 'date'}, {text: 'Date', value: 'date'},
{text: 'Hidden', value: 'hidden'}
]; ];
this.fontSizes = ['80%', '90%', '100%', '110%', '120%', '130%', '150%', '160%', '180%', '200%', '220%', '250%']; this.fontSizes = ['80%', '90%', '100%', '110%', '120%', '130%', '150%', '160%', '180%', '200%', '220%', '250%'];
this.dateFormats = [ this.dateFormats = [
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<table class="table-panel-table"> <table class="table-panel-table">
<thead> <thead>
<tr> <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)"> <div class="table-panel-table-header-inner pointer" ng-click="ctrl.toggleColumnSort(col, $index)">
{{col.text}} {{col.text}}
<span class="table-panel-table-header-controls" ng-if="col.sort"> <span class="table-panel-table-header-controls" ng-if="col.sort">
......
...@@ -94,7 +94,6 @@ class TablePanelCtrl extends MetricsPanelCtrl { ...@@ -94,7 +94,6 @@ class TablePanelCtrl extends MetricsPanelCtrl {
onDataReceived(dataList) { onDataReceived(dataList) {
this.dataRaw = dataList; this.dataRaw = dataList;
this.pageIndex = 0; this.pageIndex = 0;
this.panel.columns = [];
// automatically correct transform mode based on data // automatically correct transform mode based on data
if (this.dataRaw && this.dataRaw.length) { if (this.dataRaw && this.dataRaw.length) {
......
...@@ -45,6 +45,12 @@ export class TableRenderer { ...@@ -45,6 +45,12 @@ export class TableRenderer {
return this.defaultCellFormater; return this.defaultCellFormater;
} }
if (style.type === 'hidden') {
return v => {
return undefined;
};
}
if (style.type === 'date') { if (style.type === 'date') {
return v => { return v => {
if (_.isArray(v)) { v = v[0]; } if (_.isArray(v)) { v = v[0]; }
...@@ -119,6 +125,13 @@ export class TableRenderer { ...@@ -119,6 +125,13 @@ export class TableRenderer {
widthHack = '<div class="table-panel-width-hack">' + this.table.columns[columnIndex].text + '</div>'; 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>'; return '<td' + style + '>' + value + widthHack + '</td>';
} }
......
...@@ -142,7 +142,6 @@ transformers['table'] = { ...@@ -142,7 +142,6 @@ transformers['table'] = {
if (!data || data.length === 0) { if (!data || data.length === 0) {
return []; return [];
} }
return data[0].columns;
}, },
transform: function(data, panel, model) { transform: function(data, panel, model) {
if (!data || data.length === 0) { if (!data || data.length === 0) {
...@@ -153,27 +152,8 @@ transformers['table'] = { ...@@ -153,27 +152,8 @@ transformers['table'] = {
throw {message: 'Query result is not in table format, try using another transform.'}; throw {message: 'Query result is not in table format, try using another transform.'};
} }
var i,j,k, entry; model.columns = data[0].columns;
model.rows = data[0].rows;
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);
}
} }
}; };
......
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