From 79ecd7955e2a6764c81d4666cf0d9c052a2fc408 Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Fri, 16 Feb 2024 16:18:26 +0000 Subject: [PATCH] refactor(structure): remove hard-coded categories to change work label to "France Travail" --- .../needs-selection.component.ts | 2 +- src/app/models/personalOffer.model.ts | 4 ++- src/app/models/structure.model.ts | 3 ++- .../personal-offer.component.html | 6 ++--- .../structure-edition-summary.component.html | 25 +++++++++++-------- .../structure-edition-summary.component.ts | 5 ---- .../logo-card/logo-card.component.html | 6 ++--- .../logo-card/logo-card.component.ts | 18 +++---------- src/app/shared/enum/demarches.enum.ts | 16 ------------ src/app/shared/enum/demarchesLogo.enum.ts | 16 ------------ src/app/shared/enum/labels.emum.ts | 12 --------- .../structure-details.component.html | 22 ++++++++-------- src/app/utils/utils.ts | 7 +----- 13 files changed, 42 insertions(+), 100 deletions(-) delete mode 100644 src/app/shared/enum/demarches.enum.ts delete mode 100644 src/app/shared/enum/demarchesLogo.enum.ts delete mode 100644 src/app/shared/enum/labels.emum.ts diff --git a/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts b/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts index f69e882d5..544db2f1b 100644 --- a/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts +++ b/src/app/form/orientation-form-view/global-components/needs-selection/needs-selection.component.ts @@ -30,7 +30,7 @@ export class NeedsSelectionComponent implements OnInit { }, { title: 'Réaliser une démarche en ligne', - hint: '(Démarche Caf, CPAM, Pôle emploi…)', + hint: '(Démarche Caf, CPAM, France Travail…)', key: NeedsType.onlineDemarch, icon: 'orientationIndex2', }, diff --git a/src/app/models/personalOffer.model.ts b/src/app/models/personalOffer.model.ts index 0cb13b9c9..463fe0832 100644 --- a/src/app/models/personalOffer.model.ts +++ b/src/app/models/personalOffer.model.ts @@ -1,7 +1,9 @@ +import { Module } from '../structure-list/models/module.model'; + export class PersonalOffer { public _id: string = null; public categories: Record<string, string[]>; - public categoriesDisplay?: Record<string, string[]>; + public categoriesDisplay?: Record<string, Module[]>; constructor(obj?: any) { Object.assign(this, obj, { diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index 435d925f9..0f7f135e3 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -1,6 +1,7 @@ import { StructureCategoryEnum } from '../shared/enum/structureCategory.enum'; import { StructureCategoryIconEnum } from '../shared/enum/structureCategoryIcon.enum'; import { Weekday } from '../structure-list/enum/weekday.enum'; +import { Module } from '../structure-list/models/module.model'; import { FreeWorkshop } from '../structure/enums/freeWorkshop.enum'; import { Address } from './address.model'; import { OpeningDay } from './openingDay.model'; @@ -35,7 +36,7 @@ export class Structure { public contactPersonLastName: string = null; public contactPersonEmail: string = null; public categories: Record<string, string[]>; - public categoriesDisplay: Record<string, string[]>; + public categoriesDisplay: Record<string, Module[]>; public remoteAccompaniment: boolean = null; public nbComputers: number = null; public nbPrinters: number = null; diff --git a/src/app/profile/profile-structure/personal-offer/personal-offer.component.html b/src/app/profile/profile-structure/personal-offer/personal-offer.component.html index 43f7c529c..4bb0938ce 100644 --- a/src/app/profile/profile-structure/personal-offer/personal-offer.component.html +++ b/src/app/profile/profile-structure/personal-offer/personal-offer.component.html @@ -30,7 +30,7 @@ <app-collapse-content> <ul> <li *ngFor="let onlineProcedure of this.personalOffer.categoriesDisplay.onlineProcedures"> - {{ onlineProcedure }} + {{ onlineProcedure.name }} </li> </ul> </app-collapse-content> @@ -44,7 +44,7 @@ </app-collapse-header> <app-collapse-content> <ul> - <li *ngFor="let baseSkill of this.personalOffer.categoriesDisplay.baseSkills">{{ baseSkill }}</li> + <li *ngFor="let baseSkill of this.personalOffer.categoriesDisplay.baseSkills">{{ baseSkill.name }}</li> </ul> </app-collapse-content> </app-collapse> @@ -58,7 +58,7 @@ <app-collapse-content> <ul> <li *ngFor="let advancedSkill of this.personalOffer.categoriesDisplay.advancedSkills"> - {{ advancedSkill }} + {{ advancedSkill.name }} </li> </ul> </app-collapse-content> diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.html b/src/app/profile/structure-edition-summary/structure-edition-summary.component.html index 8b77f7e68..4cc10cfa9 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.html +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.html @@ -289,7 +289,7 @@ <div *ngIf="containsDigitalHelp()" class="list"> <app-tag-item *ngFor="let digitalHelp of structure.categoriesDisplay.onlineProcedures" - [label]="digitalHelp" + [label]="digitalHelp.name" [color]="'red'" [size]="'small'" /> @@ -362,7 +362,7 @@ <hr /> <ul> <li *ngFor="let skill of structure.categoriesDisplay.baseSkills"> - {{ skill }} + {{ skill.name }} </li> </ul> </app-collapse-content> @@ -378,7 +378,7 @@ <hr /> <ul> <li *ngFor="let skill of structure.categoriesDisplay.advancedSkills"> - {{ skill }} + {{ skill.name }} </li> </ul> </app-collapse-content> @@ -505,7 +505,7 @@ <div class="list"> <app-tag-item *ngFor="let material of structure.categoriesDisplay.solidarityMaterial" - [label]="material" + [label]="material.name" [color]="'red'" [size]="'small'" /> @@ -536,7 +536,7 @@ <div *ngIf="isFieldValid('accessModality', 'categories')" class="list"> <app-tag-item *ngFor="let accessModality of structure.categoriesDisplay.accessModality" - [label]="accessModality" + [label]="accessModality.name" [color]="'red'" [size]="'small'" /> @@ -569,7 +569,7 @@ <div *ngIf="isFieldValid('age', 'categories') && structure.categoriesDisplay.age" class="list"> <app-tag-item *ngFor="let public of structure.categoriesDisplay.age" - [label]="public" + [label]="public.name" [color]="'red'" [size]="'small'" /> @@ -606,7 +606,7 @@ <div *ngIf="structure.categoriesDisplay.languageAndIlliteracy.length" class="list"> <app-tag-item *ngFor="let public of structure.categoriesDisplay.languageAndIlliteracy" - [label]="public" + [label]="public.name" [color]="'red'" [size]="'small'" /> @@ -618,7 +618,7 @@ <div *ngIf="structure.categoriesDisplay.handicaps.length" class="list"> <app-tag-item *ngFor="let public of structure.categoriesDisplay.handicaps" - [label]="public" + [label]="public.name" [color]="'red'" [size]="'small'" /> @@ -630,7 +630,7 @@ <div *ngIf="structure.categoriesDisplay.genre.length" class="list"> <app-tag-item *ngFor="let public of structure.categoriesDisplay.genre" - [label]="public" + [label]="public.name" [color]="'red'" [size]="'small'" /> @@ -722,9 +722,12 @@ /> </div> <div class="content"> - <app-no-information *ngIf="structure.categories.labelsQualifications.length === 0" /> + <app-no-information *ngIf="structure.categoriesDisplay.labelsQualifications.length === 0" /> <div class="labelsContainer"> - <app-logo-card *ngFor="let label of structure.categories.labelsQualifications.sort()" [name]="label" /> + <app-logo-card + *ngFor="let label of structure.categoriesDisplay.labelsQualifications.sort()" + [module]="label" + /> </div> </div> </section> diff --git a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts index dcf3e589b..9a9b89aaf 100644 --- a/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts +++ b/src/app/profile/structure-edition-summary/structure-edition-summary.component.ts @@ -10,7 +10,6 @@ import { Structure } from '../../models/structure.model'; import { NotificationService } from '../../services/notification.service'; import { StructureService } from '../../services/structure.service'; import { CategoryEnum } from '../../shared/enum/category.enum'; -import { Demarches } from '../../shared/enum/demarches.enum'; import { AccessModality } from '../../structure-list/enum/access-modality.enum'; import { Equipment } from '../../structure-list/enum/equipment.enum'; import { Category } from '../../structure-list/models/category.model'; @@ -156,10 +155,6 @@ export class StructureEditionSummaryComponent implements OnInit { return this.structure.categoriesDisplay.onlineProcedures?.length > 0; } - public getDigitalHelpLabel(digitalHelp: Demarches): string { - return this.utils.getDigitalHelpLabel(digitalHelp); - } - public isBaseSkills(): boolean { return this.structure.categories.baseSkills?.length > 0; } diff --git a/src/app/shared/components/logo-card/logo-card.component.html b/src/app/shared/components/logo-card/logo-card.component.html index a8b43209e..cf2170a0c 100644 --- a/src/app/shared/components/logo-card/logo-card.component.html +++ b/src/app/shared/components/logo-card/logo-card.component.html @@ -1,4 +1,4 @@ -<div *ngIf="name"> - <img class="icon-40" [src]="getPath(name)" [alt]="" /> - <p>{{ getName(name) }}</p> +<div *ngIf="module"> + <img class="icon-40" [src]="getPath()" [alt]="" /> + <p>{{ module.name }}</p> </div> diff --git a/src/app/shared/components/logo-card/logo-card.component.ts b/src/app/shared/components/logo-card/logo-card.component.ts index a9f4bd2c9..e51156c3f 100644 --- a/src/app/shared/components/logo-card/logo-card.component.ts +++ b/src/app/shared/components/logo-card/logo-card.component.ts @@ -1,6 +1,5 @@ import { Component, Input } from '@angular/core'; -import { Demarches } from '../../enum/demarches.enum'; -import { Labels } from '../../enum/labels.emum'; +import { Module } from '../../../structure-list/models/module.model'; @Component({ selector: 'app-logo-card', @@ -8,18 +7,9 @@ import { Labels } from '../../enum/labels.emum'; styleUrls: ['./logo-card.component.scss'], }) export class LogoCardComponent { - @Input() public name: string; + @Input() public module: Module; - public getName(key: string): string { - if (Labels[key]) { - return Labels[key]; - } else { - return key; - } - } - - public getPath(value: string): string { - const path = Object.entries(Demarches).find(([, val]) => val === value)?.[0]; - return `assets/logos/${path || this.name}.svg`; + public getPath(): string { + return `assets/logos/${this.module.id}.svg`; } } diff --git a/src/app/shared/enum/demarches.enum.ts b/src/app/shared/enum/demarches.enum.ts deleted file mode 100644 index eea5e4880..000000000 --- a/src/app/shared/enum/demarches.enum.ts +++ /dev/null @@ -1,16 +0,0 @@ -export enum Demarches { - caf = 'CAF', - idDoc = 'Carte d’identité, passeport', - needs = 'Énergie, téléphonie, internet', - foreigners = 'Démarches liées aux étrangers', - franceConnect = 'France Connect', - training = 'Formation (CPF...)', - taxes = 'Impôts', - housing = 'Logement', - retirement = 'Retraite', - health = 'Santé (Ameli, CPAM...)', - scolarity = 'Scolarité (CROUS…)', - transport = 'Transports (carte grise, permis, TCL…)', - work = 'Travail (Pôle emploi, CESU…)', - autres = 'Autres', -} diff --git a/src/app/shared/enum/demarchesLogo.enum.ts b/src/app/shared/enum/demarchesLogo.enum.ts deleted file mode 100644 index d9f55e20d..000000000 --- a/src/app/shared/enum/demarchesLogo.enum.ts +++ /dev/null @@ -1,16 +0,0 @@ -export enum DemarchesLogo { - caf = 'caf', - idDoc = 'Carte d’identité, passeport', - needs = 'Énergie, téléphonie, internet', - foreigners = 'Démarches liées aux étrangers', - franceConnect = 'France Connect', - training = 'Formation (CPF...)', - taxes = 'Impôts', - housing = 'Logement', - retirement = 'Retraite', - health = 'Santé (Ameli...)', - scolarity = 'Scolarité (CROUS…)', - transport = 'Transports (carte grise, permis, TCL…)', - work = 'Travail (Pôle emploi, CESU…)', - autres = 'Autres', -} diff --git a/src/app/shared/enum/labels.emum.ts b/src/app/shared/enum/labels.emum.ts deleted file mode 100644 index 8e4c20f95..000000000 --- a/src/app/shared/enum/labels.emum.ts +++ /dev/null @@ -1,12 +0,0 @@ -export enum Labels { - passNumerique = 'Pass numérique', - espacePublicNumeriqueepn = 'Espace public numérique', - maisonFranceService = 'Maison france service', - aidantsConnect = 'Aidants connect', - fabriqueDeTerritoire = 'Fabrique de territoire', - demarcheMetropolitaine = 'Démarches Métropolitaines', - conseillerNumFranceServices = 'Conseiller numérique', - monEspaceSante = 'Mon espace santé', - numRelay = 'Les relais numériques', - mesPapiers = 'Mes papiers', -} diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html index c58d595a4..6f0773b9b 100644 --- a/src/app/structure-list/components/structure-details/structure-details.component.html +++ b/src/app/structure-list/components/structure-details/structure-details.component.html @@ -185,7 +185,7 @@ <div class="inline"> <app-tag-item *ngFor="let access of structure.categoriesDisplay.accessModality" - [label]="access" + [label]="access.name" [color]="'red'" [size]="'small'" [clickable]="false" @@ -204,7 +204,7 @@ <div class="inline"> <app-tag-item *ngFor="let label of structure.categoriesDisplay.age.sort()" - [label]="label" + [label]="label.name" [color]="'red'" [size]="'small'" [clickable]="false" @@ -221,7 +221,7 @@ <div class="inline"> <app-tag-item *ngFor="let label of structure.categoriesDisplay.languageAndIlliteracy.sort()" - [label]="label" + [label]="label.name" [color]="'red'" [size]="'small'" [clickable]="false" @@ -234,7 +234,7 @@ <div class="inline"> <app-tag-item *ngFor="let label of structure.categoriesDisplay.handicaps.sort()" - [label]="label" + [label]="label.name" [color]="'red'" [size]="'small'" [clickable]="false" @@ -247,7 +247,7 @@ <div class="inline"> <app-tag-item *ngFor="let label of structure.categoriesDisplay.genre.sort()" - [label]="label" + [label]="label.name" [color]="'red'" [size]="'small'" [clickable]="false" @@ -257,10 +257,10 @@ </section> <!-- Labellisation --> - <section *ngIf="structure.categories.labelsQualifications.length" class="labels"> + <section *ngIf="structure.categoriesDisplay.labelsQualifications.length" class="labels"> <h2>Labellisations</h2> <div class="wrapper"> - <app-logo-card *ngFor="let label of structure.categories.labelsQualifications.sort()" [name]="label" /> + <app-logo-card *ngFor="let label of structure.categoriesDisplay.labelsQualifications.sort()" [module]="label" /> </div> </section> @@ -296,7 +296,7 @@ <div class="wrapper"> <app-logo-card *ngFor="let accompagnement of structure.categoriesDisplay.onlineProcedures.sort()" - [name]="accompagnement" + [module]="accompagnement" /> </div> <div *ngIf="structure.otherDescription" class="otherDescription"> @@ -314,7 +314,7 @@ <div *ngIf="hasBaseSkills()" class="skillsContainer"> <h3 class="titleSkills">Compétences numériques de base</h3> <ul> - <li *ngFor="let skill of structure.categoriesDisplay.baseSkills" class="details">{{ skill }}</li> + <li *ngFor="let skill of structure.categoriesDisplay.baseSkills" class="details">{{ skill.name }}</li> </ul> </div> @@ -323,7 +323,7 @@ <h3 class="titleSkills">Approfondir sa culture numérique</h3> <ul> <li *ngFor="let skill of structure.categoriesDisplay.advancedSkills" class="details"> - {{ skill }} + {{ skill.name }} </li> </ul> </div> @@ -369,7 +369,7 @@ <div class="inline"> <app-tag-item *ngFor="let equipment of structure.categoriesDisplay.solidarityMaterial" - [label]="equipment" + [label]="equipment.name" [color]="'red'" [size]="'small'" [clickable]="false" diff --git a/src/app/utils/utils.ts b/src/app/utils/utils.ts index 1ee5d7061..35ff3314f 100644 --- a/src/app/utils/utils.ts +++ b/src/app/utils/utils.ts @@ -3,7 +3,6 @@ import { UntypedFormGroup } from '@angular/forms'; import { Owner } from '../models/owner.model'; import { Structure } from '../models/structure.model'; import { User } from '../models/user.model'; -import { Demarches } from '../shared/enum/demarches.enum'; import { OtherServices } from '../shared/enum/otherServices.enum'; import { AccessModality } from '../structure-list/enum/access-modality.enum'; import { Equipment } from '../structure-list/enum/equipment.enum'; @@ -79,10 +78,6 @@ export class Utils { return structure.website !== null && structure.website !== ''; } - public getDigitalHelpLabel(digitalHelp: Demarches): string { - return Demarches[digitalHelp]; - } - public hasWifi(selfServiceMaterial: string[]): boolean { return selfServiceMaterial.includes('wifiEnAccesLibre'); } @@ -140,7 +135,7 @@ export class Utils { const moduleNames = category.modules .map((module) => { if (structureModuleIds.includes(module.id)) { - return module.name; + return module; } }) .filter((value) => value !== undefined); -- GitLab