Permalink
Browse files

feat(project): Make columns usable as array of objects

  • Loading branch information...
jeremyvergnas committed Nov 25, 2016
1 parent beef809 commit c256c1e8133fdaaae58584101e6eb1b297e3f04d
Showing with 22 additions and 5 deletions.
  1. +5 −1 src/convert-manager.js
  2. +17 −4 src/datatable.js
@@ -27,7 +27,11 @@ export class ConvertManagerValueConverter {
return value;
}
for (let converter of converters.split(' | ')) {
if (typeof converters === 'string') {
converters = converters.split(' | ');
}
for (let converter of converters) {
let index = converter.indexOf(':');
if (index < 0) {
@@ -86,6 +86,8 @@ export class DataTable {
this.criteria.populate = null;
} else if (typeof this.populate === 'string') {
this.criteria.populate = this.populate;
} else if(Array.isArray(this.populate)){
this.criteria.populate = this.populate.join(',');
}
this.repository.find(this.criteria, true)
@@ -220,10 +222,6 @@ export class DataTable {
@computedFrom('columns')
get columnLabels() {
let labelsRaw = this.columns.split(',');
let columnsArray = [];
let labels = [];
function clean(str) {
return str.replace(/^'?\s*|\s*'$/g, '');
}
@@ -232,6 +230,21 @@ export class DataTable {
return str[0].toUpperCase() + str.substr(1);
}
if (Array.isArray(this.columns)) {
return this.columns.map(column => {
return {
nested : !this.isSortable(column.property),
column : column.property,
label : ucfirst(clean(column.label || column.property)),
converter: column.valueConverters || false
};
});
}
let labelsRaw = this.columns.split(',');
let columnsArray = [];
let labels = [];
labelsRaw.forEach(label => {
if (!label) {
return;

0 comments on commit c256c1e

Please sign in to comment.