-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Ajouter de la pagination sur la page statistiques (PIX-15683)
- Loading branch information
Showing
4 changed files
with
194 additions
and
39 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 |
---|---|---|
@@ -1,47 +1,81 @@ | ||
import PixPagination from '@1024pix/pix-ui/components/pix-pagination'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { t } from 'ember-intl'; | ||
|
||
import Header from '../table/header'; | ||
import CoverRateGauge from './cover-rate-gauge'; | ||
import TagLevel from './tag-level'; | ||
|
||
const analysisByTubes = (model) => { | ||
return model.data.sort( | ||
(a, b) => a.competence_code.localeCompare(b.competence_code) || a.sujet.localeCompare(b.sujet), | ||
); | ||
}; | ||
|
||
<template> | ||
<div class="statistics-page__header"> | ||
<h1 class="page-title">{{t "pages.statistics.title"}}</h1> | ||
</div> | ||
|
||
<section class="statistics-page__section"> | ||
<table class="panel"> | ||
<caption class="screen-reader-only">{{t "pages.statistics.table.caption"}}</caption> | ||
<thead> | ||
<tr> | ||
<Header @size="wide" scope="col">{{t "pages.statistics.table.headers.skills"}}</Header> | ||
<Header @size="medium" scope="col">{{t "pages.statistics.table.headers.topics"}}</Header> | ||
<Header @size="medium" @align="center" scope="col">{{t "pages.statistics.table.headers.positioning"}}</Header> | ||
<Header @align="center" @size="medium" scope="col">{{t | ||
"pages.statistics.table.headers.reached-level" | ||
}}</Header> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each (analysisByTubes @model) as |line|}} | ||
export default class Statistics extends Component { | ||
@service router; | ||
|
||
get analysisByTubes() { | ||
return this.args.model.data.sort( | ||
(a, b) => a.competence_code.localeCompare(b.competence_code) || a.sujet.localeCompare(b.sujet), | ||
); | ||
} | ||
|
||
get pageSize() { | ||
return Number(this.router.currentRoute?.queryParams?.pageSize) || 10; | ||
} | ||
|
||
get page() { | ||
return Number(this.router.currentRoute?.queryParams?.pageNumber) || 1; | ||
} | ||
|
||
get pagination() { | ||
return { | ||
page: this.page, | ||
pageSize: this.pageSize, | ||
rowCount: this.analysisByTubes.length, | ||
pageCount: Math.ceil(this.analysisByTubes.length / this.pageSize), | ||
}; | ||
} | ||
|
||
get visibleAnalysisByTubes() { | ||
const start = this.pageSize * (this.page - 1); | ||
const end = this.pageSize * this.page; | ||
return this.analysisByTubes.slice(start, end); | ||
} | ||
|
||
<template> | ||
<div class="statistics-page__header"> | ||
<h1 class="page-title">{{t "pages.statistics.title"}}</h1> | ||
</div> | ||
|
||
<section class="statistics-page__section"> | ||
<table class="panel"> | ||
<caption class="screen-reader-only">{{t "pages.statistics.table.caption"}}</caption> | ||
<thead> | ||
<tr> | ||
<td>{{line.competence_code}} {{line.competence}}</td> | ||
<td>{{line.sujet}}</td> | ||
<td> | ||
<CoverRateGauge @userLevel={{line.niveau_par_user}} @tubeLevel={{line.niveau_par_sujet}} /> | ||
</td> | ||
<td class="table__column--center"> | ||
<TagLevel @level={{line.niveau_par_user}} /> | ||
</td> | ||
<Header @size="wide" scope="col">{{t "pages.statistics.table.headers.skills"}}</Header> | ||
<Header @size="medium" scope="col">{{t "pages.statistics.table.headers.topics"}}</Header> | ||
<Header @size="medium" @align="center" scope="col">{{t | ||
"pages.statistics.table.headers.positioning" | ||
}}</Header> | ||
<Header @align="center" @size="medium" scope="col">{{t | ||
"pages.statistics.table.headers.reached-level" | ||
}}</Header> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</section> | ||
</template> | ||
</thead> | ||
<tbody> | ||
{{#each this.visibleAnalysisByTubes as |line|}} | ||
<tr> | ||
<td>{{line.competence_code}} {{line.competence}}</td> | ||
<td>{{line.sujet}}</td> | ||
<td> | ||
<CoverRateGauge @userLevel={{line.niveau_par_user}} @tubeLevel={{line.niveau_par_sujet}} /> | ||
</td> | ||
<td class="table__column--center"> | ||
<TagLevel @level={{line.niveau_par_user}} /> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</section> | ||
|
||
<PixPagination @pagination={{this.pagination}} /> | ||
</template> | ||
} |
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