Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
enable displaying nested properties
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Aug 7, 2017
1 parent 7f809c1 commit cf32818
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

All notable changes to `vue-table-component` will be documented in this file

## 1.2.2 - 2017-08-04
- Fix for displaying nexted properties

## 1.2.1 - 2017-08-04
- Fix async data retrieval and pagination

Expand Down
15 changes: 15 additions & 0 deletions __tests__/components/table-component/TableComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ describe('TableComponent', () => {
expect(document.body.innerHTML).toMatchSnapshot();
});

it('can display nested properties', async () => {
document.body.innerHTML = `
<div id="app">
<table-component
:data="[{nested: { firstName: 'John' } }, { nested: { firstName: 'Paul' }}]">
<table-column show="nested.firstName" label="First name"></table-column>
</table-component>
</div>
`;

await createVm();

expect(document.body.innerHTML).toMatchSnapshot();
});

it('has an prop to disable the filter', async () => {
document.body.innerHTML = `
<div id="app">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,61 @@ exports[`TableComponent can display a custom placeholder in the filter field 1`]
`;
exports[`TableComponent can display nested properties 1`] = `
<div id="app">
<div class="table-component">
<div class="table-component__filter">
<input type="text"
placeholder="Filter table…"
class="table-component__filter__field"
>
<!---->
</div>
<div class="table-component__table-wrapper">
<table class="table-component__table">
<caption role="alert"
aria-live="polite"
class="table-component__table__caption"
>
Table not sorted
</caption>
<thead>
<tr>
<th role="columnheader"
scope="col"
aria-sort="none"
class="table-component__th--sort"
>
First name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
John
</td>
</tr>
<tr>
<td>
Paul
</td>
</tr>
</tbody>
</table>
</div>
<!---->
<div style="display: none;">
<div>
</div>
</div>
<!---->
</div>
</div>
`;
exports[`TableComponent can mount 1`] = `
<div id="app">
Expand Down
Empty file added npm-debug.log.4082538609
Empty file.
3 changes: 2 additions & 1 deletion src/classes/Row.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import moment from 'moment';
import striptags from 'striptags';
import get from 'lodash/get';

export default class Row {
constructor(data, columns) {
Expand All @@ -8,7 +9,7 @@ export default class Row {
}

getValue(columnName) {
return this.data[columnName];
return get(this.data, columnName);
}

getColumn(columnName) {
Expand Down

0 comments on commit cf32818

Please sign in to comment.