diff --git a/orga/app/components/statistics/index.gjs b/orga/app/components/statistics/index.gjs index 51d461d76e2..acaeeb87072 100644 --- a/orga/app/components/statistics/index.gjs +++ b/orga/app/components/statistics/index.gjs @@ -1,7 +1,11 @@ import PixPagination from '@1024pix/pix-ui/components/pix-pagination'; +import { fn } from '@ember/helper'; +import { on } from '@ember/modifier'; import { service } from '@ember/service'; import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; +import { eq } from 'ember-truth-helpers'; import Header from '../table/header'; import CoverRateGauge from './cover-rate-gauge'; @@ -10,6 +14,8 @@ import TagLevel from './tag-level'; export default class Statistics extends Component { @service router; + @tracked currentDomainFilter = null; + get analysisByTubes() { return this.args.model.data.sort( (a, b) => a.competence_code.localeCompare(b.competence_code) || a.sujet.localeCompare(b.sujet), @@ -36,6 +42,9 @@ export default class Statistics extends Component { get visibleAnalysisByTubes() { const start = this.pageSize * (this.page - 1); const end = this.pageSize * this.page; + if (this.currentDomainFilter !== null) { + return this.analysisByDomains[this.currentDomainFilter].slice(start, end); + } return this.analysisByTubes.slice(start, end); } @@ -55,11 +64,34 @@ export default class Statistics extends Component { return Object.keys(this.analysisByDomains); } + handleDomainFilter = (domain) => { + if (this.currentDomainFilter === null) { + this.currentDomainFilter = domain; + } else if (this.currentDomainFilter === domain) { + this.currentDomainFilter = null; + } else { + this.currentDomainFilter = domain; + } + }; +