Skip to content

Commit

Permalink
refactor(orga): use PixPagination when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car committed Dec 24, 2024
1 parent 17ce069 commit dd65e4a
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 14 deletions.
21 changes: 19 additions & 2 deletions orga/app/components/campaign/activity/participants-list.gjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PixIconButton from '@1024pix/pix-ui/components/pix-icon-button';
import PixPagination from '@1024pix/pix-ui/components/pix-pagination';
import { array, fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { action } from '@ember/object';
Expand All @@ -9,7 +10,6 @@ import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';

import TableHeader from '../../table/header';
import PaginationControl from '../../table/pagination-control';
import ParticipationStatus from '../../ui/participation-status';
import ParticipationFilters from '../filter/participation-filters';
import DeleteParticipationModal from './delete-participation-modal';
Expand All @@ -23,10 +23,23 @@ export default class ParticipantsList extends Component {
@tracked isModalOpen = false;
@tracked participationToDelete;

get currentLocale() {
return this.intl.primaryLocale;
}

get canDeleteParticipation() {
return this.currentUser.isAdminInOrganization || this.args.campaign.ownerId == this.currentUser.prescriber?.id;
}

get pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}

@action
openModal(participation, event) {
event.stopPropagation();
Expand Down Expand Up @@ -165,7 +178,11 @@ export default class ParticipantsList extends Component {
</div>

{{#if @participations}}
<PaginationControl @pagination={{@participations.meta}} />
<PixPagination
@pagination={{@participations.meta}}
@locale={{this.getCurrentLocale}}
@pageOptions={{this.pageOptions}}
/>
{{/if}}

<DeleteParticipationModal
Expand Down
20 changes: 18 additions & 2 deletions orga/app/components/campaign/results/assessment-list.gjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import PixPagination from '@1024pix/pix-ui/components/pix-pagination';
import { t } from 'ember-intl';

import getService from '../../../helpers/get-service.js';
import TableHeader from '../../table/header';
import TablePaginationControl from '../../table/pagination-control';
import CampaignParticipationFilters from '../filter/participation-filters';
import CampaignAssessmentRow from '../results/assessment-row';
import EvolutionHeader from './evolution-header';

function pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}

<template>
<section ...attributes>
<h3 class="screen-reader-only">{{t "pages.campaign-results.table.title"}}</h3>
Expand Down Expand Up @@ -87,7 +97,13 @@ import EvolutionHeader from './evolution-header';
</div>

{{#if @participations}}
<TablePaginationControl @pagination={{@participations.meta}} />
{{#let (getService "service:intl") as |intl|}}
<PixPagination
@pagination={{@participations.meta}}
@locale={{intl.primaryLocale}}
@pageOptions={{(pageOptions)}}
/>
{{/let}}
{{/if}}
</section>
</template>
16 changes: 14 additions & 2 deletions orga/app/components/campaign/results/profile-list.gjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import PixPagination from '@1024pix/pix-ui/components/pix-pagination';
import PixTag from '@1024pix/pix-ui/components/pix-tag';
import { array, fn } from '@ember/helper';
import { on } from '@ember/modifier';
Expand All @@ -6,12 +7,21 @@ import dayjsFormat from 'ember-dayjs/helpers/dayjs-format';
import { t } from 'ember-intl';
import { gt } from 'ember-truth-helpers';

import getService from '../../../helpers/get-service.js';
import TableHeader from '../../table/header';
import TablePaginationControl from '../../table/pagination-control';
import CampaignParticipationFilters from '../filter/participation-filters';
import EvolutionHeader from './evolution-header';
import ParticipationEvolutionIcon from './participation-evolution-icon';

function pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}

<template>
<section ...attributes>
<h3 class="screen-reader-only">{{t "pages.profiles-list.table.title"}}</h3>
Expand Down Expand Up @@ -144,7 +154,9 @@ import ParticipationEvolutionIcon from './participation-evolution-icon';
</div>

{{#if (gt @profiles.length 0)}}
<TablePaginationControl @pagination={{@profiles.meta}} />
{{#let (getService "service:intl") as |intl|}}
<PixPagination @pagination={{@profiles.meta}} @locale={{intl.primaryLocale}} @pageOptions={{(pageOptions)}} />
{{/let}}
{{/if}}
</section>
</template>
21 changes: 18 additions & 3 deletions orga/app/components/mission/activity-table.gjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import PixPagination from '@1024pix/pix-ui/components/pix-pagination';
import PixTag from '@1024pix/pix-ui/components/pix-tag';
import { t } from 'ember-intl';

import getService from '../../helpers/get-service.js';
import Header from '../table/header';
import PaginationControl from '../table/pagination-control';

function statusColor(status) {
return {
'not-started': 'tertiary',
Expand All @@ -12,6 +12,15 @@ function statusColor(status) {
}[status];
}

function pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}

<template>
{{#if @missionLearners}}
<div class="panel">
Expand Down Expand Up @@ -51,7 +60,13 @@ function statusColor(status) {
</tbody>
</table>
</div>
<PaginationControl @pagination={{@missionLearners.meta}} />
{{#let (getService "service:intl") as |intl|}}
<PixPagination
@pagination={{@missionLearners.meta}}
@locale={{intl.primaryLocale}}
@pageOptions={{(pageOptions)}}
/>
{{/let}}
{{else}}
<div class="table__empty content-text">
{{t "pages.missions.mission.table.activities.no-data"}}
Expand Down
20 changes: 18 additions & 2 deletions orga/app/components/mission/result-table.gjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import PixIcon from '@1024pix/pix-ui/components/pix-icon';
import PixPagination from '@1024pix/pix-ui/components/pix-pagination';
import PixTag from '@1024pix/pix-ui/components/pix-tag';
import PixTooltip from '@1024pix/pix-ui/components/pix-tooltip';
import { t } from 'ember-intl';

import getService from '../../helpers/get-service.js';
import Header from '../table/header';
import PaginationControl from '../table/pagination-control';

function indexNumber(index) {
return { number: index + 1 };
Expand All @@ -25,6 +26,15 @@ function getMissionResultColor(result) {
}[result];
}

function pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}

<template>
{{#if @missionLearners}}
<div class="panel">
Expand Down Expand Up @@ -98,7 +108,13 @@ function getMissionResultColor(result) {
</tbody>
</table>
</div>
<PaginationControl @pagination={{@missionLearners.meta}} />
{{#let (getService "service:intl") as |intl|}}
<PixPagination
@pagination={{@missionLearners.meta}}
@locale={{intl.primaryLocale}}
@pageOptions={{(pageOptions)}}
/>
{{/let}}
{{else}}
<div class="table__empty content-text">
{{t "pages.missions.mission.table.result.no-data"}}
Expand Down
16 changes: 15 additions & 1 deletion orga/app/components/statistics/index.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ import TagLevel from './tag-level';

export default class Statistics extends Component {
@service router;
@service intl;

@tracked currentDomainFilter = null;

get currentLocale() {
return this.intl.primaryLocale;
}

get analysisByTubes() {
return this.args.model.data.sort(
(a, b) => a.competence_code.localeCompare(b.competence_code) || a.sujet?.localeCompare(b.sujet),
Expand Down Expand Up @@ -74,6 +79,15 @@ export default class Statistics extends Component {
};
}

get pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}

handleDomainFilter = (domain) => {
this.currentDomainFilter = domain;
this.router.replaceWith({ queryParams: { pageNumber: 1 } });
Expand Down Expand Up @@ -152,6 +166,6 @@ export default class Statistics extends Component {
</table>
</section>

<PixPagination @pagination={{this.pagination}} />
<PixPagination @pagination={{this.pagination}} @locale={{this.currentLocale}} @pageOptions={{this.pageOptions}} />
</template>
}
2 changes: 1 addition & 1 deletion orga/app/components/team/members-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
</div>

{{#if @members}}
<Table::PaginationControl @pagination={{@members.meta}} />
<PixPagination @pagination={{@members.meta}} @locale={{this.currentLocale}} @pageOptions={{this.pageOptions}} />
{{/if}}
14 changes: 14 additions & 0 deletions orga/app/components/team/members-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import Component from '@glimmer/component';

export default class MembersList extends Component {
@service currentUser;
@service intl;

get currentLocale() {
return this.intl.primaryLocale;
}

get displayManagingColumn() {
return this.currentUser.isAdminInOrganization;
Expand All @@ -11,4 +16,13 @@ export default class MembersList extends Component {
get isMultipleAdminsAvailable() {
return this.args.members?.filter((member) => member.isAdmin).length > 1;
}

get pageOptions() {
return [
{ label: '10', value: 10 },
{ label: '25', value: 25 },
{ label: '50', value: 50 },
{ label: '100', value: 100 },
];
}
}
1 change: 0 additions & 1 deletion orga/app/styles/components/pagination-control.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.pagination-control {
display: flex;
justify-content: space-between;
margin: 16px 0;
color: var(--pix-neutral-500);
font-size: 0.875rem;
font-family: $font-roboto;
Expand Down
1 change: 1 addition & 0 deletions orga/app/styles/globals/panels.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.panel {
@extend %pix-shadow-xs;

margin-bottom: var(--pix-spacing-8x);
background-color: var(--pix-neutral-0);
border: none;
border-radius: 4px;
Expand Down

0 comments on commit dd65e4a

Please sign in to comment.