Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add md-foot component #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ Port of https://github.com/daniel-nagy/md-data-table using ember-paper
{{/body.row}}
{{/each}}
{{/table.body}}
{{#table.foot as |foot|}}
{{#foot.row as |row|}}
{{#row.cell}}{{/row.cell}}
{{#row.cell}}{{/row.cell}}
{{#each totalDesserts as |total|}}
{{#row.cell numeric=true}}
{{total}}
{{/row.cell}}
{{/each}}
{{#row.cell}}{{/row.cell}}
{{/foot.row}}
{{/table.foot}}
{{/paper-data-table}}
{{paper-data-table-pagination
limit=limit
Expand Down
15 changes: 15 additions & 0 deletions addon/components/paper-data-table-foot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Ember from 'ember';
import layout from '../templates/components/paper-data-table-foot';

const {
Component
} = Ember;

export default Component.extend({
classNames: ['md-foot'],
attributeBindings: ['style'],
layout,
tagName: 'tfoot',
cellspacing: '0',
cellpadding: '0',
});
1 change: 1 addition & 0 deletions addon/components/paper-data-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default Component.extend({
bodyComponent: 'paper-data-table-body',
bodyRowComponent: 'paper-data-table-row',
headComponent: 'paper-data-table-head',
footComponent: 'paper-data-table-foot',
rowWidth: 0,
sortProp: '',
sortDir: 'asc',
Expand Down
4 changes: 4 additions & 0 deletions addon/templates/components/paper-data-table-foot.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{yield (hash
row=(component bodyRowComponent selectable=selectable)
)
}}
4 changes: 4 additions & 0 deletions addon/templates/components/paper-data-table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
selectable=selectable
setRowWidth=(action (mut rowWidth))
)
foot=(component footComponent
bodyRowComponent=bodyRowComponent
selectable=selectable
)
)}}
</table>
1 change: 1 addition & 0 deletions app/components/paper-data-table-foot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'paper-data-table/components/paper-data-table-foot';
2 changes: 1 addition & 1 deletion app/styles/md-table-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ md-select.md-table-select {

.md-select-menu-container.md-pagination-select .md-text {
font-size: 12px;
}
}
11 changes: 11 additions & 0 deletions tests/dummy/app/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ export default Ember.Controller.extend({
limit: 5,
pages: Ember.A([1,2]),
page: 1,
totals: Ember.computed('desserts.[]', function() {
let desserts = this.get('desserts');
let sumBy = (desserts, prop) => Math.round(desserts.reduce((sum, row) => sum + row[prop], 0));
return [
sumBy(desserts, 'calories'),
sumBy(desserts, 'fat'),
sumBy(desserts, 'carbs'),
sumBy(desserts, 'protein'),
sumBy(desserts, 'sodium')
];
}),
paginatedDesserts: Ember.computed('page','limit',function () {
let ind = (this.get('page') - 1) * this.get('limit');

Expand Down
14 changes: 14 additions & 0 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,20 @@
{{/body.row}}
{{/each}}
{{/table.body}}
{{#table.foot as |foot|}}
{{#foot.row edit=false as |row|}}
{{#row.cell}}{{/row.cell}}
{{#row.cell}}{{/row.cell}}
{{#each totals as |total|}}
{{#row.cell numeric=true}}
{{total}}
{{/row.cell}}
{{/each}}
{{#row.cell}}{{/row.cell}}
{{#row.cell}}{{/row.cell}}
{{#row.cell}}{{/row.cell}}
{{/foot.row}}
{{/table.foot}}
{{/paper-data-table}}
{{paper-data-table-pagination
limit=limit
Expand Down