Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Redesign référentiels page #3514

Merged
merged 27 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5bee024
feat(referentiels): redesign ReferentielTabs with ProgressBar and new…
elisfainstein Jan 6, 2025
8e7c205
refactor(ReferentielTabs): rename Progression to ActionsReferentiels …
elisfainstein Jan 6, 2025
c57a8d5
refactor(ReferentielTabs): use tabs from 'ui' package + add Card layo…
elisfainstein Jan 6, 2025
2ce22be
refactor: add new design's foundations
elisfainstein Jan 16, 2025
bacb585
feat(ActionsReferentiels): implement description toggle + start sorti…
elisfainstein Jan 16, 2025
f621af4
feat(ActionsReferentiels): add display by actions
elisfainstein Jan 16, 2025
c91fe6e
refactor(ActionProgressBar): replace hardcoded score with useActionSc…
elisfainstein Jan 16, 2025
b043de0
refactor(Counter): update Counter component to use actionId and fetch…
elisfainstein Jan 16, 2025
bbf4344
refactor: clean up unused code and comment some components until futu…
elisfainstein Jan 20, 2025
55db36f
refactor: standardize progress bar style options across components
elisfainstein Jan 20, 2025
d2bfe6f
refactor: change export button to UI component
elisfainstein Jan 20, 2025
f26eea1
refactor(Counter): extract percentage calculation into a separate fun…
elisfainstein Jan 20, 2025
fca80ed
refactor: remove unused code and simplify display logic
elisfainstein Jan 20, 2025
6a0bed1
refactor: remove Card components for Aide à la prio and Détail des st…
elisfainstein Jan 21, 2025
49cbae0
feat(ActionsReferentiels): rename Referentiels component
elisfainstein Jan 22, 2025
b36ba14
refactor: add ReferentielHeader awith progress bar
elisfainstein Jan 22, 2025
371ee11
refactor(ReferentielCard, ExpandableAction): reorganize imports and u…
elisfainstein Jan 22, 2025
188159d
refactor(Counter): rmove Counter component
elisfainstein Jan 22, 2025
06dfa74
refactor: patch css with a workaround to make table look nice inside …
elisfainstein Jan 22, 2025
bf00b83
feat(ReferentielTabs): add Counter component
elisfainstein Jan 22, 2025
d284bc9
feat(ReferentielTabs): add Counter component
elisfainstein Jan 22, 2025
6299650
refactor(ExpandableAction): simplify css
elisfainstein Jan 22, 2025
d996e5d
refactor: restore previous file name Referentiels.tsx
elisfainstein Jan 23, 2025
cf93867
refactor(ProgressBar): remove unused justify option and clean up JSX …
elisfainstein Jan 23, 2025
c942468
refactor: replace Card component with divs
elisfainstein Jan 23, 2025
4fe0ce2
feat(Referentiels): add loading spinner and clean css
elisfainstein Jan 23, 2025
d441466
refactor(ReferentielTabs): remove overflow scroll
elisfainstein Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const CellAction = (props: TCellProps) => {
{depth > 0 ? (
depth > idDepth ? (
<Link
className="hover:underline active:underline active:!bg-transparent"
className="bg-none hover:underline active:underline active:!bg-transparent"
onClick={(evt) => evt.stopPropagation()}
href={makeCollectiviteTacheUrl({
collectiviteId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,84 @@ import {
useReferentielId,
useReferentielVue,
} from '@/app/core-logic/hooks/params';
import { ReferentielOfIndicateur } from '@/app/types/litterals';
import { Tab, Tabs } from '@/app/ui/shared/Tabs';
import { Referentiel, ReferentielOfIndicateur } from '@/app/types/litterals';
import { Tab, Tabs } from '@/ui';
import { useRouter } from 'next/navigation';
import { useReferentielDownToAction } from '../../../../core-logic/hooks/referentiel';
import ActionProgressBar from '../../../../ui/referentiels/ActionProgressBar';
import { Counter } from '../../../../ui/referentiels/Counter';
import AidePriorisation from '../AidePriorisation';
import DetailTacheTable from '../DetailTaches';
import Progression from './Referentiels';
import ActionsReferentiels from './Referentiels';

const TABS_INDEX: Record<ReferentielVueParamOption, number> = {
progression: 0,
priorisation: 1,
detail: 2,
};

/**
* Affiche les onglets des vues tabulaires sur le référentiel
*/
const ReferentielHeader = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si on met la page de progression dans un dossier à part, on pourrait séparer ReferentielTabs et ReferentielHeader

referentielId,
className,
}: {
referentielId: ReferentielParamOption;
className?: string;
}) => {
const current = referentielId ?? 'eci';
const actions = useReferentielDownToAction(current as Referentiel);
const referentiel = actions.find((a) => a.type === 'referentiel')!;

return (
<div className={className}>
<h2 className="mb-4">
Référentiel{' '}
{referentielToName[referentielId as ReferentielOfIndicateur]}
</h2>
{/*****************************************/}
{/* */}
{/* For future use: start */}
{/* (Figer une version du référentiel) */}
{/* */}
{/*****************************************/}
Comment on lines +45 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magnifique panneau

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha merci, j'y ai mis toute mon âme artistique


{/* <div className="flex gap-x-4"> */}
{/* <Select
options={[]}
onChange={() => {}}
values={[]}
customItem={(v) => <span className="text-grey-8">{v.label}</span>}
small
/>
<Button
icon="save-3-line"
size="sm"
className="whitespace-nowrap min-w-fit"
>
Figer le référentiel
</Button> */}
{/* </div> */}

{/**********************************/}
{/* */}
{/* For future use: end */}
{/* */}
{/**********************************/}

{referentiel && (
<div className="flex items-center gap-4 pb-4 mb-4 border-b border-primary-3">
<div className="grow">
<ActionProgressBar
action={referentiel}
progressBarStyleOptions={{ fullWidth: true }}
/>
</div>
<Counter actionId={referentiel.id} className="ml-auto" />
</div>
)}
</div>
);
};

const ReferentielTabs = () => {
const collectiviteId = useCollectiviteId();
const referentielId = useReferentielId() as ReferentielParamOption;
Expand Down Expand Up @@ -60,31 +122,40 @@ const ReferentielTabs = () => {
};

return (
<main className="fr-container fr-mt-4w flex flex-col items-center">
<h1 className="fr-mb-4w">
Référentiel{' '}
{referentielToName[referentielId as ReferentielOfIndicateur]}
</h1>
<Tabs
className="w-full"
defaultActiveTab={activeTab}
onChange={handleChange}
>
<Tab label="Progression">
<Progression />
</Tab>
<Tab label="Aide à la priorisation">
{activeTab === TABS_INDEX['priorisation'] ? (
<AidePriorisation />
) : (
'...'
)}
</Tab>
<Tab label="Détail des statuts">
{activeTab === TABS_INDEX['detail'] ? <DetailTacheTable /> : '...'}
</Tab>
</Tabs>
</main>
<div className="grow bg-grey-2 -mb-8 py-12 px-4 lg:px-6 2xl:px-0">
<div className="m-auto xl:max-w-[90rem] 2xl:px-6">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici pour cette div tu pourras utiliser le nouveau compo PageContainer quand il sera merge sur main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je me note de faire une PR corrective si jamais cette branche est merge avant celle qui contient PageContainer, merci

<ReferentielHeader referentielId={referentielId} />
<Tabs
defaultActiveTab={activeTab}
onChange={handleChange}
tabsListClassName="!justify-start pl-0 flex-nowrap bg-transparent"
>
<Tab label="Actions">
<div className="p-7 border border-primary-2 bg-white rounded-lg">
<ActionsReferentiels />
</div>
</Tab>
<Tab label="Aide à la priorisation" className="!text-primary-500">
{activeTab === TABS_INDEX['priorisation'] ? (
<div className="p-7 border border-primary-2 bg-white rounded-lg">
<AidePriorisation />
</div>
) : (
'...'
)}
</Tab>
<Tab label="Détail des statuts">
{activeTab === TABS_INDEX['detail'] ? (
<div className="p-7 border border-primary-2 bg-white rounded-lg">
<DetailTacheTable />
</div>
) : (
'...'
)}
</Tab>
</Tabs>
</div>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import { ActionDefinitionSummary } from '@/app/core-logic/api/endpoints/ActionDefinitionSummaryReadEndpoint';
import { useReferentielId } from '@/app/core-logic/hooks/params';
import { useReferentielDownToAction } from '@/app/core-logic/hooks/referentiel';
import { useCurrentCollectivite } from '@/app/core-logic/hooks/useCurrentCollectivite';
import { Referentiel } from '@/app/types/litterals';
import ActionProgressBar from '@/app/ui/referentiels/ActionProgressBar';
import { ExpandableAction } from '@/app/ui/shared/actions/ExpandableAction';
import SpinnerLoader from '@/app/ui/shared/SpinnerLoader';
import { Button, Checkbox, OptionValue, Select } from '@/ui';
import { useState } from 'react';
import { ReferentielCard } from '../../../../ui/referentiels/Card/ReferentielCard';
import { useExportScore } from './useExportScore';

const ReferentielHead = (props: { referentiel: ActionDefinitionSummary }) => {
return (
<>
<header className="flex flex-row mb-6 items-center justify-between">
<h2 className="fr-h2">{props.referentiel.nom}</h2>
<ActionProgressBar action={props.referentiel} />
</header>
</>
);
};

export const ActionsReferentiels = () => {
const referentielId = useReferentielId();
const current = referentielId ?? 'eci';
Expand All @@ -31,27 +22,78 @@ export const ActionsReferentiels = () => {
referentielId,
collectivite
);
const [isDescriptionOn, setIsDescriptionOn] = useState(false);
const [displayOption, setDisplayOption] = useState<OptionValue>('axe');

if (!referentiel) return <></>;
if (!referentiel) return <SpinnerLoader />;

return (
<main data-test="ActionsReferentiels" className="fr-container mt-9">
<ReferentielHead referentiel={referentiel} />
<section>
{axes.map((axe) => (
<ExpandableAction action={axe} key={axe.id} />
<main data-test="ActionsReferentiels" className="fr-container mt-2">
<div className="relative flex justify-between max-xl:flex-col xl:items-center gap-4 pb-6 border-b border-primary-3 mb-6">
<div className="flex max-md:flex-col gap-x-8 gap-y-4 md:items-center">
<div className="w-full md:w-64">
<Select
options={[
{ value: 'axe', label: 'Par axe' },
{ value: 'action', label: 'Par action' },
]}
onChange={(value) => setDisplayOption(value ?? 'axe')}
values={[displayOption]}
customItem={(v) => (
<span className="text-grey-8 font-normal">{v.label}</span>
)}
small
/>
</div>

<Checkbox
label="Afficher la description des actions"
variant="switch"
labelClassname="font-normal text-sm !text-grey-7"
containerClassname="items-center"
checked={isDescriptionOn}
onChange={() => setIsDescriptionOn(!isDescriptionOn)}
disabled={isLoading}
/>
</div>

<Button
data-test="export-scores"
icon={'download-fill'}
disabled={isLoading}
onClick={() => exportScore()}
size="sm"
/>
</div>

{displayOption === 'axe' &&
axes.map((axe) => (
<ExpandableAction
action={axe}
key={axe.id}
isDescriptionOn={isDescriptionOn}
/>
))}
</section>
<button
data-test="export-scores"
className="fr-btn fr-btn--icon-left fr-fi-download-line fr-mt-6w"
disabled={isLoading}
onClick={() => {
exportScore();
}}
>
Exporter
</button>

{displayOption === 'action' && (
<div>
<div
className={`grid grid-cols-1 ${
!isDescriptionOn ? 'sm:grid-cols-2 lg:grid-cols-3' : ''
} gap-4 grid-rows-1`}
>
{actions
.filter((action) => action.type === 'action')
.map((action) => (
<ReferentielCard
key={action.id}
action={action}
isDescriptionOn={isDescriptionOn}
/>
))}
</div>
</div>
)}
</main>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { avancementToLabel } from '@/app/app/labels';
import { actionAvancementColors } from '@/app/app/theme';
import { ActionDefinitionSummary } from '@/app/core-logic/api/endpoints/ActionDefinitionSummaryReadEndpoint';
import { useActionScore } from '@/app/core-logic/hooks/scoreHooks';
import ProgressBarWithTooltip from '@/app/ui/score/ProgressBarWithTooltip';
import { useActionScore } from '../../core-logic/hooks/scoreHooks';
import { ProgressBarStyleOptions } from '../score/ProgressBar';

export const ActionProgressBar = ({
action,
// remettre actionId au lieu de action une fois l'affichage des scores par % généralisé
className,
progressBarStyleOptions,
}: {
action: ActionDefinitionSummary;
className?: string;
progressBarStyleOptions?: ProgressBarStyleOptions;
}) => {
const score = useActionScore(action.id);

const isReglementaire = action.identifiant.split('.').includes('0');

if (score === null || (score.point_potentiel < 1e-3 && !isReglementaire))
Expand Down Expand Up @@ -58,8 +62,8 @@ export const ActionProgressBar = ({
label: avancementToLabel.non_renseigne,
color: actionAvancementColors.non_renseigne,
}}
valueToDisplay={avancementToLabel.fait}
percent={action.type === 'tache'}
progressBarStyleOptions={progressBarStyleOptions}
/>
</div>
);
Expand Down
Loading
Loading