-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wip: Ajoute la nouvelle page Toutes les actions sans filtre dans l'URL
- Loading branch information
Showing
8 changed files
with
292 additions
and
1 deletion.
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
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
213 changes: 213 additions & 0 deletions
213
...ges/collectivite/PlansActions/ToutesLesFichesAction/ModalFiltresToutesLesFichesAction.tsx
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 |
---|---|---|
@@ -0,0 +1,213 @@ | ||
import {useState} from 'react'; | ||
|
||
import { | ||
Checkbox, | ||
Field, | ||
FormSection, | ||
FormSectionGrid, | ||
Modal, | ||
ModalFooterOKCancel, | ||
ModalProps, | ||
SelectFilter, | ||
} from '@tet/ui'; | ||
import {QueryKey} from 'react-query'; | ||
import PersonnesDropdown from 'ui/dropdownLists/PersonnesDropdown/PersonnesDropdown'; | ||
import {Filtre} from '@tet/api/dist/src/fiche_actions/fiche_resumes.list/domain/fetch_options.schema'; | ||
import { | ||
ficheActionNiveauPrioriteOptions, | ||
ficheActionStatutOptions, | ||
} from 'app/pages/collectivite/PlansActions/FicheAction/data/options/listesStatiques'; | ||
import {TFicheActionNiveauxPriorite, TFicheActionStatuts} from 'types/alias'; | ||
import BadgeStatut from 'app/pages/collectivite/PlansActions/components/BadgeStatut'; | ||
import BadgePriorite from 'app/pages/collectivite/PlansActions/components/BadgePriorite'; | ||
import { | ||
getPilotesValues, | ||
getReferentsValues, | ||
splitPilotePersonnesAndUsers, | ||
splitReferentPersonnesAndUsers, | ||
} from 'ui/dropdownLists/PersonnesDropdown/utils'; | ||
import ServicesPilotesDropdown from 'ui/dropdownLists/ServicesPilotesDropdown/ServicesPilotesDropdown'; | ||
import ThematiquesDropdown from 'ui/dropdownLists/ThematiquesDropdown/ThematiquesDropdown'; | ||
import FinanceursDropdown from 'ui/dropdownLists/FinanceursDropdown/FinanceursDropdown'; | ||
|
||
type Props = ModalProps & { | ||
filters: Filtre; | ||
setFilters: (filters: Filtre) => void; | ||
keysToInvalidate?: QueryKey[]; | ||
}; | ||
|
||
const ModalFiltresToutesLesFichesAction = ({ | ||
openState, | ||
filters, | ||
setFilters, | ||
keysToInvalidate, | ||
}: Props) => { | ||
const [filtreState, setFiltreState] = useState<Filtre>(filters); | ||
|
||
const pilotes = getPilotesValues(filtreState); | ||
const referents = getReferentsValues(filtreState); | ||
|
||
return ( | ||
<Modal | ||
openState={openState} | ||
render={() => ( | ||
<> | ||
<FormSection title="Nouveau filtre :" className="!grid-cols-1"> | ||
<Field title="Pilote"> | ||
<PersonnesDropdown | ||
values={pilotes} | ||
onChange={({personnes}) => { | ||
setFiltreState({ | ||
...filtreState, | ||
...splitPilotePersonnesAndUsers(personnes), | ||
}); | ||
}} | ||
/> | ||
</Field> | ||
<Field title="Direction ou service pilote"> | ||
<ServicesPilotesDropdown | ||
values={ | ||
filtreState.servicePiloteIds?.length | ||
? filtreState.servicePiloteIds | ||
: undefined | ||
} | ||
onChange={({services}) => { | ||
setFiltreState({...filtreState, servicePiloteIds: services}); | ||
}} | ||
/> | ||
</Field> | ||
<FormSectionGrid> | ||
<Field title="Statut de l'action"> | ||
<SelectFilter | ||
values={filtreState.statuts ?? undefined} | ||
options={ficheActionStatutOptions} | ||
onChange={({values}) => { | ||
const {statuts, ...rest} = filtreState; | ||
if (values) { | ||
setFiltreState({ | ||
...filtreState, | ||
statuts: values as TFicheActionStatuts[], | ||
}); | ||
} else { | ||
setFiltreState(rest); | ||
} | ||
}} | ||
customItem={item => ( | ||
<BadgeStatut statut={item.value as TFicheActionStatuts} /> | ||
)} | ||
/> | ||
</Field> | ||
<Field title="Niveau de priorité"> | ||
<SelectFilter | ||
values={filtreState.priorites ?? undefined} | ||
options={ficheActionNiveauPrioriteOptions} | ||
onChange={({values}) => { | ||
const {priorites, ...rest} = filtreState; | ||
if (values) { | ||
setFiltreState({ | ||
...filtreState, | ||
priorites: values as TFicheActionNiveauxPriorite[], | ||
}); | ||
} else { | ||
setFiltreState(rest); | ||
} | ||
}} | ||
customItem={item => ( | ||
<BadgePriorite | ||
priorite={item.value as TFicheActionNiveauxPriorite} | ||
/> | ||
)} | ||
/> | ||
</Field> | ||
</FormSectionGrid> | ||
<Field title="Thématique"> | ||
<ThematiquesDropdown | ||
values={ | ||
filtreState.thematiqueIds && | ||
filtreState.thematiqueIds.length > 0 | ||
? filtreState.thematiqueIds | ||
: undefined | ||
} | ||
onChange={({thematiques}) => | ||
setFiltreState({ | ||
...filtreState, | ||
thematiqueIds: thematiques.map(t => t.id), | ||
}) | ||
} | ||
/> | ||
</Field> | ||
<Field title="Financeur"> | ||
<FinanceursDropdown | ||
values={ | ||
filtreState.financeurIds && | ||
filtreState.financeurIds.length > 0 | ||
? filtreState.financeurIds | ||
: undefined | ||
} | ||
onChange={({financeurs}) => { | ||
setFiltreState({...filtreState, financeurIds: financeurs}); | ||
}} | ||
/> | ||
</Field> | ||
</FormSection> | ||
<Field title="Élu·e référent·e"> | ||
<PersonnesDropdown | ||
values={referents} | ||
onChange={({personnes}) => { | ||
setFiltreState({ | ||
...filtreState, | ||
...splitReferentPersonnesAndUsers(personnes), | ||
}); | ||
}} | ||
/> | ||
</Field> | ||
<Checkbox | ||
label="Budget renseigné" | ||
checked={filtreState.budgetPrevisionnel} | ||
onChange={() => | ||
setFiltreState({ | ||
...filtreState, | ||
budgetPrevisionnel: !filtreState.budgetPrevisionnel, | ||
}) | ||
} | ||
/> | ||
<Checkbox | ||
label="Confidentialité" | ||
checked={filtreState.restreint} | ||
onChange={() => | ||
setFiltreState({ | ||
...filtreState, | ||
restreint: !filtreState.restreint, | ||
}) | ||
} | ||
/> | ||
<Checkbox | ||
label="Indicateur(s) lié" | ||
checked={filtreState.hasIndicateurLies} | ||
onChange={() => | ||
setFiltreState({ | ||
...filtreState, | ||
hasIndicateurLies: !filtreState.hasIndicateurLies, | ||
}) | ||
} | ||
/> | ||
</> | ||
)} | ||
renderFooter={({close}) => ( | ||
<ModalFooterOKCancel | ||
btnCancelProps={{ | ||
onClick: () => close(), | ||
}} | ||
btnOKProps={{ | ||
onClick: () => { | ||
setFilters(filtreState); | ||
close(); | ||
}, | ||
}} | ||
/> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default ModalFiltresToutesLesFichesAction; |
28 changes: 28 additions & 0 deletions
28
...t/src/app/pages/collectivite/PlansActions/ToutesLesFichesAction/ToutesLesFichesAction.tsx
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Filtre} from '@tet/api/dist/src/fiche_actions/fiche_resumes.list/domain/fetch_options.schema'; | ||
import ModalFiltresToutesLesFichesAction from 'app/pages/collectivite/PlansActions/ToutesLesFichesAction/ModalFiltresToutesLesFichesAction'; | ||
import FichesActionListe from 'app/pages/collectivite/TableauDeBord/Module/ModuleFichesActions/FichesActionListe'; | ||
import {useState} from 'react'; | ||
|
||
const ToutesLesFichesAction = () => { | ||
const [filters, setFilters] = useState<Filtre>({}); | ||
|
||
return ( | ||
<div className="min-h-[44rem] flex flex-col gap-8"> | ||
<div> | ||
<h2 className="mb-0">Toutes les actions</h2> | ||
</div> | ||
<FichesActionListe | ||
filtres={filters} | ||
settingsModal={openState => ( | ||
<ModalFiltresToutesLesFichesAction | ||
openState={openState} | ||
filters={filters} | ||
setFilters={filters => setFilters(filters)} | ||
/> | ||
)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ToutesLesFichesAction; |
18 changes: 18 additions & 0 deletions
18
...c/app/pages/collectivite/PlansActions/ToutesLesFichesAction/ToutesLesFichesActionPage.tsx
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {Suspense} from 'react'; | ||
import {lazy} from 'utils/lazy'; | ||
import {renderLoader} from 'utils/renderLoader'; | ||
|
||
const ToutesLesFichesAction = lazy( | ||
() => | ||
import( | ||
'app/pages/collectivite/PlansActions/ToutesLesFichesAction/ToutesLesFichesAction' | ||
) | ||
); | ||
|
||
export const ToutesLesFichesActionPage = () => { | ||
return ( | ||
<Suspense fallback={renderLoader()}> | ||
<ToutesLesFichesAction /> | ||
</Suspense> | ||
); | ||
}; |
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