Skip to content

Commit

Permalink
Merge pull request #296 from sly7-7/add-prop-to-columnFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain authored Jan 27, 2021
2 parents 3c36288 + bd19fd2 commit 6ca6da0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions addon/components/yeti-table/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ class YetiTable extends DidChangeAttrsComponent {
filter: this.get('filter'),
filterUsing: this.get('filterUsing'),
columnFilters: this.get('columns').map(c => ({
prop: c.get('prop'),
filter: c.get('filter'),
filterUsing: c.get('filterUsing')
}))
Expand Down
20 changes: 10 additions & 10 deletions tests/dummy/app/pods/docs/async/template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Async data

## The `loadData` function
Expand All @@ -21,6 +20,7 @@ This function will be invoked whenever new data is needed:
The argument for the `loadData` function is an object that contains:

- `paginationData` - an object that contains:

- `pageSize` - the current size of the page
- `pageNumber` - the current page number
- `pageStart` - the 1-indexed index of the first record of the current page
Expand All @@ -35,7 +35,7 @@ The argument for the `loadData` function is an object that contains:
- `filterData` - an object that contains:
- `filter` - the current global filter applied to the table
- `filterUsing` - the current `@filterUsing` property, if existent
- `columnFilters` - an array of `{ filter, filterUsing }` objects for each column
- `columnFilters` - an array of `{ prop, filter, filterUsing }` objects for each column

With this data you should be able to build the correct request to inform your server of what exact info Yeti Table wants.

Expand Down Expand Up @@ -78,7 +78,7 @@ A custom pagination controls component is also included (check the `pagination-c
</aside>

{{#docs-demo as |demo|}}
{{#demo.example name="async-simple.hbs"}}
{{#demo.example name="async-simple.hbs"}}

<div class="docs-flex docs-justify-end">
<input
Expand All @@ -90,7 +90,7 @@ A custom pagination controls component is also included (check the `pagination-c
@loadData={{perform this.loadDataTask}}
@filter={{this.filterText}}
@pagination={{true}} @pageSize={{10}} @totalRows={{this.totalRows}} as |table|>

<table.header as |header|>
<header.column @prop="avatarUrl" @sortable={{false}}>
Avatar
Expand Down Expand Up @@ -145,11 +145,11 @@ A custom pagination controls component is also included (check the `pagination-c

</YetiTable>

{{/demo.example}}
{{/demo.example}}

{{demo.snippet "async-simple.hbs"}}
{{demo.snippet label="load-data-task.js" name="async-simple.js"}}
{{demo.snippet label="load-data-async-await.js" name="async-simple-es7.js"}}
{{demo.snippet label="pagination-component.hbs" name="async-custom-pagination.hbs"}}
{{demo.snippet label="user-model.js" name="user.js"}}
{{demo.snippet "async-simple.hbs"}}
{{demo.snippet label="load-data-task.js" name="async-simple.js"}}
{{demo.snippet label="load-data-async-await.js" name="async-simple-es7.js"}}
{{demo.snippet label="pagination-component.hbs" name="async-custom-pagination.hbs"}}
{{demo.snippet label="user-model.js" name="user.js"}}
{{/docs-demo}}
11 changes: 9 additions & 2 deletions tests/integration/components/yeti-table/async-data-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ module('Integration | Component | yeti-table (async)', function (hooks) {
<header.column @prop="firstName">
First name
</header.column>
<header.column @prop="lastName" @sort="desc">
<header.column @prop="lastName" @sort="desc" @filter="Andrade">
Last name
</header.column>
<header.column @prop="points">
Expand All @@ -292,7 +292,14 @@ module('Integration | Component | yeti-table (async)', function (hooks) {
this.loadData.firstCall.calledWithMatch({
paginationData: undefined,
sortData: [{ prop: 'lastName', direction: 'desc' }],
filterData: { filter: 'Miguel' }
filterData: {
filter: 'Miguel',
columnFilters: [
{ prop: 'firstName', filter: undefined, filterUsing: undefined },
{ prop: 'lastName', filter: 'Andrade', filterUsing: undefined },
{ prop: 'points', filter: undefined, filterUsing: undefined }
]
}
})
);
});
Expand Down

0 comments on commit 6ca6da0

Please sign in to comment.