Skip to content

Commit

Permalink
feat: add filter wip
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentHardouin committed Dec 13, 2024
1 parent f73b94d commit 1d7c9a5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
32 changes: 32 additions & 0 deletions orga/app/components/statistics/index.gjs
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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),
Expand All @@ -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);
}

Expand All @@ -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;
}
};

<template>
<div class="statistics-page__header">
<h1 class="page-title">{{t "pages.statistics.title"}}</h1>
</div>

<section class="statistics-page__filter panel">
<div class="tabs">
{{#each this.domainsName as |domain|}}
<button
class="navbar-item {{if (eq this.currentDomainFilter domain) 'active' ''}}"
{{on "click" (fn this.handleDomainFilter domain)}}
>
{{domain}}
</button>
{{/each}}
</div>
</section>

<section class="statistics-page__section">
<table class="panel">
<caption class="screen-reader-only">{{t "pages.statistics.table.caption"}}</caption>
Expand Down
22 changes: 22 additions & 0 deletions orga/app/styles/components/statistics.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@
}
}
}

.statistics-page__filter {
display: flex;
align-items: center;
width: 100%;
min-height: 60px;
padding: 0 8px;
border: none;

& .navbar-item {
height: 60px;
}
}

.tabs {
display: flex;
align-items: center;
width: 100%;
min-height: 60px;
padding: 0 8px;
border: none;
}

0 comments on commit 1d7c9a5

Please sign in to comment.