Skip to content

Commit 2942859

Browse files
committed
Refactor lifecycle states configuration: enhance states.yml, update DTOs to include optional icons, and streamline lifecycle service state retrieval
1 parent d2741cb commit 2942859

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

defaults/lifecycle/states.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ states:
33
- key: A
44
label: "En Attente"
55
description: "supannRessourceEtat : {COMPTE} A SupannAnticipe"
6+
icon: "mdi-account-clock"
67

7-
# PROV -> supannResourceEtat : {COMTE} A SupannSursis et supannRessourceEtatDate: Date de passage en PROV
8+
# PROV -> supannResourceEtat : {COMPTE} A SupannSursis et supannRessourceEtatDate: Date de passage en PROV
89
- key: P
9-
label: "PROV"
10-
description: "supannResourceEtat : {COMTE} A SupannSursis et supannRessourceEtatDate: Date de passage en PROV"
10+
label: "Provisoire"
11+
description: "supannResourceEtat : {COMPTE} A SupannSursis et supannRessourceEtatDate: Date de passage en PROV"
12+
icon: "mdi-account-alert"
1113

1214
# A Détruire -> supannRessourceEtat : {COMPTE} I SupannSupprCompte
1315
- key: D
1416
label: "A Détruire"
1517
description: "supannRessourceEtat : {COMPTE} I SupannSupprCompte"
18+
icon: "mdi-account-remove"
1619

1720
# Verrouillé -> supannRessourceEtat : {COMPTE} S SupannVerrouille
1821
- key: V
1922
label: "Verrouillé"
2023
description: "supannRessourceEtat : {COMPTE} S SupannVerrouille"
24+
icon: "mdi-account-lock"

src/management/identities/_enums/lifecycle.enum.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,24 @@ export enum IdentityLifecycleDefault {
33
INACTIVE = "I",
44
MANUAL = "M",
55
}
6+
7+
export const IdentityLifecycleDefaultList: Array<{ key: string; label: string; description: string, icon: string }> = [
8+
{
9+
key: IdentityLifecycleDefault.OFFICIAL,
10+
label: 'Officiel',
11+
description: 'supannRessourceEtat : {COMPTE} O SupannActif',
12+
icon: 'mdi-account-check',
13+
},
14+
{
15+
key: IdentityLifecycleDefault.INACTIVE,
16+
label: 'Inactif',
17+
description: 'supannRessourceEtat : {COMPTE} I SupannInactif',
18+
icon: 'mdi-account-off',
19+
},
20+
{
21+
key: IdentityLifecycleDefault.MANUAL,
22+
label: 'Manuel',
23+
description: 'supannRessourceEtat : {COMPTE} M SupannManuel',
24+
icon: 'mdi-account-cog',
25+
},
26+
];

src/management/lifecycle/_dto/config-states.dto.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ApiProperty } from '@nestjs/swagger';
2-
import { IsArray, IsNotEmpty, IsString, ValidateNested } from 'class-validator';
2+
import { IsArray, IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator';
33
import { Type } from 'class-transformer';
44

55
/**
@@ -37,6 +37,16 @@ export class LifecycleStateDTO {
3737
required: true,
3838
})
3939
public description: string;
40+
41+
@IsOptional()
42+
@IsString()
43+
@ApiProperty({
44+
type: String,
45+
description: 'Icône associée à l\'état (optionnel)',
46+
example: 'mdi-account-clock',
47+
required: false,
48+
})
49+
public icon?: string;
4050
}
4151

4252
/**

src/management/lifecycle/lifecycle.service.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Identities } from '../identities/_schemas/identities.schema';
1414
import { IdentitiesCrudService } from '../identities/identities-crud.service';
1515
import { ConfigRulesObjectIdentitiesDTO, ConfigRulesObjectSchemaDTO } from './_dto/config-rules.dto';
1616
import { ConfigStatesDTO, LifecycleStateDTO } from './_dto/config-states.dto';
17-
import { IdentityLifecycleDefault } from '../identities/_enums/lifecycle.enum';
17+
import { IdentityLifecycleDefault, IdentityLifecycleDefaultList } from '../identities/_enums/lifecycle.enum';
1818
import { Lifecycle, LifecycleRefId } from './_schemas/lifecycle.schema';
1919
import { ConfigService } from '@nestjs/config';
2020
import dayjs from 'dayjs';
@@ -316,16 +316,14 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
316316
public getAllAvailableStates(): Array<{ key: string; label: string; description: string }> {
317317
const allStates: Array<{ key: string; label: string; description: string }> = [];
318318

319-
// Ajouter les états par défaut de l'enum
320-
Object.entries(IdentityLifecycleDefault).forEach(([enumKey, enumValue]) => {
319+
IdentityLifecycleDefaultList.forEach(state => {
321320
allStates.push({
322-
key: enumValue,
323-
label: enumKey,
324-
description: `Default lifecycle state: ${enumKey}`,
321+
key: state.key,
322+
label: state.label,
323+
description: state.description,
325324
});
326325
});
327326

328-
// Ajouter les états custom
329327
this.customStates.forEach(customState => {
330328
allStates.push({
331329
key: customState.key,
@@ -334,7 +332,6 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
334332
});
335333
});
336334

337-
this.logger.debug(`Retrieved <${allStates.length}> total available lifecycle states`);
338335
return allStates;
339336
}
340337

@@ -361,8 +358,7 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
361358
* @returns An array of custom lifecycle states with their details
362359
*/
363360
public getCustomStates(): LifecycleStateDTO[] {
364-
this.logger.debug(`Retrieved <${this.customStates.length}> custom lifecycle states`);
365-
return [...this.customStates]; // Return a copy to prevent external modification
361+
return [...this.customStates];
366362
}
367363

368364
/**

0 commit comments

Comments
 (0)