-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(table): add a dummy page for table
Co-authored-by: Jérémie Jadé <jeremie.jade@pix.fr> Co-authored-by: Fael Bassetti <fael.bassetti@pix.fr>
- Loading branch information
1 parent
a9725b2
commit 36263bc
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class TablePage extends Controller { | ||
@tracked | ||
nameSortOrder = null; | ||
|
||
variant = 'orga'; | ||
|
||
@tracked | ||
data = [ | ||
{ | ||
name: 'jean', | ||
description: 'fort au jungle speed', | ||
age: 15, | ||
}, | ||
{ | ||
name: 'brian', | ||
description: 'travail au peach pit', | ||
age: 25, | ||
}, | ||
]; | ||
|
||
caption = 'Titre de mon tableau'; | ||
|
||
@action | ||
onNameSort() { | ||
if (this.nameSortOrder === 'asc') { | ||
this.data = this.data.sort((a, b) => b.name.localeCompare(a.name)); | ||
this.nameSortOrder = 'desc'; | ||
} else { | ||
this.data = this.data.sort((a, b) => a.name.localeCompare(b.name)); | ||
this.nameSortOrder = 'asc'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<PixTable @variant={{this.variant}} @data={{this.data}} @caption={{this.caption}}> | ||
<:columns as |row context|> | ||
<PixTableBasicColumn | ||
@context={{context}} | ||
@type="text" | ||
@name="Nom" | ||
@value={{row.name}} | ||
@onSort={{this.onNameSort}} | ||
@sortOrder={{this.nameSortOrder}} | ||
/> | ||
<PixTableColumn @context={{context}}> | ||
<:header> | ||
Description | ||
</:header> | ||
<:cell> | ||
<i>{{row.description}}</i> | ||
</:cell> | ||
</PixTableColumn> | ||
<PixTableColumn @context={{context}} class="table__column--wide"> | ||
<:header> | ||
Age | ||
</:header> | ||
<:cell> | ||
il a | ||
{{row.age}} | ||
ans | ||
</:cell> | ||
</PixTableColumn> | ||
<PixTableColumn @context={{context}}> | ||
<:header> | ||
Info | ||
</:header> | ||
<:cell> | ||
<PixIcon @name="info" @title={{concat row.name " a " row.age " ans"}} /> | ||
</:cell> | ||
</PixTableColumn> | ||
</:columns> | ||
</PixTable> |