-
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.
[FEATURE] Permettre de trier les données de
PixTable
(PIX-15560)
- Loading branch information
Showing
11 changed files
with
581 additions
and
8 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
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
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,59 @@ | ||
import Controller from '@ember/controller'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class TablePage extends Controller { | ||
@tracked | ||
nameSortOrder = null; | ||
@tracked | ||
numSortOrder = 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() { | ||
this.resetOrders('name'); | ||
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'; | ||
} | ||
} | ||
|
||
@action | ||
onNumSort() { | ||
this.resetOrders('num'); | ||
if (this.numSortOrder === 'asc') { | ||
this.data = this.data.sort((a, b) => b.age - a.age); | ||
this.numSortOrder = 'desc'; | ||
} else { | ||
this.data = this.data.sort((a, b) => a.age - b.age); | ||
this.numSortOrder = 'asc'; | ||
} | ||
} | ||
|
||
resetOrders(except) { | ||
for (const key of ['num', 'name']) { | ||
if (key === except) continue; | ||
this[`${key}SortOrder`] = null; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.